* Re: [PATCH v2 net-next 06/13] octeontx2-pf: Add support for unicast MAC address filtering
@ 2020-11-10 16:53 Naveen Mamindlapalli
0 siblings, 0 replies; 3+ messages in thread
From: Naveen Mamindlapalli @ 2020-11-10 16:53 UTC (permalink / raw)
To: Saeed Mahameed, netdev, linux-kernel
Cc: kuba, davem, Sunil Kovvuri Goutham, Linu Cherian,
Geethasowjanya Akula, Jerin Jacob Kollanukkaran,
Subbaraya Sundeep Bhatta, Hariprasad Kelam
Hi Saeed,
Thanks for the review!
> -----Original Message-----
> From: Saeed Mahameed <saeed@kernel.org>
> Sent: Saturday, November 7, 2020 3:46 AM
> To: Naveen Mamindlapalli <naveenm@marvell.com>; netdev@vger.kernel.org;
> linux-kernel@vger.kernel.org
> Cc: kuba@kernel.org; davem@davemloft.net; Sunil Kovvuri Goutham
> <sgoutham@marvell.com>; Linu Cherian <lcherian@marvell.com>;
> Geethasowjanya Akula <gakula@marvell.com>; Jerin Jacob Kollanukkaran
> <jerinj@marvell.com>; Subbaraya Sundeep Bhatta <sbhatta@marvell.com>;
> Hariprasad Kelam <hkelam@marvell.com>
> Subject: Re: [PATCH v2 net-next 06/13] octeontx2-pf: Add support for
> unicast MAC address filtering
>
> On Thu, 2020-11-05 at 14:58 +0530, Naveen Mamindlapalli wrote:
> > From: Hariprasad Kelam <hkelam@marvell.com>
> >
> > Add unicast MAC address filtering support using install flow message.
> > Total of 8 MCAM entries are allocated for adding unicast mac filtering
> > rules. If the MCAM allocation fails, the unicast filtering support
> > will not be advertised.
> >
> > Signed-off-by: Hariprasad Kelam <hkelam@marvell.com>
> > Signed-off-by: Sunil Goutham <sgoutham@marvell.com>
> > Signed-off-by: Naveen Mamindlapalli <naveenm@marvell.com>
> > ---
> > .../ethernet/marvell/octeontx2/nic/otx2_common.h | 10 ++
> > .../ethernet/marvell/octeontx2/nic/otx2_flows.c | 138
> > +++++++++++++++++++--
> > .../net/ethernet/marvell/octeontx2/nic/otx2_pf.c | 5 +
> > 3 files changed, 146 insertions(+), 7 deletions(-)
> >
>
> > +int otx2_add_macfilter(struct net_device *netdev, const u8 *mac) {
> > + struct otx2_nic *pf = netdev_priv(netdev);
> > + int err;
> > +
> > + err = otx2_do_add_macfilter(pf, mac);
> > + if (err) {
> > + netdev->flags |= IFF_PROMISC;
>
> I don't think you are allowed to change netdev->flags inside the driver like this,
> this can easily conflict with other users of this netdev; netdev promiscuity is
> managed by the stack via refcount Please see:
> __dev_set_promiscuity() and dev_set_promiscuity()
>
> And you will need to notify stack and userspace of flags changes.
Understood, will fix in v3.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2 net-next 00/13] Add ethtool ntuple filters support @ 2020-11-05 9:28 Naveen Mamindlapalli 2020-11-05 9:28 ` [PATCH v2 net-next 06/13] octeontx2-pf: Add support for unicast MAC address filtering Naveen Mamindlapalli 0 siblings, 1 reply; 3+ messages in thread From: Naveen Mamindlapalli @ 2020-11-05 9:28 UTC (permalink / raw) To: netdev, linux-kernel Cc: kuba, davem, sgoutham, lcherian, gakula, jerinj, sbhatta, hkelam, Naveen Mamindlapalli This patch series adds support for ethtool ntuple filters, unicast address filtering, VLAN offload and SR-IOV ndo handlers. All of the above features are based on the Admin Function(AF) driver support to install and delete the low level MCAM entries. Each MCAM entry is programmed with the packet fields to match and what actions to take if the match succeeds. The PF driver requests AF driver to allocate set of MCAM entries to be used to install the flows by that PF. The entries will be freed when the PF driver is unloaded. * The patches 1 to 4 adds AF driver infrastructure to install and delete the low level MCAM flow entries. * Patch 5 adds ethtool ntuple filter support. * Patch 6 adds unicast MAC address filtering. * Patch 7 adds support for dumping the MCAM entries via debugfs. * Patches 8 to 10 adds support for VLAN offload. * Patch 10 to 11 adds support for SR-IOV ndo handlers. * Patch 12 adds support to read the MCAM entries. Misc: * Removed redundant mailbox NIX_RXVLAN_ALLOC. Change-log: - Fixed the sparse issues reported by Jakub. Hariprasad Kelam (3): octeontx2-pf: Add support for unicast MAC address filtering octeontx2-pf: Implement ingress/egress VLAN offload octeontx2-af: Handle PF-VF mac address changes Naveen Mamindlapalli (2): octeontx2-pf: Add support for SR-IOV management functions octeontx2-af: Add new mbox messages to retrieve MCAM entries Stanislaw Kardach (1): octeontx2-af: Modify default KEX profile to extract TX packet fields Subbaraya Sundeep (6): octeontx2-af: Verify MCAM entry channel and PF_FUNC octeontx2-af: Generate key field bit mask from KEX profile octeontx2-af: Add mbox messages to install and delete MCAM rules octeontx2-pf: Add support for ethtool ntuple filters octeontx2-af: Add debugfs entry to dump the MCAM rules octeontx2-af: Delete NIX_RXVLAN_ALLOC mailbox message Vamsi Attunuru (1): octeontx2-af: Modify nix_vtag_cfg mailbox to support TX VTAG entries drivers/net/ethernet/marvell/octeontx2/af/Makefile | 2 +- drivers/net/ethernet/marvell/octeontx2/af/common.h | 2 + drivers/net/ethernet/marvell/octeontx2/af/mbox.h | 170 ++- drivers/net/ethernet/marvell/octeontx2/af/npc.h | 106 +- .../ethernet/marvell/octeontx2/af/npc_profile.h | 71 +- drivers/net/ethernet/marvell/octeontx2/af/rvu.c | 16 +- drivers/net/ethernet/marvell/octeontx2/af/rvu.h | 71 +- .../ethernet/marvell/octeontx2/af/rvu_debugfs.c | 197 +++ .../net/ethernet/marvell/octeontx2/af/rvu_nix.c | 305 ++++- .../net/ethernet/marvell/octeontx2/af/rvu_npc.c | 462 ++++++- .../net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c | 1334 ++++++++++++++++++++ .../net/ethernet/marvell/octeontx2/af/rvu_struct.h | 11 + .../net/ethernet/marvell/octeontx2/nic/Makefile | 2 +- .../ethernet/marvell/octeontx2/nic/otx2_common.c | 8 +- .../ethernet/marvell/octeontx2/nic/otx2_common.h | 54 + .../ethernet/marvell/octeontx2/nic/otx2_ethtool.c | 58 +- .../ethernet/marvell/octeontx2/nic/otx2_flows.c | 854 +++++++++++++ .../net/ethernet/marvell/octeontx2/nic/otx2_pf.c | 313 ++++- .../net/ethernet/marvell/octeontx2/nic/otx2_txrx.c | 16 + .../net/ethernet/marvell/octeontx2/nic/otx2_vf.c | 13 + 20 files changed, 3905 insertions(+), 160 deletions(-) create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c create mode 100644 drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c -- 2.16.5 ^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2 net-next 06/13] octeontx2-pf: Add support for unicast MAC address filtering 2020-11-05 9:28 [PATCH v2 net-next 00/13] Add ethtool ntuple filters support Naveen Mamindlapalli @ 2020-11-05 9:28 ` Naveen Mamindlapalli 2020-11-06 22:15 ` Saeed Mahameed 0 siblings, 1 reply; 3+ messages in thread From: Naveen Mamindlapalli @ 2020-11-05 9:28 UTC (permalink / raw) To: netdev, linux-kernel Cc: kuba, davem, sgoutham, lcherian, gakula, jerinj, sbhatta, hkelam, Naveen Mamindlapalli From: Hariprasad Kelam <hkelam@marvell.com> Add unicast MAC address filtering support using install flow message. Total of 8 MCAM entries are allocated for adding unicast mac filtering rules. If the MCAM allocation fails, the unicast filtering support will not be advertised. Signed-off-by: Hariprasad Kelam <hkelam@marvell.com> Signed-off-by: Sunil Goutham <sgoutham@marvell.com> Signed-off-by: Naveen Mamindlapalli <naveenm@marvell.com> --- .../ethernet/marvell/octeontx2/nic/otx2_common.h | 10 ++ .../ethernet/marvell/octeontx2/nic/otx2_flows.c | 138 +++++++++++++++++++-- .../net/ethernet/marvell/octeontx2/nic/otx2_pf.c | 5 + 3 files changed, 146 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h index 0f33bbba4e2b..f36972d46771 100644 --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h @@ -229,10 +229,17 @@ struct otx2_ptp { #define OTX2_HW_TIMESTAMP_LEN 8 +struct otx2_mac_table { + u8 addr[ETH_ALEN]; + u16 mcam_entry; + bool inuse; +}; + struct otx2_flow_config { u16 entry[NPC_MAX_NONCONTIG_ENTRIES]; u32 nr_flows; u32 ntuple_offset; + u32 unicast_offset; u32 ntuple_max_flows; struct list_head flow_list; }; @@ -249,6 +256,7 @@ struct otx2_nic { #define OTX2_FLAG_INTF_DOWN BIT_ULL(2) #define OTX2_FLAG_MCAM_ENTRIES_ALLOC BIT_ULL(3) #define OTX2_FLAG_NTUPLE_SUPPORT BIT_ULL(4) +#define OTX2_FLAG_UCAST_FLTR_SUPPORT BIT_ULL(5) #define OTX2_FLAG_RX_PAUSE_ENABLED BIT_ULL(9) #define OTX2_FLAG_TX_PAUSE_ENABLED BIT_ULL(10) u64 flags; @@ -674,5 +682,7 @@ int otx2_add_flow(struct otx2_nic *pfvf, int otx2_remove_flow(struct otx2_nic *pfvf, u32 location); int otx2_prepare_flow_request(struct ethtool_rx_flow_spec *fsp, struct npc_install_flow_req *req); +int otx2_del_macfilter(struct net_device *netdev, const u8 *mac); +int otx2_add_macfilter(struct net_device *netdev, const u8 *mac); #endif /* OTX2_COMMON_H */ diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c index a66b19c58f51..8851f8cd3822 100644 --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c @@ -10,8 +10,10 @@ /* helper macros to support mcam flows */ #define OTX2_MAX_NTUPLE_FLOWS 32 +#define OTX2_MAX_UNICAST_FLOWS 8 -#define OTX2_MCAM_COUNT OTX2_MAX_NTUPLE_FLOWS +#define OTX2_MCAM_COUNT (OTX2_MAX_NTUPLE_FLOWS + \ + OTX2_MAX_UNICAST_FLOWS) #define OTX2_DEFAULT_ACTION 0x1 @@ -35,7 +37,13 @@ int otx2_mcam_flow_init(struct otx2_nic *pf) pf->flow_cfg->ntuple_max_flows = OTX2_MAX_NTUPLE_FLOWS; - pf->flags |= OTX2_FLAG_NTUPLE_SUPPORT; + pf->flags |= OTX2_FLAG_NTUPLE_SUPPORT | + OTX2_FLAG_UCAST_FLTR_SUPPORT; + + pf->mac_table = devm_kzalloc(pf->dev, sizeof(struct otx2_mac_table) + * OTX2_MAX_UNICAST_FLOWS, GFP_KERNEL); + if (!pf->mac_table) + return -ENOMEM; return 0; } @@ -77,13 +85,19 @@ int otx2_alloc_mcam_entries(struct otx2_nic *pfvf) rsp = (struct npc_mcam_alloc_entry_rsp *)otx2_mbox_get_rsp (&pfvf->mbox.mbox, 0, &req->hdr); - if (rsp->count != req->count) + if (rsp->count != req->count) { netdev_info(pfvf->netdev, "number of rules truncated to %d\n", rsp->count); - - /* support only ntuples here */ - flow_cfg->ntuple_max_flows = rsp->count; - flow_cfg->ntuple_offset = 0; + /* support only ntuples here */ + flow_cfg->ntuple_max_flows = rsp->count; + flow_cfg->ntuple_offset = 0; + pfvf->netdev->priv_flags &= ~IFF_UNICAST_FLT; + pfvf->flags &= ~OTX2_FLAG_UCAST_FLTR_SUPPORT; + } else { + flow_cfg->ntuple_offset = 0; + flow_cfg->unicast_offset = flow_cfg->ntuple_offset + + OTX2_MAX_NTUPLE_FLOWS; + } for (i = 0; i < rsp->count; i++) flow_cfg->entry[i] = rsp->entry_list[i]; @@ -94,6 +108,116 @@ int otx2_alloc_mcam_entries(struct otx2_nic *pfvf) return 0; } +/* On success adds mcam entry + * On failure enable promisous mode + */ +static int otx2_do_add_macfilter(struct otx2_nic *pf, const u8 *mac) +{ + struct otx2_flow_config *flow_cfg = pf->flow_cfg; + struct npc_install_flow_req *req; + int err, i; + + if (!(pf->flags & OTX2_FLAG_MCAM_ENTRIES_ALLOC)) { + err = otx2_alloc_mcam_entries(pf); + if (err) + return err; + } + + if (!(pf->flags & OTX2_FLAG_UCAST_FLTR_SUPPORT)) + return -ENOMEM; + + /* dont have free mcam entries or uc list is greater than alloted */ + if (netdev_uc_count(pf->netdev) > OTX2_MAX_UNICAST_FLOWS) + return -ENOMEM; + + mutex_lock(&pf->mbox.lock); + req = otx2_mbox_alloc_msg_npc_install_flow(&pf->mbox); + if (!req) { + mutex_unlock(&pf->mbox.lock); + return -ENOMEM; + } + + /* unicast offset starts with 32 0..31 for ntuple */ + for (i = 0; i < OTX2_MAX_UNICAST_FLOWS; i++) { + if (pf->mac_table[i].inuse) + continue; + ether_addr_copy(pf->mac_table[i].addr, mac); + pf->mac_table[i].inuse = true; + pf->mac_table[i].mcam_entry = + flow_cfg->entry[i + flow_cfg->unicast_offset]; + req->entry = pf->mac_table[i].mcam_entry; + break; + } + + ether_addr_copy(req->packet.dmac, mac); + eth_broadcast_addr((u8 *)&req->mask.dmac); + req->features = BIT_ULL(NPC_DMAC); + req->channel = pf->hw.rx_chan_base; + req->intf = NIX_INTF_RX; + req->op = NIX_RX_ACTION_DEFAULT; + req->set_cntr = 1; + + err = otx2_sync_mbox_msg(&pf->mbox); + mutex_unlock(&pf->mbox.lock); + + return err; +} + +int otx2_add_macfilter(struct net_device *netdev, const u8 *mac) +{ + struct otx2_nic *pf = netdev_priv(netdev); + int err; + + err = otx2_do_add_macfilter(pf, mac); + if (err) { + netdev->flags |= IFF_PROMISC; + return err; + } + return 0; +} + +static bool otx2_get_mcamentry_for_mac(struct otx2_nic *pf, const u8 *mac, + int *mcam_entry) +{ + int i; + + for (i = 0; i < OTX2_MAX_UNICAST_FLOWS; i++) { + if (!pf->mac_table[i].inuse) + continue; + + if (ether_addr_equal(pf->mac_table[i].addr, mac)) { + *mcam_entry = pf->mac_table[i].mcam_entry; + pf->mac_table[i].inuse = false; + return true; + } + } + return false; +} + +int otx2_del_macfilter(struct net_device *netdev, const u8 *mac) +{ + struct otx2_nic *pf = netdev_priv(netdev); + struct npc_delete_flow_req *req; + int err, mcam_entry; + + /* check does mcam entry exists for given mac */ + if (!otx2_get_mcamentry_for_mac(pf, mac, &mcam_entry)) + return 0; + + mutex_lock(&pf->mbox.lock); + req = otx2_mbox_alloc_msg_npc_delete_flow(&pf->mbox); + if (!req) { + mutex_unlock(&pf->mbox.lock); + return -ENOMEM; + } + req->entry = mcam_entry; + /* Send message to AF */ + err = otx2_sync_mbox_msg(&pf->mbox); + mutex_unlock(&pf->mbox.lock); + + return err; +} + static struct otx2_flow *otx2_find_flow(struct otx2_nic *pfvf, u32 location) { struct otx2_flow *iter; diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c index f85073528eb9..8f9b5f539069 100644 --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c @@ -1724,6 +1724,10 @@ void otx2_do_set_rx_mode(struct work_struct *work) if (!(netdev->flags & IFF_UP)) return; + /* Write unicast address to mcam entries or del from mcam */ + if (netdev->priv_flags & IFF_UNICAST_FLT) + __dev_uc_sync(netdev, otx2_add_macfilter, otx2_del_macfilter); + mutex_lock(&pf->mbox.lock); req = otx2_mbox_alloc_msg_nix_set_rx_mode(&pf->mbox); if (!req) { @@ -2118,6 +2122,7 @@ static int otx2_probe(struct pci_dev *pdev, const struct pci_device_id *id) netdev->hw_features |= NETIF_F_LOOPBACK | NETIF_F_NTUPLE | NETIF_F_RXALL; + netdev->priv_flags |= IFF_UNICAST_FLT; netdev->gso_max_segs = OTX2_MAX_GSO_SEGS; netdev->watchdog_timeo = OTX2_TX_TIMEOUT; -- 2.16.5 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2 net-next 06/13] octeontx2-pf: Add support for unicast MAC address filtering 2020-11-05 9:28 ` [PATCH v2 net-next 06/13] octeontx2-pf: Add support for unicast MAC address filtering Naveen Mamindlapalli @ 2020-11-06 22:15 ` Saeed Mahameed 0 siblings, 0 replies; 3+ messages in thread From: Saeed Mahameed @ 2020-11-06 22:15 UTC (permalink / raw) To: Naveen Mamindlapalli, netdev, linux-kernel Cc: kuba, davem, sgoutham, lcherian, gakula, jerinj, sbhatta, hkelam On Thu, 2020-11-05 at 14:58 +0530, Naveen Mamindlapalli wrote: > From: Hariprasad Kelam <hkelam@marvell.com> > > Add unicast MAC address filtering support using install flow > message. Total of 8 MCAM entries are allocated for adding > unicast mac filtering rules. If the MCAM allocation fails, > the unicast filtering support will not be advertised. > > Signed-off-by: Hariprasad Kelam <hkelam@marvell.com> > Signed-off-by: Sunil Goutham <sgoutham@marvell.com> > Signed-off-by: Naveen Mamindlapalli <naveenm@marvell.com> > --- > .../ethernet/marvell/octeontx2/nic/otx2_common.h | 10 ++ > .../ethernet/marvell/octeontx2/nic/otx2_flows.c | 138 > +++++++++++++++++++-- > .../net/ethernet/marvell/octeontx2/nic/otx2_pf.c | 5 + > 3 files changed, 146 insertions(+), 7 deletions(-) > > +int otx2_add_macfilter(struct net_device *netdev, const u8 *mac) > +{ > + struct otx2_nic *pf = netdev_priv(netdev); > + int err; > + > + err = otx2_do_add_macfilter(pf, mac); > + if (err) { > + netdev->flags |= IFF_PROMISC; I don't think you are allowed to change netdev->flags inside the driver like this, this can easily conflict with other users of this netdev; netdev promiscuity is managed by the stack via refcount Please see: __dev_set_promiscuity() and dev_set_promiscuity() And you will need to notify stack and userspace of flags changes. ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-11-10 16:54 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-11-10 16:53 [PATCH v2 net-next 06/13] octeontx2-pf: Add support for unicast MAC address filtering Naveen Mamindlapalli -- strict thread matches above, loose matches on Subject: below -- 2020-11-05 9:28 [PATCH v2 net-next 00/13] Add ethtool ntuple filters support Naveen Mamindlapalli 2020-11-05 9:28 ` [PATCH v2 net-next 06/13] octeontx2-pf: Add support for unicast MAC address filtering Naveen Mamindlapalli 2020-11-06 22:15 ` Saeed Mahameed
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.