diff mbox series

[net-next,v2,10/11] bridge: switchdev: cfm: switchdev interface implementation

Message ID 20201001103019.1342470-11-henrik.bjoernlund@microchip.com
State New
Headers show
Series net: bridge: cfm: Add support for Connectivity Fault Management(CFM) | expand

Commit Message

Henrik Bjoernlund Oct. 1, 2020, 10:30 a.m. UTC
This is the definition of the CFM switchdev interface.

The interface consist of these objects:
    SWITCHDEV_OBJ_ID_MEP_CFM,
    SWITCHDEV_OBJ_ID_MEP_CONFIG_CFM,
    SWITCHDEV_OBJ_ID_CC_CONFIG_CFM,
    SWITCHDEV_OBJ_ID_CC_PEER_MEP_CFM,
    SWITCHDEV_OBJ_ID_CC_CCM_TX_CFM,
    SWITCHDEV_OBJ_ID_MEP_STATUS_CFM,
    SWITCHDEV_OBJ_ID_PEER_MEP_STATUS_CFM

MEP instance add/del
    switchdev_port_obj_add(SWITCHDEV_OBJ_ID_MEP_CFM)
    switchdev_port_obj_del(SWITCHDEV_OBJ_ID_MEP_CFM)

MEP cofigure
    switchdev_port_obj_add(SWITCHDEV_OBJ_ID_MEP_CONFIG_CFM)

MEP CC cofigure
    switchdev_port_obj_add(SWITCHDEV_OBJ_ID_CC_CONFIG_CFM)

Peer MEP add/del
    switchdev_port_obj_add(SWITCHDEV_OBJ_ID_CC_PEER_MEP_CFM)
    switchdev_port_obj_del(SWITCHDEV_OBJ_ID_CC_PEER_MEP_CFM)

Start/stop CCM transmission
    switchdev_port_obj_add(SWITCHDEV_OBJ_ID_CC_CCM_TX_CFM)

Get MEP status
	switchdev_port_obj_get(SWITCHDEV_OBJ_ID_MEP_STATUS_CFM)

Get Peer MEP status
	switchdev_port_obj_get(SWITCHDEV_OBJ_ID_PEER_MEP_STATUS_CFM)

Reviewed-by: Horatiu Vultur  <horatiu.vultur@microchip.com>
Signed-off-by: Henrik Bjoernlund  <henrik.bjoernlund@microchip.com>
---
 include/linux/if_bridge.h |  13 +++++
 include/net/switchdev.h   | 115 ++++++++++++++++++++++++++++++++++++++
 net/switchdev/switchdev.c |  54 ++++++++++++++++++
 3 files changed, 182 insertions(+)

Comments

Jiri Pirko Oct. 1, 2020, 12:49 p.m. UTC | #1
Thu, Oct 01, 2020 at 12:30:18PM CEST, henrik.bjoernlund@microchip.com wrote:
>This is the definition of the CFM switchdev interface.
>
>The interface consist of these objects:
>    SWITCHDEV_OBJ_ID_MEP_CFM,
>    SWITCHDEV_OBJ_ID_MEP_CONFIG_CFM,
>    SWITCHDEV_OBJ_ID_CC_CONFIG_CFM,
>    SWITCHDEV_OBJ_ID_CC_PEER_MEP_CFM,
>    SWITCHDEV_OBJ_ID_CC_CCM_TX_CFM,
>    SWITCHDEV_OBJ_ID_MEP_STATUS_CFM,
>    SWITCHDEV_OBJ_ID_PEER_MEP_STATUS_CFM
>
>MEP instance add/del
>    switchdev_port_obj_add(SWITCHDEV_OBJ_ID_MEP_CFM)
>    switchdev_port_obj_del(SWITCHDEV_OBJ_ID_MEP_CFM)
>
>MEP cofigure
>    switchdev_port_obj_add(SWITCHDEV_OBJ_ID_MEP_CONFIG_CFM)
>
>MEP CC cofigure
>    switchdev_port_obj_add(SWITCHDEV_OBJ_ID_CC_CONFIG_CFM)
>
>Peer MEP add/del
>    switchdev_port_obj_add(SWITCHDEV_OBJ_ID_CC_PEER_MEP_CFM)
>    switchdev_port_obj_del(SWITCHDEV_OBJ_ID_CC_PEER_MEP_CFM)
>
>Start/stop CCM transmission
>    switchdev_port_obj_add(SWITCHDEV_OBJ_ID_CC_CCM_TX_CFM)
>
>Get MEP status
>	switchdev_port_obj_get(SWITCHDEV_OBJ_ID_MEP_STATUS_CFM)
>
>Get Peer MEP status
>	switchdev_port_obj_get(SWITCHDEV_OBJ_ID_PEER_MEP_STATUS_CFM)
>
>Reviewed-by: Horatiu Vultur  <horatiu.vultur@microchip.com>
>Signed-off-by: Henrik Bjoernlund  <henrik.bjoernlund@microchip.com>

