NCSI VLAN Filtering Support
Subsystems (3)
Samuel Mendoza-Jonas
maintainercover NCSI VLAN Filtering Support
This RFC series adds VLAN filtering support for NCSI-capable network devices. This supports adding and removing VLAN tags up to the limit of the actual NCSI channel. In it's present form the NCSI driver will default to the "Accept specific VLAN-tagged traffic as well as non-tagged traffic" mode.
This is still a bit rough, but sending out to the OpenBMC list for some eyeballing.
Samuel Mendoza-Jonas (3):
ftgmac: Include NETIF_F_HW_VLAN_CTAG_FILTER in features net/ncsi: Fix several packet definitions net/ncsi: Configure VLAN tag filter
drivers/net/ethernet/faraday/ftgmac100.c | 5 + include/net/ncsi.h | 2 + net/ncsi/internal.h | 11 ++ net/ncsi/ncsi-cmd.c | 10 +- net/ncsi/ncsi-manage.c | 257 ++++++++++++++++++++++++++++++- net/ncsi/ncsi-pkt.h | 2 +- net/ncsi/ncsi-rsp.c | 13 +- 7 files changed, 290 insertions(+), 10 deletions(-)
Signature · 1 line
2.13.3
Samuel Mendoza-Jonas
maintainerRFC PATCH 1/3 ftgmac: Include NETIF_F_HW_VLAN_CTAG_FILTER in features
This is required for the VLAN core to call the add/kill callback for VLAN IDs.
--- drivers/net/ethernet/faraday/ftgmac100.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/faraday/ftgmac100.c +3 -0
@@ -1837,6 +1837,9 @@ static int ftgmac100_probe(struct platform_device *pdev)NETIF_F_GRO |NETIF_F_SG |NETIF_F_HW_VLAN_CTAG_RX |NETIF_F_HW_VLAN_CTAG_TX ; +if (priv->use_ncsi) + netdev->hw_features |=NETIF_F_HW_VLAN_CTAG_FILTER ; +/* AST2400 doesn't have working HW checksum generation */ if (np && (of_device_is_compatible (np,"aspeed,ast2400-mac" ))) netdev->hw_features &= ~NETIF_F_HW_CSUM ;
Signature · 1 line
2.13.3
Re: [RFC PATCH 1/3] ftgmac: Include NETIF_F_HW_VLAN_CTAG_FILTER in features
Quoted 13 lines · Samuel Mendoza-Jonas
This is required for the VLAN core to call the add/kill callback for VLAN IDs.
Signed-off-by Samuel Mendoza-Jonas <[email protected]>--- drivers/net/ethernet/faraday/ftgmac100.c | 3 +++ 1 file changed, 3 insertions(+)drivers/net/ethernet/faraday/ftgmac100.c +0
-0
drivers/net/ethernet/faraday/ftgmac100.c static int ftgmac100_probe(struct platform_device *pdev) · line 1841
Quoted 5 lines
drivers/net/ethernet/faraday/ftgmac100.c +2
-0@@ -1837,6 +1837,9 @@ static int ftgmac100_probe(struct platform_device *pdev)NETIF_F_GRO |NETIF_F_SG |NETIF_F_HW_VLAN_CTAG_RX |NETIF_F_HW_VLAN_CTAG_TX ; +if (priv->use_ncsi) + netdev->hw_features |=NETIF_F_HW_VLAN_CTAG_FILTER ;
I'm a VLAN noob. Why is this conditional on ncsi?
Can the ftgmac100 support vlan with a directly attached PHY?
Cheers,
Joel
Re: [RFC PATCH 1/3] ftgmac: Include NETIF_F_HW_VLAN_CTAG_FILTER in features
Quoted 6 lines · Joel Stanley
Quoted 6 lines
drivers/net/ethernet/faraday/ftgmac100.c +0
-0@@ -1837,6 +1837,9 @@ static int ftgmac100_probe(struct platform_device *pdev)NETIF_F_GRO |NETIF_F_SG |NETIF_F_HW_VLAN_CTAG_RX |NETIF_F_HW_VLAN_CTAG_TX ;
Quoted 6 lines
drivers/net/ethernet/faraday/ftgmac100.c static int ftgmac100_probe(struct platform_device *pdev) · line 1841
Quoted 2 lines
drivers/net/ethernet/faraday/ftgmac100.c +2
-0+if (priv->use_ncsi) + netdev->hw_features |=NETIF_F_HW_VLAN_CTAG_FILTER ;I'm a VLAN noob. Why is this conditional on ncsi?
Can the ftgmac100 support vlan with a directly attached PHY?
ftgmac100 supports vlans fine. This flag is telling the network stack that we can offload the filtering so we need to get notified of vlans being added or removed.
There is no point setting it when not doing ncsi. The HW doesn't have a filter in that case (we do have HW vlan tag extraction and injection, which my driver supports, but that's different flags).
Cheers,
Ben.
Re: [RFC PATCH 1/3] ftgmac: Include NETIF_F_HW_VLAN_CTAG_FILTER in features
Quoted 14 lines · Benjamin Herrenschmidt
Quoted 6 lines · Joel Stanley
Quoted 6 lines
drivers/net/ethernet/faraday/ftgmac100.c +0
-0@@ -1837,6 +1837,9 @@ static int ftgmac100_probe(struct platform_device *pdev)NETIF_F_GRO |NETIF_F_SG |NETIF_F_HW_VLAN_CTAG_RX |NETIF_F_HW_VLAN_CTAG_TX ;Quoted 6 lines
drivers/net/ethernet/faraday/ftgmac100.c static int ftgmac100_probe(struct platform_device *pdev) · line 1841
Quoted 2 lines
drivers/net/ethernet/faraday/ftgmac100.c +2
-0+if (priv->use_ncsi) + netdev->hw_features |=NETIF_F_HW_VLAN_CTAG_FILTER ;I'm a VLAN noob. Why is this conditional on ncsi?
Can the ftgmac100 support vlan with a directly attached PHY?
Quoted 7 lines
ftgmac100 supports vlans fine. This flag is telling the network stack that we can offload the filtering so we need to get notified of vlans being added or removed.
There is no point setting it when not doing ncsi. The HW doesn't have a filter in that case (we do have HW vlan tag extraction and injection, which my driver supports, but that's different flags).
Thanks for the explanation. Makes sense.
Sam, that might make a good addition to the commit message.
Cheers,
Joel
Samuel Mendoza-Jonas
maintainerRFC PATCH 2/3 net/ncsi: Fix several packet definitions
In reply to Samuel Mendoza-Jonas--- net/ncsi/ncsi-cmd.c | 10 +++++----- net/ncsi/ncsi-pkt.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-)
net/ncsi/ncsi-cmd.c +5 -5
@@ -146,9 +146,9 @@ static int ncsi_cmd_handler_svf(struct sk_buff *skb, cmd = (struct ncsi_cmd_svf_pkt *)skb_put (skb,sizeof (*cmd));memset (cmd,0 ,sizeof (*cmd)); - cmd->vlan =htons (nca->words[0 ]); - cmd->index = nca->bytes[2 ]; - cmd->enable = nca->bytes[3 ]; + cmd->vlan =htons (nca->words[1 ]); + cmd->index = nca->bytes[6 ]; + cmd->enable = nca->bytes[7 ];ncsi_cmd_build_header (&cmd->cmd.common, nca);return 0 ;
@@ -161,7 +161,7 @@ static int ncsi_cmd_handler_ev(struct sk_buff *skb, cmd = (struct ncsi_cmd_ev_pkt *)skb_put (skb,sizeof (*cmd));memset (cmd,0 ,sizeof (*cmd)); - cmd->mode = nca->bytes[0 ]; + cmd->mode = nca->bytes[3 ];ncsi_cmd_build_header (&cmd->cmd.common, nca);return 0 ;
@@ -240,7 +240,7 @@ static struct ncsi_cmd_handler { { NCSI_PKT_CMD_AE, 8, ncsi_cmd_handler_ae }, { NCSI_PKT_CMD_SL, 8, ncsi_cmd_handler_sl }, { NCSI_PKT_CMD_GLS, 0, ncsi_cmd_handler_default }, - { NCSI_PKT_CMD_SVF, 4, ncsi_cmd_handler_svf }, + { NCSI_PKT_CMD_SVF, 8, ncsi_cmd_handler_svf }, { NCSI_PKT_CMD_EV, 4, ncsi_cmd_handler_ev }, { NCSI_PKT_CMD_DV, 0, ncsi_cmd_handler_default }, { NCSI_PKT_CMD_SMA, 8, ncsi_cmd_handler_sma },
net/ncsi/ncsi-pkt.h +1 -1
@@ -104,7 +104,7 @@ struct ncsi_cmd_svf_pkt {unsigned char index;/* VLAN table index */ unsigned char enable;/* Enable or disable */ __be32 checksum;/* Checksum */ -unsigned char pad[14 ]; +unsigned char pad[18 ]; };/* Enable VLAN */
Signature · 1 line
2.13.3
Re: [RFC PATCH 2/3] net/ncsi: Fix several packet definitions
Quoted 11 lines · Samuel Mendoza-Jonas
Signed-off-by Samuel Mendoza-Jonas <[email protected]>--- net/ncsi/ncsi-cmd.c | 10 +++++----- net/ncsi/ncsi-pkt.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-)net/ncsi/ncsi-cmd.c +0
-0
net/ncsi/ncsi-cmd.c static int ncsi_cmd_handler_svf(struct sk_buff *skb, · line 151
Quoted 9 lines
net/ncsi/ncsi-cmd.c +3
-3@@ -146,9 +146,9 @@ static int ncsi_cmd_handler_svf(struct sk_buff *skb, cmd = (struct ncsi_cmd_svf_pkt *)skb_put (skb,sizeof (*cmd));memset (cmd,0 ,sizeof (*cmd)); - cmd->vlan =htons (nca->words[0 ]); - cmd->index = nca->bytes[2 ]; - cmd->enable = nca->bytes[3 ]; + cmd->vlan =htons (nca->words[1 ]); + cmd->index = nca->bytes[6 ]; + cmd->enable = nca->bytes[7 ];
These look like straight up bugs. Should we send them off as fixes?
Quoted 37 lines
net/ncsi/ncsi-cmd.c +2
-2ncsi_cmd_build_header (&cmd->cmd.common, nca);return 0 ;@@ -161,7 +161,7 @@ static int ncsi_cmd_handler_ev(struct sk_buff *skb, cmd = (struct ncsi_cmd_ev_pkt *)skb_put (skb,sizeof (*cmd));memset (cmd,0 ,sizeof (*cmd)); - cmd->mode = nca->bytes[0 ]; + cmd->mode = nca->bytes[3 ];ncsi_cmd_build_header (&cmd->cmd.common, nca);return 0 ;@@ -240,7 +240,7 @@ static struct ncsi_cmd_handler { { NCSI_PKT_CMD_AE, 8, ncsi_cmd_handler_ae }, { NCSI_PKT_CMD_SL, 8, ncsi_cmd_handler_sl }, { NCSI_PKT_CMD_GLS, 0, ncsi_cmd_handler_default }, - { NCSI_PKT_CMD_SVF, 4, ncsi_cmd_handler_svf }, + { NCSI_PKT_CMD_SVF, 8, ncsi_cmd_handler_svf }, { NCSI_PKT_CMD_EV, 4, ncsi_cmd_handler_ev }, { NCSI_PKT_CMD_DV, 0, ncsi_cmd_handler_default }, { NCSI_PKT_CMD_SMA, 8, ncsi_cmd_handler_sma },net/ncsi/ncsi-pkt.h +1
-2@@ -104,7 +104,7 @@ struct ncsi_cmd_svf_pkt {unsigned char index;/* VLAN table index */ unsigned char enable;/* Enable or disable */ __be32 checksum;/* Checksum */ -unsigned char pad[14 ]; +unsigned char pad[18 ]; };/* Enable VLAN */ --2.13.3
Re: [RFC PATCH 2/3] net/ncsi: Fix several packet definitions
Quoted 14 lines · Joel Stanley
Quoted 12 lines · Samuel Mendoza-Jonas
Signed-off-by Samuel Mendoza-Jonas <[email protected]>--- net/ncsi/ncsi-cmd.c | 10 +++++----- net/ncsi/ncsi-pkt.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-)net/ncsi/ncsi-cmd.c +0
-0@@ -146,9 +146,9 @@ static int ncsi_cmd_handler_svf(struct sk_buff *skb,
Quoted 10 lines
net/ncsi/ncsi-cmd.c static int ncsi_cmd_handler_svf(struct sk_buff *skb, · line 151
Quoted 8 lines
net/ncsi/ncsi-cmd.c +3
-3cmd = (struct ncsi_cmd_svf_pkt *)skb_put (skb,sizeof (*cmd));memset (cmd,0 ,sizeof (*cmd)); - cmd->vlan =htons (nca->words[0 ]); - cmd->index = nca->bytes[2 ]; - cmd->enable = nca->bytes[3 ]; + cmd->vlan =htons (nca->words[1 ]); + cmd->index = nca->bytes[6 ]; + cmd->enable = nca->bytes[7 ];These look like straight up bugs. Should we send them off as fixes?
This shows how completely wrong that whole "magic byte/words array argumetns" thing is, especially when there *is* a proper struct definitions for the packets :-( We definitely need that fixed too asap.
Quoted 37 lines
Quoted 37 lines
net/ncsi/ncsi-cmd.c +2
-2ncsi_cmd_build_header (&cmd->cmd.common, nca);return 0 ;@@ -161,7 +161,7 @@ static int ncsi_cmd_handler_ev(struct sk_buff *skb, cmd = (struct ncsi_cmd_ev_pkt *)skb_put (skb,sizeof (*cmd));memset (cmd,0 ,sizeof (*cmd)); - cmd->mode = nca->bytes[0 ]; + cmd->mode = nca->bytes[3 ];ncsi_cmd_build_header (&cmd->cmd.common, nca);return 0 ;@@ -240,7 +240,7 @@ static struct ncsi_cmd_handler { { NCSI_PKT_CMD_AE, 8, ncsi_cmd_handler_ae }, { NCSI_PKT_CMD_SL, 8, ncsi_cmd_handler_sl }, { NCSI_PKT_CMD_GLS, 0, ncsi_cmd_handler_default }, - { NCSI_PKT_CMD_SVF, 4, ncsi_cmd_handler_svf }, + { NCSI_PKT_CMD_SVF, 8, ncsi_cmd_handler_svf }, { NCSI_PKT_CMD_EV, 4, ncsi_cmd_handler_ev }, { NCSI_PKT_CMD_DV, 0, ncsi_cmd_handler_default }, { NCSI_PKT_CMD_SMA, 8, ncsi_cmd_handler_sma },net/ncsi/ncsi-pkt.h +1
-2@@ -104,7 +104,7 @@ struct ncsi_cmd_svf_pkt {unsigned char index;/* VLAN table index */ unsigned char enable;/* Enable or disable */ __be32 checksum;/* Checksum */ -unsigned char pad[14 ]; +unsigned char pad[18 ]; };/* Enable VLAN */ --2.13.3
Samuel Mendoza-Jonas
maintainerRe: [RFC PATCH 2/3] net/ncsi: Fix several packet definitions
In reply to Joel StanleyQuoted 14 lines · Joel Stanley
Quoted 12 lines · Samuel Mendoza-Jonas
Signed-off-by Samuel Mendoza-Jonas <[email protected]>--- net/ncsi/ncsi-cmd.c | 10 +++++----- net/ncsi/ncsi-pkt.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-)net/ncsi/ncsi-cmd.c +0
-0@@ -146,9 +146,9 @@ static int ncsi_cmd_handler_svf(struct sk_buff *skb,
Quoted 10 lines
net/ncsi/ncsi-cmd.c static int ncsi_cmd_handler_svf(struct sk_buff *skb, · line 151
Quoted 8 lines
net/ncsi/ncsi-cmd.c +3
-3cmd = (struct ncsi_cmd_svf_pkt *)skb_put (skb,sizeof (*cmd));memset (cmd,0 ,sizeof (*cmd)); - cmd->vlan =htons (nca->words[0 ]); - cmd->index = nca->bytes[2 ]; - cmd->enable = nca->bytes[3 ]; + cmd->vlan =htons (nca->words[1 ]); + cmd->index = nca->bytes[6 ]; + cmd->enable = nca->bytes[7 ];These look like straight up bugs. Should we send them off as fixes?
These are straight up bugs except... without my changes we never call this code. As Ben says as time provides a lot of the current definitions need to be gone over, there's a few command/response code paths that are never triggered and could be broken in similar ways.
Quoted 38 lines
Quoted 38 lines
net/ncsi/ncsi-cmd.c +2
-2ncsi_cmd_build_header (&cmd->cmd.common, nca);return 0 ;@@ -161,7 +161,7 @@ static int ncsi_cmd_handler_ev(struct sk_buff *skb, cmd = (struct ncsi_cmd_ev_pkt *)skb_put (skb,sizeof (*cmd));memset (cmd,0 ,sizeof (*cmd)); - cmd->mode = nca->bytes[0 ]; + cmd->mode = nca->bytes[3 ];ncsi_cmd_build_header (&cmd->cmd.common, nca);return 0 ;@@ -240,7 +240,7 @@ static struct ncsi_cmd_handler { { NCSI_PKT_CMD_AE, 8, ncsi_cmd_handler_ae }, { NCSI_PKT_CMD_SL, 8, ncsi_cmd_handler_sl }, { NCSI_PKT_CMD_GLS, 0, ncsi_cmd_handler_default }, - { NCSI_PKT_CMD_SVF, 4, ncsi_cmd_handler_svf }, + { NCSI_PKT_CMD_SVF, 8, ncsi_cmd_handler_svf }, { NCSI_PKT_CMD_EV, 4, ncsi_cmd_handler_ev }, { NCSI_PKT_CMD_DV, 0, ncsi_cmd_handler_default }, { NCSI_PKT_CMD_SMA, 8, ncsi_cmd_handler_sma },net/ncsi/ncsi-pkt.h +1
-2@@ -104,7 +104,7 @@ struct ncsi_cmd_svf_pkt {unsigned char index;/* VLAN table index */ unsigned char enable;/* Enable or disable */ __be32 checksum;/* Checksum */ -unsigned char pad[14 ]; +unsigned char pad[18 ]; };/* Enable VLAN */ --2.13.3
Re: [RFC PATCH 2/3] net/ncsi: Fix several packet definitions
Quoted 26 lines · Samuel Mendoza-Jonas
Quoted 14 lines · Joel Stanley
Quoted 12 lines · Samuel Mendoza-Jonas
Signed-off-by Samuel Mendoza-Jonas <[email protected]>--- net/ncsi/ncsi-cmd.c | 10 +++++----- net/ncsi/ncsi-pkt.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-)net/ncsi/ncsi-cmd.c +0
-0@@ -146,9 +146,9 @@ static int ncsi_cmd_handler_svf(struct sk_buff *skb,Quoted 10 lines
net/ncsi/ncsi-cmd.c static int ncsi_cmd_handler_svf(struct sk_buff *skb, · line 151
Quoted 8 lines
net/ncsi/ncsi-cmd.c +3
-3cmd = (struct ncsi_cmd_svf_pkt *)skb_put (skb,sizeof (*cmd));memset (cmd,0 ,sizeof (*cmd)); - cmd->vlan =htons (nca->words[0 ]); - cmd->index = nca->bytes[2 ]; - cmd->enable = nca->bytes[3 ]; + cmd->vlan =htons (nca->words[1 ]); + cmd->index = nca->bytes[6 ]; + cmd->enable = nca->bytes[7 ];These look like straight up bugs. Should we send them off as fixes?
Quoted 4 lines
These are straight up bugs except... without my changes we never call this code. As Ben says as time provides a lot of the current definitions need to be gone over, there's a few command/response code paths that are never triggered and could be broken in similar ways.
Okay. So we can do the cleanup once the vlan fire has been put out?
Makes sense to me. Unless we start hitting strange bugs, in which case the cleanup might expose other issues.
Cheers,
Joel
Samuel Mendoza-Jonas
maintainerRFC PATCH 3/3 net/ncsi: Configure VLAN tag filter
In reply to Samuel Mendoza-JonasMake use of the ndo_vlan_rx_{add,kill}_vid callbacks to have the NCSI stack process new VLAN tags and configure the channel VLAN filter appropriately.
Several VLAN tags can be set and a "Set VLAN Filter" packet must be sent for each one, meaning the ncsi_dev_state_config_svf state must be repeated. An internal list of VLAN tags is maintained, and compared against the current channel's ncsi_channel_filter in order to keep track within the state. VLAN filters are removed in a similar manner, with the introduction of the ncsi_dev_state_config_clear_vids state. The maximum number of VLAN tag filters is determined by the "Get Capabilities" response from the channel.
--- drivers/net/ethernet/faraday/ftgmac100.c | 2 + include/net/ncsi.h | 2 + net/ncsi/internal.h | 11 ++ net/ncsi/ncsi-manage.c | 257 ++++++++++++++++++++++++++++++- net/ncsi/ncsi-rsp.c | 13 +- 5 files changed, 281 insertions(+), 4 deletions(-)
drivers/net/ethernet/faraday/ftgmac100.c +2 -0
@@ -1623,6 +1623,8 @@ static const struct net_device_ops ftgmac100_netdev_ops = {#ifdef CONFIG_NET_POLL_CONTROLLER .ndo_poll_controller = ftgmac100_poll_controller, #endif + .ndo_vlan_rx_add_vid = ncsi_vlan_rx_add_vid, + .ndo_vlan_rx_kill_vid = ncsi_vlan_rx_kill_vid, };static int ftgmac100_setup_mdio (struct net_device *netdev)
include/net/ncsi.h +2 -0
@@ -28,6 +28,8 @@ struct ncsi_dev { };#ifdef CONFIG_NET_NCSI +int ncsi_vlan_rx_add_vid (struct net_device *dev,__be16 proto,u16 vid); +int ncsi_vlan_rx_kill_vid (struct net_device *dev,__be16 proto,u16 vid);struct ncsi_dev *ncsi_register_dev (struct net_device *dev,void (*notifier)(struct ncsi_dev *nd));int ncsi_start_dev (struct ncsi_dev *nd);
net/ncsi/internal.h +11 -0
@@ -180,6 +180,7 @@ struct ncsi_channel {#define NCSI_CHANNEL_INACTIVE 1#define NCSI_CHANNEL_ACTIVE 2#define NCSI_CHANNEL_INVISIBLE 3 +bool reconfigure_needed;spinlock_t lock;/* Protect filters etc */ struct ncsi_package *package;struct ncsi_channel_version version;
@@ -235,6 +236,9 @@ enum { ncsi_dev_state_probe_dp, ncsi_dev_state_config_sp =0x0301 , ncsi_dev_state_config_cis, + ncsi_dev_state_config_clear_vids, + ncsi_dev_state_config_svf, + ncsi_dev_state_config_ev, ncsi_dev_state_config_sma, ncsi_dev_state_config_ebf, #if IS_ENABLED(CONFIG_IPV6)
@@ -253,6 +257,12 @@ enum {ncsi_dev_state_suspend_done }; +struct vlan_vid { +struct list_head list; +__be16 proto; +u16 vid; +}; +struct ncsi_dev_priv {struct ncsi_dev ndev;/* Associated NCSI device */ unsigned int flags;/* NCSI device flags */
@@ -276,6 +286,7 @@ struct ncsi_dev_priv {struct work_struct work;/* For channel management */ struct packet_type ptype;/* NCSI packet Rx handler */ struct list_head node;/* Form NCSI device list */ +struct list_head vlan_vids;/* List of active VLAN IDs */ };struct ncsi_cmd_arg {
net/ncsi/ncsi-manage.c +255 -2
301 lines not on this page · raw message
net/ncsi/ncsi-rsp.c +11 -2
@@ -39,8 +39,12 @@ static int ncsi_validate_rsp_pkt(struct ncsi_request *nr,/* Check on code and reason */ if (ntohs (h->code) !=NCSI_PKT_RSP_C_COMPLETED || -ntohs (h->reason) !=NCSI_PKT_RSP_R_NO_ERROR ) +ntohs (h->reason) !=NCSI_PKT_RSP_R_NO_ERROR ) { +printk (KERN_ERR "ncsi rsp not valid!\n" ); +printk (KERN_ERR "\tCode: %x\n" ,ntohs (h->code)); +printk (KERN_ERR "\tReason: %x\n" ,ntohs (h->reason));return -EINVAL ; + }/* Validate checksum, which might be zeroes if the * sender doesn't support checksum according to NCSI
@@ -693,7 +697,12 @@ static int ncsi_rsp_handler_gc(struct ncsi_request *nr) ncf->index = i; ncf->total = cnt; - ncf->bitmap =0x0ul ; +if (i ==NCSI_FILTER_VLAN ) { +/* Set VLAN filters active so they are cleared in config */ + ncf->bitmap =U64_MAX ; + }else { + ncf->bitmap =0x0ul ; + } nc->filters[i] = ncf; }
Signature · 1 line
2.13.3
Re: [RFC PATCH 3/3] net/ncsi: Configure VLAN tag filter
Quoted 12 lines · Samuel Mendoza-Jonas
Make use of the ndo_vlan_rx_{add,kill}_vid callbacks to have the NCSI stack process new VLAN tags and configure the channel VLAN filter appropriately.
Several VLAN tags can be set and a "Set VLAN Filter" packet must be sent for each one, meaning thencsi_dev_state_config_svfstate must be repeated. An internal list of VLAN tags is maintained, and compared against the current channel'sncsi_channel_filterin order to keep track within the state. VLAN filters are removed in a similar manner, with the introduction of thencsi_dev_state_config_clear_vidsstate. The maximum number of VLAN tag filters is determined by the "Get Capabilities" response from the channel.
Quoted 1 line
Signed-off-by Samuel Mendoza-Jonas <[email protected]>
Thanks Sam. I've made some comments below.
Quoted 10 lines
--- drivers/net/ethernet/faraday/ftgmac100.c | 2 + include/net/ncsi.h | 2 + net/ncsi/internal.h | 11 ++ net/ncsi/ncsi-manage.c | 257 ++++++++++++++++++++++++++++++- net/ncsi/ncsi-rsp.c | 13 +- 5 files changed, 281 insertions(+), 4 deletions(-)
net/ncsi/ncsi-manage.c static void ncsi_configure_channel(struct ncsi_dev_priv *ndp) · line 710
Quoted 5 lines
net/ncsi/ncsi-manage.c +2
-0@@ -699,11 +706,93 @@ static void ncsi_configure_channel(struct ncsi_dev_priv *ndp) nca.package = np->id; nca.channel = nc->id; +/* Clear any active filters on the channel before setting */ +if (nd->state == ncsi_dev_state_config_clear_vids) {
This is epic. Could it go in a function?
net/ncsi/ncsi-manage.c static void ncsi_configure_channel(struct ncsi_dev_priv *ndp) · line 715
Quoted 5 lines
net/ncsi/ncsi-manage.c +5
-0+ clear = false; + vlan_index =-1 ; +spin_lock_irqsave (&nc->lock, flags); + ncf = nc->filters[NCSI_FILTER_VLAN ]; + while ((vlan_index = find_next_bit((void *)&ncf->bitmap, ncf->total, vlan_index + 1))
We should make ->bitmap an unsigned long, then we can pass it to find_next_bit without casting. Other users of it do the same thing with a temporary variable.
net/ncsi/ncsi-manage.c static void ncsi_configure_channel(struct ncsi_dev_priv *ndp) · line 718
Quoted 3 lines
net/ncsi/ncsi-manage.c +3
-0+ < ncf->total) { + clear = true; +// TODO retrieve the vid that was set
Still WIP?
net/ncsi/ncsi-manage.c static void ncsi_configure_channel(struct ncsi_dev_priv *ndp) · line 719
Quoted 1 line
net/ncsi/ncsi-manage.c +1
-0+ netdev_printk(KERN_DEBUG, dev, "ncsi: removed vlan tag at index %d\n",
Do we get a ncsi prefix from the driver name?
Quoted 14 lines
net/ncsi/ncsi-manage.c +13
-0+ vlan_index); +ncsi_remove_filter (nc,NCSI_FILTER_VLAN , vlan_index); +break ; + } +spin_unlock_irqrestore (&nc->lock, flags); + +int ncsi_vlan_rx_add_vid (struct net_device *dev,__be16 proto,u16 vid) +{ +struct ncsi_channel_filter *ncf; +struct ncsi_dev_priv *ndp; +unsigned int n_vids =0 ; +struct vlan_vid *vlan; +struct ncsi_dev *nd;
net/ncsi/ncsi-manage.c static struct notifier_block ncsi_inet6addr_notifier = { · line 1391
Quoted 10 lines
net/ncsi/ncsi-manage.c +9
-0+bool found = false; + +if (n_vids >= ncf->total) { +netdev_info (dev,"NCSI Channel supports up to %u VLAN tags but %u are already set\n" , + ncf->total, n_vids); +return -EINVAL ; + } + + vlan =kzalloc (sizeof (struct vlan_vid ),GFP_KERNEL );
Does this get freed anywhere?
Quoted 5 lines
net/ncsi/ncsi-manage.c +4
-0+if (!vlan) { +netdev_err (dev,"could not alloc vlan_vid struct\n" ); +return -ENOMEM ; + }
Samuel Mendoza-Jonas
maintainerRe: [RFC PATCH 3/3] net/ncsi: Configure VLAN tag filter
Quoted 27 lines · Joel Stanley
Quoted 12 lines · Samuel Mendoza-Jonas
Make use of the ndo_vlan_rx_{add,kill}_vid callbacks to have the NCSI stack process new VLAN tags and configure the channel VLAN filter appropriately.
Several VLAN tags can be set and a "Set VLAN Filter" packet must be sent for each one, meaning thencsi_dev_state_config_svfstate must be repeated. An internal list of VLAN tags is maintained, and compared against the current channel'sncsi_channel_filterin order to keep track within the state. VLAN filters are removed in a similar manner, with the introduction of thencsi_dev_state_config_clear_vidsstate. The maximum number of VLAN tag filters is determined by the "Get Capabilities" response from the channel.Quoted 1 line
Signed-off-by Samuel Mendoza-Jonas <[email protected]>Thanks Sam. I've made some comments below.
Quoted 7 lines
--- drivers/net/ethernet/faraday/ftgmac100.c | 2 + include/net/ncsi.h | 2 + net/ncsi/internal.h | 11 ++ net/ncsi/ncsi-manage.c | 257 ++++++++++++++++++++++++++++++- net/ncsi/ncsi-rsp.c | 13 +- 5 files changed, 281 insertions(+), 4 deletions(-)
Quoted 8 lines
net/ncsi/ncsi-manage.c static void ncsi_configure_channel(struct ncsi_dev_priv *ndp) · line 710
Quoted 6 lines
net/ncsi/ncsi-manage.c +2
-0@@ -699,11 +706,93 @@ static void ncsi_configure_channel(struct ncsi_dev_priv *ndp) nca.package = np->id; nca.channel = nc->id; +/* Clear any active filters on the channel before setting */ +if (nd->state == ncsi_dev_state_config_clear_vids) {This is epic. Could it go in a function?
Yep, I'll clean up and split out what I can.
Quoted 10 lines
net/ncsi/ncsi-manage.c static void ncsi_configure_channel(struct ncsi_dev_priv *ndp) · line 715
Quoted 6 lines
net/ncsi/ncsi-manage.c +5
-0+ clear = false; + vlan_index =-1 ; +spin_lock_irqsave (&nc->lock, flags); + ncf = nc->filters[NCSI_FILTER_VLAN ]; + while ((vlan_index = find_next_bit((void *)&ncf->bitmap, ncf->total, vlan_index + 1))We should make ->bitmap an unsigned long, then we can pass it to
find_next_bitwithout casting. Other users of it do the same thing with a temporary variable.
Ack
Quoted 6 lines
net/ncsi/ncsi-manage.c static void ncsi_configure_channel(struct ncsi_dev_priv *ndp) · line 718
Quoted 4 lines
net/ncsi/ncsi-manage.c +3
-0+ < ncf->total) { + clear = true; +// TODO retrieve the vid that was set Still WIP?
Definitely still 'rough' :)
Quoted 4 lines
net/ncsi/ncsi-manage.c static void ncsi_configure_channel(struct ncsi_dev_priv *ndp) · line 719
Quoted 2 lines
net/ncsi/ncsi-manage.c +1
-0+ netdev_printk(KERN_DEBUG, dev, "ncsi: removed vlan tag at index %d\n",Do we get a ncsi prefix from the driver name?
No we get a prefix of the form
"ftgmac100 1e660000.ethernet eth0:"
so yes adding a NCSI prefix would be good.
Quoted 17 lines
Quoted 17 lines
net/ncsi/ncsi-manage.c +16
-0+ vlan_index); +ncsi_remove_filter (nc,NCSI_FILTER_VLAN , vlan_index); +break ; + } +spin_unlock_irqrestore (&nc->lock, flags); + +int ncsi_vlan_rx_add_vid (struct net_device *dev,__be16 proto,u16 vid) +{ +struct ncsi_channel_filter *ncf; +struct ncsi_dev_priv *ndp; +unsigned int n_vids =0 ; +struct vlan_vid *vlan; +struct ncsi_dev *nd; +bool found = false; + +if (n_vids >= ncf->total) {
Quoted 8 lines
net/ncsi/ncsi-manage.c static struct notifier_block ncsi_inet6addr_notifier = { · line 1391
Quoted 6 lines
net/ncsi/ncsi-manage.c +6
-0+netdev_info (dev,"NCSI Channel supports up to %u VLAN tags but %u are already set\n" , + ncf->total, n_vids); +return -EINVAL ; + } + + vlan =kzalloc (sizeof (struct vlan_vid ),GFP_KERNEL );Does this get freed anywhere?
Whoops!
Quoted 6 lines
Quoted 6 lines
net/ncsi/ncsi-manage.c +4
-0+if (!vlan) { +netdev_err (dev,"could not alloc vlan_vid struct\n" ); +return -ENOMEM ; + }
Re: [RFC PATCH 3/3] net/ncsi: Configure VLAN tag filter
In reply to Samuel Mendoza-JonasQuoted 31 lines · Samuel Mendoza-Jonas
net/ncsi/ncsi-manage.c +31
-0+static int ncsi_kick_channels (struct ncsi_dev_priv *ndp) +{ +struct ncsi_dev *nd = &ndp->ndev; +struct ncsi_channel *nc; +struct ncsi_package *np; +unsigned long flags; +unsigned int n =0 ; + + NCSI_FOR_EACH_PACKAGE(ndp, np) { + NCSI_FOR_EACH_CHANNEL(np, nc) { +spin_lock_irqsave (&nc->lock, flags); + +/* +* Channels may be busy - mark dirty instead of kicking if +* a) not ACTIVE (configured) +* b) in the channel_queue (to be configured) +* c) it's ndev is in the config state +*/ +if (nc->state !=NCSI_CHANNEL_ACTIVE ) { +if ((ndp->ndev.state &0xff00 ) == ncsi_dev_state_config || + !list_empty (&nc->link)) { +netdev_info (nd->dev,"nc %p marked dirty\n" , nc); + nc->reconfigure_needed = true; + } +spin_unlock_irqrestore (&nc->lock, flags); +continue ; + } + +spin_unlock_irqrestore (&nc->lock, flags); + +ncsi_stop_channel_monitor (nc);
net/ncsi/ncsi-manage.c static struct notifier_block ncsi_inet6addr_notifier = { · line 1343
Quoted 10 lines
net/ncsi/ncsi-manage.c +10
-0+spin_lock_irqsave (&nc->lock, flags); + nc->state =NCSI_CHANNEL_INVISIBLE ; +spin_unlock_irqrestore (&nc->lock, flags); + +spin_lock_irqsave (&ndp->lock, flags); + nc->state =NCSI_CHANNEL_INACTIVE ; +list_add_tail_rcu (&nc->link, &ndp->channel_queue); +spin_unlock_irqrestore (&ndp->lock, flags); + +spin_unlock_irqrestore (&nc->lock, flags);
Oops, this is unlocking nc->lock a second time.
Quoted 5 lines
net/ncsi/ncsi-manage.c +5
-0+ +netdev_info (nd->dev,"Kicked channel %p\n" , nc); + n++; + } + }
Samuel Mendoza-Jonas
maintainerRe: [RFC PATCH 3/3] net/ncsi: Configure VLAN tag filter
Quoted 37 lines · Joel Stanley
Quoted 35 lines · Samuel Mendoza-Jonas
net/ncsi/ncsi-manage.c +35
-0+static int ncsi_kick_channels (struct ncsi_dev_priv *ndp) +{ +struct ncsi_dev *nd = &ndp->ndev; +struct ncsi_channel *nc; +struct ncsi_package *np; +unsigned long flags; +unsigned int n =0 ; + + NCSI_FOR_EACH_PACKAGE(ndp, np) { + NCSI_FOR_EACH_CHANNEL(np, nc) { +spin_lock_irqsave (&nc->lock, flags); + +/* +* Channels may be busy - mark dirty instead of kicking if +* a) not ACTIVE (configured) +* b) in the channel_queue (to be configured) +* c) it's ndev is in the config state +*/ +if (nc->state !=NCSI_CHANNEL_ACTIVE ) { +if ((ndp->ndev.state &0xff00 ) == ncsi_dev_state_config || + !list_empty (&nc->link)) { +netdev_info (nd->dev,"nc %p marked dirty\n" , nc); + nc->reconfigure_needed = true; + } +spin_unlock_irqrestore (&nc->lock, flags); +continue ; + } + +spin_unlock_irqrestore (&nc->lock, flags); + +ncsi_stop_channel_monitor (nc); +spin_lock_irqsave (&nc->lock, flags); + nc->state =NCSI_CHANNEL_INVISIBLE ; +spin_unlock_irqrestore (&nc->lock, flags); +
Quoted 8 lines
net/ncsi/ncsi-manage.c static struct notifier_block ncsi_inet6addr_notifier = { · line 1343
Quoted 6 lines
net/ncsi/ncsi-manage.c +6
-0+spin_lock_irqsave (&ndp->lock, flags); + nc->state =NCSI_CHANNEL_INACTIVE ; +list_add_tail_rcu (&nc->link, &ndp->channel_queue); +spin_unlock_irqrestore (&ndp->lock, flags); + +spin_unlock_irqrestore (&nc->lock, flags);Oops, this is unlocking
nc->locka second time.
Oops indeed! Good spot.
Quoted 6 lines
Quoted 6 lines
net/ncsi/ncsi-manage.c +5
-0+ +netdev_info (nd->dev,"Kicked channel %p\n" , nc); + n++; + } + }