Re: [PATCH net-next v4 07/10] bridge: cfm: Netlink SET configuration Interface.

2020-10-12 Thread henrik.bjoernl...@microchip.com
The 10/09/2020 21:53, Nikolay Aleksandrov wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the 
> content is safe
> 
> On Fri, 2020-10-09 at 14:35 +, Henrik Bjoernlund wrote:
> > This is the implementation of CFM netlink configuration
> > set information interface.
> >
> > Add new nested netlink attributes. These attributes are used by the
> > user space to create/delete/configure CFM instances.
> >
> > SETLINK:
> > IFLA_BRIDGE_CFM:
> > Indicate that the following attributes are CFM.
> >
> > IFLA_BRIDGE_CFM_MEP_CREATE:
> > This indicate that a MEP instance must be created.
> > IFLA_BRIDGE_CFM_MEP_DELETE:
> > This indicate that a MEP instance must be deleted.
> > IFLA_BRIDGE_CFM_MEP_CONFIG:
> > This indicate that a MEP instance must be configured.
> > IFLA_BRIDGE_CFM_CC_CONFIG:
> > This indicate that a MEP instance Continuity Check (CC)
> > functionality must be configured.
> > IFLA_BRIDGE_CFM_CC_PEER_MEP_ADD:
> > This indicate that a CC Peer MEP must be added.
> > IFLA_BRIDGE_CFM_CC_PEER_MEP_REMOVE:
> > This indicate that a CC Peer MEP must be removed.
> > IFLA_BRIDGE_CFM_CC_CCM_TX:
> > This indicate that the CC transmitted CCM PDU must be configured.
> > IFLA_BRIDGE_CFM_CC_RDI:
> > This indicate that the CC transmitted CCM PDU RDI must be
> > configured.
> >
> > CFM nested attribute has the following attributes in next level.
> >
> > SETLINK RTEXT_FILTER_CFM_CONFIG:
> > IFLA_BRIDGE_CFM_MEP_CREATE_INSTANCE:
> > The created MEP instance number.
> > The type is u32.
> > IFLA_BRIDGE_CFM_MEP_CREATE_DOMAIN:
> > The created MEP domain.
> > The type is u32 (br_cfm_domain).
> > It must be BR_CFM_PORT.
> > This means that CFM frames are transmitted and received
> > directly on the port - untagged. Not in a VLAN.
> > IFLA_BRIDGE_CFM_MEP_CREATE_DIRECTION:
> > The created MEP direction.
> > The type is u32 (br_cfm_mep_direction).
> > It must be BR_CFM_MEP_DIRECTION_DOWN.
> > This means that CFM frames are transmitted and received on
> > the port. Not in the bridge.
> > IFLA_BRIDGE_CFM_MEP_CREATE_IFINDEX:
> > The created MEP residence port ifindex.
> > The type is u32 (ifindex).
> >
> > IFLA_BRIDGE_CFM_MEP_DELETE_INSTANCE:
> > The deleted MEP instance number.
> > The type is u32.
> >
> > IFLA_BRIDGE_CFM_MEP_CONFIG_INSTANCE:
> > The configured MEP instance number.
> > The type is u32.
> > IFLA_BRIDGE_CFM_MEP_CONFIG_UNICAST_MAC:
> > The configured MEP unicast MAC address.
> > The type is 6*u8 (array).
> > This is used as SMAC in all transmitted CFM frames.
> > IFLA_BRIDGE_CFM_MEP_CONFIG_MDLEVEL:
> > The configured MEP unicast MD level.
> > The type is u32.
> > It must be in the range 1-7.
> > No CFM frames are passing through this MEP on lower levels.
> > IFLA_BRIDGE_CFM_MEP_CONFIG_MEPID:
> > The configured MEP ID.
> > The type is u32.
> > It must be in the range 0-0x1FFF.
> > This MEP ID is inserted in any transmitted CCM frame.
> >
> > IFLA_BRIDGE_CFM_CC_CONFIG_INSTANCE:
> > The configured MEP instance number.
> > The type is u32.
> > IFLA_BRIDGE_CFM_CC_CONFIG_ENABLE:
> > The Continuity Check (CC) functionality is enabled or disabled.
> > The type is u32 (bool).
> > IFLA_BRIDGE_CFM_CC_CONFIG_EXP_INTERVAL:
> > The CC expected receive interval of CCM frames.
> > The type is u32 (br_cfm_ccm_interval).
> > This is also the transmission interval of CCM frames when enabled.
> > IFLA_BRIDGE_CFM_CC_CONFIG_EXP_MAID:
> > The CC expected receive MAID in CCM frames.
> > The type is CFM_MAID_LENGTH*u8.
> > This is MAID is also inserted in transmitted CCM frames.
> >
> > IFLA_BRIDGE_CFM_CC_PEER_MEP_INSTANCE:
> > The configured MEP instance number.
> > The type is u32.
> > IFLA_BRIDGE_CFM_CC_PEER_MEPID:
> > The CC Peer MEP ID added.
> > The type is u32.
> > When a Peer MEP ID is added and CC is enabled it is expected to
> > receive CCM frames from that Peer MEP.
> >
> > IFLA_BRIDGE_CFM_CC_RDI_INSTANCE:
> > The configured MEP instance number.
> > The type is u32.
> > IFLA_BRIDGE_CFM_CC_RDI_RDI:
> > The RDI that is inserted in transmitted CCM PDU.
> > The type is u32 (bool).
> >
> > IFLA_BRIDGE_CFM_CC_CCM_TX_INSTANCE:
> > The configured MEP instance number.
> > The type is u32.
> > IFLA_BRIDGE_CFM_CC_CCM_TX_DMAC:
> > The transmitted CCM frame destination MAC address.
> > The type is 6*u8 (array).
> > This is used as DMAC in all transmitted CFM frames.
> > 