You have to submit the driver parts as a part of this patchset.
Otherwise it is no good.

Thanks!
kernel test robot Oct. 1, 2020, 3:20 p.m. UTC | #2
Hi Henrik,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on net-next/master]

url:    https://github.com/0day-ci/linux/commits/Henrik-Bjoernlund/net-bridge-cfm-Add-support-for-Connectivity-Fault-Management-CFM/20201001-184031
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git f2e834694b0d92187d889172da842e27829df371
config: arm-bcm2835_defconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/11484cf00dba95e52678e269d11425358dcde310
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Henrik-Bjoernlund/net-bridge-cfm-Add-support-for-Connectivity-Fault-Management-CFM/20201001-184031
        git checkout 11484cf00dba95e52678e269d11425358dcde310
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arm 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   arm-linux-gnueabi-ld: net/core/flow_dissector.o: in function `switchdev_port_obj_get':
>> flow_dissector.c:(.text+0x838): multiple definition of `switchdev_port_obj_get'; drivers/net/usb/lan78xx.o:lan78xx.c:(.text+0x68b4): first defined here
   arm-linux-gnueabi-ld: net/core/dev.o: in function `switchdev_port_obj_get':
   dev.c:(.text+0x7760): multiple definition of `switchdev_port_obj_get'; drivers/net/usb/lan78xx.o:lan78xx.c:(.text+0x68b4): first defined here
   arm-linux-gnueabi-ld: net/core/dev_ioctl.o: in function `switchdev_port_obj_get':
   dev_ioctl.c:(.text+0x3f0): multiple definition of `switchdev_port_obj_get'; drivers/net/usb/lan78xx.o:lan78xx.c:(.text+0x68b4): first defined here
   arm-linux-gnueabi-ld: net/ethernet/eth.o: in function `switchdev_port_obj_get':
   eth.c:(.text+0x838): multiple definition of `switchdev_port_obj_get'; drivers/net/usb/lan78xx.o:lan78xx.c:(.text+0x68b4): first defined here
   arm-linux-gnueabi-ld: net/ethtool/tunnels.o: in function `switchdev_port_obj_get':
   tunnels.c:(.text+0x400): multiple definition of `switchdev_port_obj_get'; drivers/net/usb/lan78xx.o:lan78xx.c:(.text+0x68b4): first defined here
   arm-linux-gnueabi-ld: net/ipv4/ip_tunnel_core.o: in function `switchdev_port_obj_get':
   ip_tunnel_core.c:(.text+0xd6c): multiple definition of `switchdev_port_obj_get'; drivers/net/usb/lan78xx.o:lan78xx.c:(.text+0x68b4): first defined here
   arm-linux-gnueabi-ld: net/ipv4/ipconfig.o: in function `switchdev_port_obj_get':
   ipconfig.c:(.text+0x1d8): multiple definition of `switchdev_port_obj_get'; drivers/net/usb/lan78xx.o:lan78xx.c:(.text+0x68b4): first defined here

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
kernel test robot Oct. 1, 2020, 3:38 p.m. UTC | #3
Hi Henrik,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on net-next/master]

