lkml.org 
[lkml]   [2019]   [Feb]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH net-next 4/9] staging: fsl-dpaa2: ethsw: Check bridge port flags during prepare
    Date
    In preparation for removing SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS_SUPPORT,
    have ethsw check that the bridge port flags that are being set are
    supported when SWITCHDEV_ATTR_ID_PORT_PRE_BRIDGE_FLAGS is specified.

    Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
    ---
    drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 12 +++++++++---
    1 file changed, 9 insertions(+), 3 deletions(-)

    diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
    index 1b3943b71254..f788a9458b89 100644
    --- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
    +++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
    @@ -668,13 +668,16 @@ static int port_attr_stp_state_set(struct net_device *netdev,

    static int port_attr_br_flags_set(struct net_device *netdev,
    struct switchdev_trans *trans,
    - unsigned long flags)
    + unsigned long flags, bool pre_set)
    {
    struct ethsw_port_priv *port_priv = netdev_priv(netdev);
    int err = 0;

    - if (switchdev_trans_ph_prepare(trans))
    + if (switchdev_trans_ph_prepare(trans) && pre_set) {
    + if (flags & ~(BR_LEARNING | BR_FLOOD))
    + return -EOPNOTSUPP;
    return 0;
    + }

    /* Learning is enabled per switch */
    err = ethsw_set_learning(port_priv->ethsw_data, flags & BR_LEARNING);
    @@ -691,6 +694,7 @@ static int swdev_port_attr_set(struct net_device *netdev,
    const struct switchdev_attr *attr,
    struct switchdev_trans *trans)
    {
    + bool pre_set = false;
    int err = 0;

    switch (attr->id) {
    @@ -698,9 +702,11 @@ static int swdev_port_attr_set(struct net_device *netdev,
    err = port_attr_stp_state_set(netdev, trans,
    attr->u.stp_state);
    break;
    + case SWITCHDEV_ATTR_ID_PORT_PRE_BRIDGE_FLAGS:
    + pre_set = true; /* fall through */
    case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS:
    err = port_attr_br_flags_set(netdev, trans,
    - attr->u.brport_flags);
    + attr->u.brport_flags, pre_set);
    break;
    case SWITCHDEV_ATTR_ID_BRIDGE_VLAN_FILTERING:
    /* VLANs are supported by default */
    --
    2.17.1
    \
     
     \ /
      Last update: 2019-02-13 23:10    [W:2.194 / U:0.788 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site