Re: [PATCH net-next v4 07/10] bridge: cfm: Netlink SET configuration Interface.

2020-10-12 Thread Henrik Bjoernlund
Thanks for the review. Comments below.

The 10/09/2020 18:45, Jakub Kicinski wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the 
> content is safe
> 
> On Fri, 9 Oct 2020 14:35:27 + Henrik Bjoernlund wrote:
> > +static inline struct mac_addr nla_get_mac(const struct nlattr *nla)
> 
> static inlines are generally not needed in C sources and just hide
> unused code. Please drop the inline annotation.
> 
I removed this function
> > +{
> > + struct mac_addr mac;
> > +
> > + nla_memcpy(, nla, sizeof(mac.addr));
> > +
> > + return mac;
> > +}
> > +
> > +static inline struct br_cfm_maid nla_get_maid(const struct nlattr *nla)
> 
> ditto

I removed this function.

> 
> > +{
> > + struct br_cfm_maid maid;
> > +
> > + nla_memcpy(, nla, sizeof(maid.data));
> 
> returning a 48B struct from a helper is a little strange, but I guess
> it's not too bad when compiler inlines the thing?
> 
I removed this function. 

> > + return maid;
> > +}
> > +
> > +static const struct nla_policy
> > +br_cfm_policy[IFLA_BRIDGE_CFM_MAX + 1] = {
> > + [IFLA_BRIDGE_CFM_UNSPEC]= { .type = NLA_REJECT },
> 
> Not needed, REJECT is treated the same as 0 / uninit, right?
> 
Did not change anything here. I would like to keep this if it does no harm.

> > + [IFLA_BRIDGE_CFM_MEP_CREATE]= { .type = NLA_NESTED },
> 
> Consider using NLA_POLICY_NESTED() to link up the next layers.
> 
I change to use the NLA_POLICY_NESTED macro.

> > + [IFLA_BRIDGE_CFM_MEP_DELETE]= { .type = NLA_NESTED },
> > + [IFLA_BRIDGE_CFM_MEP_CONFIG]= { .type = NLA_NESTED },
> > + [IFLA_BRIDGE_CFM_CC_CONFIG] = { .type = NLA_NESTED },
> > + [IFLA_BRIDGE_CFM_CC_PEER_MEP_ADD]   = { .type = NLA_NESTED },
> > + [IFLA_BRIDGE_CFM_CC_PEER_MEP_REMOVE]= { .type = NLA_NESTED },
> > + [IFLA_BRIDGE_CFM_CC_RDI]= { .type = NLA_NESTED },
> > + [IFLA_BRIDGE_CFM_CC_CCM_TX] = { .type = NLA_NESTED },
> > +};