url:    https://github.com/0day-ci/linux/commits/Henrik-Bjoernlund/net-bridge-cfm-Add-support-for-Connectivity-Fault-Management-CFM/20201001-184031
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git f2e834694b0d92187d889172da842e27829df371
config: i386-randconfig-a004-20200930 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce (this is a W=1 build):
        # https://github.com/0day-ci/linux/commit/11484cf00dba95e52678e269d11425358dcde310
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Henrik-Bjoernlund/net-bridge-cfm-Add-support-for-Connectivity-Fault-Management-CFM/20201001-184031
        git checkout 11484cf00dba95e52678e269d11425358dcde310
        # save the attached .config to linux build tree
        make W=1 ARCH=i386 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   ld: net/core/flow_dissector.o: in function `switchdev_port_obj_get':
>> include/net/switchdev.h:441: multiple definition of `switchdev_port_obj_get'; drivers/net/usb/lan78xx.o:include/net/switchdev.h:441: first defined here
   ld: net/core/dev.o: in function `switchdev_port_obj_get':
>> include/net/switchdev.h:441: multiple definition of `switchdev_port_obj_get'; drivers/net/usb/lan78xx.o:include/net/switchdev.h:441: first defined here
   ld: net/core/dev_ioctl.o: in function `switchdev_port_obj_get':
>> include/net/switchdev.h:441: multiple definition of `switchdev_port_obj_get'; drivers/net/usb/lan78xx.o:include/net/switchdev.h:441: first defined here
   ld: net/ethernet/eth.o: in function `switchdev_port_obj_get':
>> include/net/switchdev.h:441: multiple definition of `switchdev_port_obj_get'; drivers/net/usb/lan78xx.o:include/net/switchdev.h:441: first defined here
   ld: net/ethtool/tunnels.o: in function `switchdev_port_obj_get':
>> include/net/switchdev.h:441: multiple definition of `switchdev_port_obj_get'; drivers/net/usb/lan78xx.o:include/net/switchdev.h:441: first defined here
   ld: net/ipv4/ip_tunnel_core.o: in function `switchdev_port_obj_get':
>> include/net/switchdev.h:441: multiple definition of `switchdev_port_obj_get'; drivers/net/usb/lan78xx.o:include/net/switchdev.h:441: first defined here
   ld: net/ipv4/ipconfig.o: in function `switchdev_port_obj_get':
>> include/net/switchdev.h:441: multiple definition of `switchdev_port_obj_get'; drivers/net/usb/lan78xx.o:include/net/switchdev.h:441: first defined here

vim +441 include/net/switchdev.h

   435	
   436	int switchdev_port_obj_get(struct net_device *dev,
   437				   const struct switchdev_obj *obj,
   438				   struct netlink_ext_ack *extack)
   439	{
   440		return -EOPNOTSUPP;
 > 441	}
   442	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
allan.nielsen@microchip.com Oct. 5, 2020, 1:07 p.m. UTC | #4
Hi Jiri

On 01.10.2020 14:49, Jiri Pirko wrote:
>EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
>
>Thu, Oct 01, 2020 at 12:30:18PM CEST, henrik.bjoernlund@microchip.com wrote:
>>This is the definition of the CFM switchdev interface.
>>
>>The interface consist of these objects:
>>    SWITCHDEV_OBJ_ID_MEP_CFM,
>>    SWITCHDEV_OBJ_ID_MEP_CONFIG_CFM,
>>    SWITCHDEV_OBJ_ID_CC_CONFIG_CFM,
>>    SWITCHDEV_OBJ_ID_CC_PEER_MEP_CFM,
>>    SWITCHDEV_OBJ_ID_CC_CCM_TX_CFM,
>>    SWITCHDEV_OBJ_ID_MEP_STATUS_CFM,
>>    SWITCHDEV_OBJ_ID_PEER_MEP_STATUS_CFM
>>
>>MEP instance add/del
>>    switchdev_port_obj_add(SWITCHDEV_OBJ_ID_MEP_CFM)
>>    switchdev_port_obj_del(SWITCHDEV_OBJ_ID_MEP_CFM)
>>
>>MEP cofigure
>>    switchdev_port_obj_add(SWITCHDEV_OBJ_ID_MEP_CONFIG_CFM)
>>
>>MEP CC cofigure
>>    switchdev_port_obj_add(SWITCHDEV_OBJ_ID_CC_CONFIG_CFM)
>>
>>Peer MEP add/del
>>    switchdev_port_obj_add(SWITCHDEV_OBJ_ID_CC_PEER_MEP_CFM)
>>    switchdev_port_obj_del(SWITCHDEV_OBJ_ID_CC_PEER_MEP_CFM)
>>
>>Start/stop CCM transmission
>>    switchdev_port_obj_add(SWITCHDEV_OBJ_ID_CC_CCM_TX_CFM)
>>
>>Get MEP status
>>       switchdev_port_obj_get(SWITCHDEV_OBJ_ID_MEP_STATUS_CFM)
>>
>>Get Peer MEP status
>>       switchdev_port_obj_get(SWITCHDEV_OBJ_ID_PEER_MEP_STATUS_CFM)
>>
>>Reviewed-by: Horatiu Vultur  <horatiu.vultur@microchip.com>
>>Signed-off-by: Henrik Bjoernlund  <henrik.bjoernlund@microchip.com>
>
>You have to submit the driver parts as a part of this patchset.
>Otherwise it is no good.
Fair enough.