-- 
/Henrik


Re: [PATCH net-next v4 07/10] bridge: cfm: Netlink SET configuration Interface.

2020-10-09 Thread Jakub Kicinski
On Fri, 9 Oct 2020 14:35:27 + Henrik Bjoernlund wrote:
> +static inline struct mac_addr nla_get_mac(const struct nlattr *nla)

static inlines are generally not needed in C sources and just hide
unused code. Please drop the inline annotation.

> +{
> + struct mac_addr mac;
> +
> + nla_memcpy(, nla, sizeof(mac.addr));
> +
> + return mac;
> +}
> +
> +static inline struct br_cfm_maid nla_get_maid(const struct nlattr *nla)

ditto

> +{
> + struct br_cfm_maid maid;
> +
> + nla_memcpy(, nla, sizeof(maid.data));

returning a 48B struct from a helper is a little strange, but I guess
it's not too bad when compiler inlines the thing?

> + return maid;
> +}
> +
> +static const struct nla_policy
> +br_cfm_policy[IFLA_BRIDGE_CFM_MAX + 1] = {
> + [IFLA_BRIDGE_CFM_UNSPEC]= { .type = NLA_REJECT },

Not needed, REJECT is treated the same as 0 / uninit, right?

> + [IFLA_BRIDGE_CFM_MEP_CREATE]= { .type = NLA_NESTED },

Consider using NLA_POLICY_NESTED() to link up the next layers.

> + [IFLA_BRIDGE_CFM_MEP_DELETE]= { .type = NLA_NESTED },
> + [IFLA_BRIDGE_CFM_MEP_CONFIG]= { .type = NLA_NESTED },
> + [IFLA_BRIDGE_CFM_CC_CONFIG] = { .type = NLA_NESTED },
> + [IFLA_BRIDGE_CFM_CC_PEER_MEP_ADD]   = { .type = NLA_NESTED },
> + [IFLA_BRIDGE_CFM_CC_PEER_MEP_REMOVE]= { .type = NLA_NESTED },
> + [IFLA_BRIDGE_CFM_CC_RDI]= { .type = NLA_NESTED },
> + [IFLA_BRIDGE_CFM_CC_CCM_TX] = { .type = NLA_NESTED },
> +};


Re: [PATCH net-next v4 07/10] bridge: cfm: Netlink SET configuration Interface.