With MRP we did it like this, and after Nik asked for details on what is
being offload, we thought that adding this would help.

The reason why we did not include the implementation of this interface
is that it is for a new SoC which is still not fully available which is
why we have not done the basic SwitchDev driver for it yet. But the
basic functionality clearly needs to come first.

Our preference is to continue fixing the comments we got on the pure SW
implementation and then get back to the SwitchDev offloading.

This will mean dropping the last 2 patches in the serie.

Does that work for you Jiri, and Nik?

/Allan
Jiri Pirko Oct. 6, 2020, 9:02 a.m. UTC | #5
Mon, Oct 05, 2020 at 03:07:12PM CEST, allan.nielsen@microchip.com wrote:
>Hi Jiri
>
>On 01.10.2020 14:49, Jiri Pirko wrote:
>> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
>> 
>> Thu, Oct 01, 2020 at 12:30:18PM CEST, henrik.bjoernlund@microchip.com wrote:
>> > This is the definition of the CFM switchdev interface.
>> > 
>> > The interface consist of these objects:
>> >    SWITCHDEV_OBJ_ID_MEP_CFM,
>> >    SWITCHDEV_OBJ_ID_MEP_CONFIG_CFM,
>> >    SWITCHDEV_OBJ_ID_CC_CONFIG_CFM,
>> >    SWITCHDEV_OBJ_ID_CC_PEER_MEP_CFM,
>> >    SWITCHDEV_OBJ_ID_CC_CCM_TX_CFM,
>> >    SWITCHDEV_OBJ_ID_MEP_STATUS_CFM,
>> >    SWITCHDEV_OBJ_ID_PEER_MEP_STATUS_CFM
>> > 
>> > MEP instance add/del
>> >    switchdev_port_obj_add(SWITCHDEV_OBJ_ID_MEP_CFM)
>> >    switchdev_port_obj_del(SWITCHDEV_OBJ_ID_MEP_CFM)
>> > 
>> > MEP cofigure
>> >    switchdev_port_obj_add(SWITCHDEV_OBJ_ID_MEP_CONFIG_CFM)
>> > 
>> > MEP CC cofigure
>> >    switchdev_port_obj_add(SWITCHDEV_OBJ_ID_CC_CONFIG_CFM)
>> > 
>> > Peer MEP add/del
>> >    switchdev_port_obj_add(SWITCHDEV_OBJ_ID_CC_PEER_MEP_CFM)
>> >    switchdev_port_obj_del(SWITCHDEV_OBJ_ID_CC_PEER_MEP_CFM)
>> > 
>> > Start/stop CCM transmission
>> >    switchdev_port_obj_add(SWITCHDEV_OBJ_ID_CC_CCM_TX_CFM)
>> > 
>> > Get MEP status
>> >       switchdev_port_obj_get(SWITCHDEV_OBJ_ID_MEP_STATUS_CFM)
>> > 
>> > Get Peer MEP status
>> >       switchdev_port_obj_get(SWITCHDEV_OBJ_ID_PEER_MEP_STATUS_CFM)
>> > 
>> > Reviewed-by: Horatiu Vultur  <horatiu.vultur@microchip.com>
>> > Signed-off-by: Henrik Bjoernlund  <henrik.bjoernlund@microchip.com>
>> 
>> You have to submit the driver parts as a part of this patchset.
>> Otherwise it is no good.
>Fair enough.
>
>With MRP we did it like this, and after Nik asked for details on what is
>being offload, we thought that adding this would help.
>
>The reason why we did not include the implementation of this interface
>is that it is for a new SoC which is still not fully available which is
>why we have not done the basic SwitchDev driver for it yet. But the
>basic functionality clearly needs to come first.
>
>Our preference is to continue fixing the comments we got on the pure SW
>implementation and then get back to the SwitchDev offloading.
>
>This will mean dropping the last 2 patches in the serie.
>
>Does that work for you Jiri, and Nik?

Sure.

>
>/Allan
>
Nikolay Aleksandrov Oct. 6, 2020, 10:50 a.m. UTC | #6
On Mon, 2020-10-05 at 15:07 +0200, Allan W. Nielsen wrote:
> Hi Jiri

> 

> On 01.10.2020 14:49, Jiri Pirko wrote:

> > EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

> > 

> > Thu, Oct 01, 2020 at 12:30:18PM CEST, henrik.bjoernlund@microchip.com wrote:

> > > This is the definition of the CFM switchdev interface.

> > > 

> > > The interface consist of these objects:

> > >    SWITCHDEV_OBJ_ID_MEP_CFM,

> > >    SWITCHDEV_OBJ_ID_MEP_CONFIG_CFM,

> > >    SWITCHDEV_OBJ_ID_CC_CONFIG_CFM,

> > >    SWITCHDEV_OBJ_ID_CC_PEER_MEP_CFM,

> > >    SWITCHDEV_OBJ_ID_CC_CCM_TX_CFM,

> > >    SWITCHDEV_OBJ_ID_MEP_STATUS_CFM,

> > >    SWITCHDEV_OBJ_ID_PEER_MEP_STATUS_CFM

> > > 

> > > MEP instance add/del

> > >    switchdev_port_obj_add(SWITCHDEV_OBJ_ID_MEP_CFM)

> > >    switchdev_port_obj_del(SWITCHDEV_OBJ_ID_MEP_CFM)

> > > 

> > > MEP cofigure

> > >    switchdev_port_obj_add(SWITCHDEV_OBJ_ID_MEP_CONFIG_CFM)

> > > 

> > > MEP CC cofigure

> > >    switchdev_port_obj_add(SWITCHDEV_OBJ_ID_CC_CONFIG_CFM)

> > > 

> > > Peer MEP add/del

> > >    switchdev_port_obj_add(SWITCHDEV_OBJ_ID_CC_PEER_MEP_CFM)

> > >    switchdev_port_obj_del(SWITCHDEV_OBJ_ID_CC_PEER_MEP_CFM)

> > > 

> > > Start/stop CCM transmission

> > >    switchdev_port_obj_add(SWITCHDEV_OBJ_ID_CC_CCM_TX_CFM)

> > > 

> > > Get MEP status

> > >       switchdev_port_obj_get(SWITCHDEV_OBJ_ID_MEP_STATUS_CFM)

> > > 

> > > Get Peer MEP status

> > >       switchdev_port_obj_get(SWITCHDEV_OBJ_ID_PEER_MEP_STATUS_CFM)

> > > 

> > > Reviewed-by: Horatiu Vultur  <horatiu.vultur@microchip.com>

> > > Signed-off-by: Henrik Bjoernlund  <henrik.bjoernlund@microchip.com>

> > 

> > You have to submit the driver parts as a part of this patchset.

> > Otherwise it is no good.

> Fair enough.

> 

> With MRP we did it like this, and after Nik asked for details on what is

> being offload, we thought that adding this would help.

> 

> The reason why we did not include the implementation of this interface

> is that it is for a new SoC which is still not fully available which is

> why we have not done the basic SwitchDev driver for it yet. But the

> basic functionality clearly needs to come first.

> 

> Our preference is to continue fixing the comments we got on the pure SW

> implementation and then get back to the SwitchDev offloading.

> 

> This will mean dropping the last 2 patches in the serie.

> 

> Does that work for you Jiri, and Nik?

> 

> /Allan

> 


Sounds good to me. Sorry I was unresponsive last week, but I was sick and
couldn't get to netdev@. I'll review the set today.

Cheers,
 Nik