2020-10-09 Thread Nikolay Aleksandrov
On Fri, 2020-10-09 at 14:35 +, Henrik Bjoernlund wrote:
> This is the implementation of CFM netlink configuration
> set information interface.
> 
> Add new nested netlink attributes. These attributes are used by the
> user space to create/delete/configure CFM instances.
> 
> SETLINK:
> IFLA_BRIDGE_CFM:
> Indicate that the following attributes are CFM.
> 
> IFLA_BRIDGE_CFM_MEP_CREATE:
> This indicate that a MEP instance must be created.
> IFLA_BRIDGE_CFM_MEP_DELETE:
> This indicate that a MEP instance must be deleted.
> IFLA_BRIDGE_CFM_MEP_CONFIG:
> This indicate that a MEP instance must be configured.
> IFLA_BRIDGE_CFM_CC_CONFIG:
> This indicate that a MEP instance Continuity Check (CC)
> functionality must be configured.
> IFLA_BRIDGE_CFM_CC_PEER_MEP_ADD:
> This indicate that a CC Peer MEP must be added.
> IFLA_BRIDGE_CFM_CC_PEER_MEP_REMOVE:
> This indicate that a CC Peer MEP must be removed.
> IFLA_BRIDGE_CFM_CC_CCM_TX:
> This indicate that the CC transmitted CCM PDU must be configured.
> IFLA_BRIDGE_CFM_CC_RDI:
> This indicate that the CC transmitted CCM PDU RDI must be
> configured.
> 
> CFM nested attribute has the following attributes in next level.
> 
> SETLINK RTEXT_FILTER_CFM_CONFIG:
> IFLA_BRIDGE_CFM_MEP_CREATE_INSTANCE:
> The created MEP instance number.
> The type is u32.
> IFLA_BRIDGE_CFM_MEP_CREATE_DOMAIN:
> The created MEP domain.
> The type is u32 (br_cfm_domain).
> It must be BR_CFM_PORT.
> This means that CFM frames are transmitted and received
> directly on the port - untagged. Not in a VLAN.
> IFLA_BRIDGE_CFM_MEP_CREATE_DIRECTION:
> The created MEP direction.
> The type is u32 (br_cfm_mep_direction).
> It must be BR_CFM_MEP_DIRECTION_DOWN.
> This means that CFM frames are transmitted and received on
> the port. Not in the bridge.
> IFLA_BRIDGE_CFM_MEP_CREATE_IFINDEX:
> The created MEP residence port ifindex.
> The type is u32 (ifindex).
> 
> IFLA_BRIDGE_CFM_MEP_DELETE_INSTANCE:
> The deleted MEP instance number.
> The type is u32.
> 
> IFLA_BRIDGE_CFM_MEP_CONFIG_INSTANCE:
> The configured MEP instance number.
> The type is u32.
> IFLA_BRIDGE_CFM_MEP_CONFIG_UNICAST_MAC:
> The configured MEP unicast MAC address.
> The type is 6*u8 (array).
> This is used as SMAC in all transmitted CFM frames.
> IFLA_BRIDGE_CFM_MEP_CONFIG_MDLEVEL:
> The configured MEP unicast MD level.
> The type is u32.
> It must be in the range 1-7.
> No CFM frames are passing through this MEP on lower levels.
> IFLA_BRIDGE_CFM_MEP_CONFIG_MEPID:
> The configured MEP ID.
> The type is u32.
> It must be in the range 0-0x1FFF.
> This MEP ID is inserted in any transmitted CCM frame.
> 
> IFLA_BRIDGE_CFM_CC_CONFIG_INSTANCE:
> The configured MEP instance number.
> The type is u32.
> IFLA_BRIDGE_CFM_CC_CONFIG_ENABLE:
> The Continuity Check (CC) functionality is enabled or disabled.
> The type is u32 (bool).
> IFLA_BRIDGE_CFM_CC_CONFIG_EXP_INTERVAL:
> The CC expected receive interval of CCM frames.
> The type is u32 (br_cfm_ccm_interval).
> This is also the transmission interval of CCM frames when enabled.
> IFLA_BRIDGE_CFM_CC_CONFIG_EXP_MAID:
> The CC expected receive MAID in CCM frames.
> The type is CFM_MAID_LENGTH*u8.
> This is MAID is also inserted in transmitted CCM frames.
> 
> IFLA_BRIDGE_CFM_CC_PEER_MEP_INSTANCE:
> The configured MEP instance number.
> The type is u32.
> IFLA_BRIDGE_CFM_CC_PEER_MEPID:
> The CC Peer MEP ID added.
> The type is u32.
> When a Peer MEP ID is added and CC is enabled it is expected to
> receive CCM frames from that Peer MEP.
> 
> IFLA_BRIDGE_CFM_CC_RDI_INSTANCE:
> The configured MEP instance number.
> The type is u32.
> IFLA_BRIDGE_CFM_CC_RDI_RDI:
> The RDI that is inserted in transmitted CCM PDU.
> The type is u32 (bool).
> 
> IFLA_BRIDGE_CFM_CC_CCM_TX_INSTANCE:
> The configured MEP instance number.
> The type is u32.
> IFLA_BRIDGE_CFM_CC_CCM_TX_DMAC:
> The transmitted CCM frame destination MAC address.
> The type is 6*u8 (array).
> This is used as DMAC in all transmitted CFM frames.
> IFLA_BRIDGE_CFM_CC_CCM_TX_SEQ_NO_UPDATE:
> The transmitted CCM frame update (increment) of sequence
> number is enabled or disabled.
> The type is u32 (bool).
> IFLA_BRIDGE_CFM_CC_CCM_TX_PERIOD:
> The period of time where CCM frame are transmitted.
> The type is u32.
> The time is given in seconds. SETLINK