allan.nielsen@microchip.com Oct. 6, 2020, 10:53 a.m. UTC | #7
On 06.10.2020 10:50, Nikolay Aleksandrov wrote:
>EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
>
>On Mon, 2020-10-05 at 15:07 +0200, Allan W. Nielsen wrote:
>> Hi Jiri
>>
>> On 01.10.2020 14:49, Jiri Pirko wrote:
>> > EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
>> >
>> > Thu, Oct 01, 2020 at 12:30:18PM CEST, henrik.bjoernlund@microchip.com wrote:
>> > > This is the definition of the CFM switchdev interface.
>> > >
>> > > The interface consist of these objects:
>> > >    SWITCHDEV_OBJ_ID_MEP_CFM,
>> > >    SWITCHDEV_OBJ_ID_MEP_CONFIG_CFM,
>> > >    SWITCHDEV_OBJ_ID_CC_CONFIG_CFM,
>> > >    SWITCHDEV_OBJ_ID_CC_PEER_MEP_CFM,
>> > >    SWITCHDEV_OBJ_ID_CC_CCM_TX_CFM,
>> > >    SWITCHDEV_OBJ_ID_MEP_STATUS_CFM,
>> > >    SWITCHDEV_OBJ_ID_PEER_MEP_STATUS_CFM
>> > >
>> > > MEP instance add/del
>> > >    switchdev_port_obj_add(SWITCHDEV_OBJ_ID_MEP_CFM)
>> > >    switchdev_port_obj_del(SWITCHDEV_OBJ_ID_MEP_CFM)
>> > >
>> > > MEP cofigure
>> > >    switchdev_port_obj_add(SWITCHDEV_OBJ_ID_MEP_CONFIG_CFM)
>> > >
>> > > MEP CC cofigure
>> > >    switchdev_port_obj_add(SWITCHDEV_OBJ_ID_CC_CONFIG_CFM)
>> > >
>> > > Peer MEP add/del
>> > >    switchdev_port_obj_add(SWITCHDEV_OBJ_ID_CC_PEER_MEP_CFM)
>> > >    switchdev_port_obj_del(SWITCHDEV_OBJ_ID_CC_PEER_MEP_CFM)
>> > >
>> > > Start/stop CCM transmission
>> > >    switchdev_port_obj_add(SWITCHDEV_OBJ_ID_CC_CCM_TX_CFM)
>> > >
>> > > Get MEP status
>> > >       switchdev_port_obj_get(SWITCHDEV_OBJ_ID_MEP_STATUS_CFM)
>> > >
>> > > Get Peer MEP status
>> > >       switchdev_port_obj_get(SWITCHDEV_OBJ_ID_PEER_MEP_STATUS_CFM)
>> > >
>> > > Reviewed-by: Horatiu Vultur  <horatiu.vultur@microchip.com>
>> > > Signed-off-by: Henrik Bjoernlund  <henrik.bjoernlund@microchip.com>
>> >
>> > You have to submit the driver parts as a part of this patchset.
>> > Otherwise it is no good.
>> Fair enough.
>>
>> With MRP we did it like this, and after Nik asked for details on what is
>> being offload, we thought that adding this would help.
>>
>> The reason why we did not include the implementation of this interface
>> is that it is for a new SoC which is still not fully available which is
>> why we have not done the basic SwitchDev driver for it yet. But the
>> basic functionality clearly needs to come first.
>>
>> Our preference is to continue fixing the comments we got on the pure SW
>> implementation and then get back to the SwitchDev offloading.
>>
>> This will mean dropping the last 2 patches in the serie.
>>
>> Does that work for you Jiri, and Nik?
>>
>> /Allan
>>
>
>Sounds good to me. Sorry I was unresponsive last week, but I was sick and
>couldn't get to netdev@. I'll review the set today.

Perfect. Thanks for the support.

/Allan
diff mbox series

Patch

diff --git a/include/linux/if_bridge.h b/include/linux/if_bridge.h
index 556caed00258..5476880319ae 100644
--- a/include/linux/if_bridge.h
+++ b/include/linux/if_bridge.h
@@ -155,4 +155,17 @@  br_port_flag_is_set(const struct net_device *dev, unsigned long flag)
 }
 #endif
 
+#if IS_ENABLED(CONFIG_BRIDGE_CFM)
+#define BR_CFM_EVENT_CCM_DEFECT  (1<<0)
+
+struct br_cfm_notif_info {
+	u32 instance;
+	u32 peer_mep;
+	u32 events;
+};
+
+/* Function to be called from CFM switchdev driver to notify change in status */
+void br_cfm_notification(struct net_device *dev, const struct br_cfm_notif_info *const notif_info);
+#endif
+
 #endif
diff --git a/include/net/switchdev.h b/include/net/switchdev.h
index 53e8b4994296..cd5194cd54d0 100644
--- a/include/net/switchdev.h
+++ b/include/net/switchdev.h
@@ -11,6 +11,9 @@ 
 #include <linux/notifier.h>
 #include <linux/list.h>
 #include <net/ip_fib.h>
+#include <uapi/linux/cfm_bridge.h>
+#include "../net/bridge/br_private.h"
+#include "../net/bridge/br_private_cfm.h"
 
 #define SWITCHDEV_F_NO_RECURSE		BIT(0)
 #define SWITCHDEV_F_SKIP_EOPNOTSUPP	BIT(1)
@@ -81,6 +84,15 @@  enum switchdev_obj_id {
 	SWITCHDEV_OBJ_ID_IN_STATE_MRP,
 
 #endif
+#if IS_ENABLED(CONFIG_BRIDGE_CFM)
+	SWITCHDEV_OBJ_ID_MEP_CFM,
+	SWITCHDEV_OBJ_ID_MEP_CONFIG_CFM,
+	SWITCHDEV_OBJ_ID_CC_CONFIG_CFM,
+	SWITCHDEV_OBJ_ID_CC_PEER_MEP_CFM,
+	SWITCHDEV_OBJ_ID_CC_CCM_TX_CFM,
+	SWITCHDEV_OBJ_ID_MEP_STATUS_CFM,
+	SWITCHDEV_OBJ_ID_PEER_MEP_STATUS_CFM
+#endif
 };
 
 struct switchdev_obj {
@@ -112,6 +124,97 @@  struct switchdev_obj_port_mdb {
 #define SWITCHDEV_OBJ_PORT_MDB(OBJ) \
 	container_of((OBJ), struct switchdev_obj_port_mdb, obj)
 
+#if IS_ENABLED(CONFIG_BRIDGE_CFM)
+/* SWITCHDEV_OBJ_ID_MEP_CFM */
+struct switchdev_obj_cfm_mep {
+	struct switchdev_obj obj;
+	u32 instance;
+	enum br_cfm_domain domain; /* Domain for this MEP */
+	enum br_cfm_mep_direction direction; /* Up or Down MEP direction */
+	struct net_device *port; /* Residence port */
+};
+
+#define SWITCHDEV_OBJ_CFM_MEP(OBJ) \
+	container_of((OBJ), struct switchdev_obj_cfm_mep, obj)
+
+/* SWITCHDEV_OBJ_ID_MEP_CONFIG_CFM */
+struct switchdev_obj_cfm_mep_config_set {
+	struct switchdev_obj obj;
+	u32 instance;
+	u32 mdlevel;
+	u32 mepid;
+	struct mac_addr unicast_mac;
+};
+
+#define SWITCHDEV_OBJ_CFM_MEP_CONFIG_SET(OBJ) \
+	container_of((OBJ), struct switchdev_obj_cfm_mep_config_set, obj)
+
+#define SWITCHDEV_CFM_MAID_LENGTH	48
+
+/* SWITCHDEV_OBJ_ID_CC_CONFIG_CFM */
+struct switchdev_obj_cfm_cc_config_set {
+	struct switchdev_obj obj;
+	u32 instance;
+	struct br_cfm_maid maid;
+	enum br_cfm_ccm_interval interval;
+	bool enable;
+};
+
+#define SWITCHDEV_OBJ_CFM_CC_CONFIG_SET(OBJ) \
+	container_of((OBJ), struct switchdev_obj_cfm_cc_config_set, obj)
+
+/* SWITCHDEV_OBJ_ID_CC_PEER_MEP_CFM */
+struct switchdev_obj_cfm_cc_peer_mep {
+	struct switchdev_obj obj;
+	u32 instance;
+	u32 peer_mep_id;
+};
+
+#define SWITCHDEV_OBJ_CFM_CC_PEER_MEP(OBJ) \
+	container_of((OBJ), struct switchdev_obj_cfm_cc_peer_mep, obj)
+
+/* SWITCHDEV_OBJ_ID_CC_CCM_TX_CFM */
+struct switchdev_obj_cfm_cc_ccm_tx {
+	struct switchdev_obj obj;
+	u32 instance;
+	u32 period;
+	struct sk_buff *skb;
+	enum br_cfm_ccm_interval interval;
+};
+
+#define SWITCHDEV_OBJ_CFM_CC_CCM_TX(OBJ) \
+	container_of((OBJ), struct switchdev_obj_cfm_cc_ccm_tx, obj)
+
+/* SWITCHDEV_OBJ_ID_MEP_STATUS_CFM */
+struct switchdev_obj_cfm_mep_status_get {
+	struct switchdev_obj obj;
+	u32 instance;
+	bool clear;
+	bool opcode_unexp_seen;
+	bool version_unexp_seen;
+	bool rx_level_low_seen;
+};
+
+#define SWITCHDEV_OBJ_CFM_MEP_STATUS_get(OBJ) \
+	container_of((OBJ), struct switchdev_obj_cfm_mep_status_get, obj)
+
+/* SWITCHDEV_OBJ_ID_PEER_MEP_STATUS_CFM */
+struct switchdev_obj_cfm_cc_peer_status_get {
+	struct switchdev_obj obj;
+	u32 instance;
+	bool clear;
+	u8 port_tlv_value;
+	u8 if_tlv_value;
+	bool ccm_defect;
+	bool rdi;
+	bool seen;
+	bool tlv_seen;
+	bool seq_unexp_seen;
+};
+#define SWITCHDEV_OBJ_CFM_CC_PEER_STATUS_get(OBJ) \
+	container_of((OBJ), struct switchdev_obj_cfm_cc_peer_status_get, obj)
+
+#endif
 
 #if IS_ENABLED(CONFIG_BRIDGE_MRP)
 /* SWITCHDEV_OBJ_ID_MRP */
@@ -208,6 +311,7 @@  enum switchdev_notifier_type {
 	SWITCHDEV_PORT_OBJ_ADD, /* Blocking. */
 	SWITCHDEV_PORT_OBJ_DEL, /* Blocking. */
 	SWITCHDEV_PORT_ATTR_SET, /* May be blocking . */
+	SWITCHDEV_PORT_OBJ_GET, /* Blocking */
 
 	SWITCHDEV_VXLAN_FDB_ADD_TO_BRIDGE,
 	SWITCHDEV_VXLAN_FDB_DEL_TO_BRIDGE,
@@ -265,6 +369,9 @@  int switchdev_port_obj_add(struct net_device *dev,
 			   struct netlink_ext_ack *extack);
 int switchdev_port_obj_del(struct net_device *dev,
 			   const struct switchdev_obj *obj);
+int switchdev_port_obj_get(struct net_device *dev,
+			   const struct switchdev_obj *obj,
+			   struct netlink_ext_ack *extack);
 
 int register_switchdev_notifier(struct notifier_block *nb);
 int unregister_switchdev_notifier(struct notifier_block *nb);
@@ -326,6 +433,14 @@  static inline int switchdev_port_obj_del(struct net_device *dev,
 	return -EOPNOTSUPP;
 }
 
+int switchdev_port_obj_get(struct net_device *dev,
+			   const struct switchdev_obj *obj,
+			   struct netlink_ext_ack *extack)
+{
+	return -EOPNOTSUPP;
+}
+
+
 static inline int register_switchdev_notifier(struct notifier_block *nb)
 {
 	return 0;
diff --git a/net/switchdev/switchdev.c b/net/switchdev/switchdev.c
index 865f3e037425..fefb05b885e0 100644
--- a/net/switchdev/switchdev.c
+++ b/net/switchdev/switchdev.c
@@ -372,6 +372,60 @@  int switchdev_port_obj_del(struct net_device *dev,
 }
 EXPORT_SYMBOL_GPL(switchdev_port_obj_del);
 
+static int switchdev_port_obj_get_now(struct net_device *dev,
+				      const struct switchdev_obj *obj,
+				      struct netlink_ext_ack *extack)
+{
+	struct switchdev_trans trans;
+	int err;
+
+	/* Phase I: prepare for obj add. Driver/device should fail
+	 * here if there are going to be issues in the commit phase,
+	 * such as lack of resources or support.  The driver/device
+	 * should reserve resources needed for the commit phase here,
+	 * but should not commit the obj.
+	 */
+
+	trans.ph_prepare = true;
+	err = switchdev_port_obj_notify(SWITCHDEV_PORT_OBJ_GET,
+					dev, obj, &trans, extack);
+	if (err)
+		return err;
+
+	/* Phase II: commit obj add.  This cannot fail as a fault
+	 * of driver/device.  If it does, it's a bug in the driver/device
+	 * because the driver said everythings was OK in phase I.
+	 */
+
+	trans.ph_prepare = false;
+	err = switchdev_port_obj_notify(SWITCHDEV_PORT_OBJ_GET,
+					dev, obj, &trans, extack);
+	WARN(err, "%s: Commit of object (id=%d) failed.\n", dev->name, obj->id);
+
+	return err;
+}
+
+/**
+ *	switchdev_port_obj_get - Get information from a port object
+ *	It is expected that the driver fill in information in the
+ *	obj structure.
+ *
+ *	@dev: port device
+ *	@obj: object to get information from
+ *	@extack: netlink extended ack
+ *
+ *	Use a 2-phase prepare-commit transaction model to ensure
+ *	system is not left in a partially updated state due to
+ *	failure from driver/device.
+ */
+int switchdev_port_obj_get(struct net_device *dev,
+			   const struct switchdev_obj *obj,
+			   struct netlink_ext_ack *extack)
+{
+	return switchdev_port_obj_get_now(dev, obj, extack);
+}
+EXPORT_SYMBOL_GPL(switchdev_port_obj_get);
+
 static ATOMIC_NOTIFIER_HEAD(switchdev_notif_chain);
 static BLOCKING_NOTIFIER_HEAD(switchdev_blocking_notif_chain);