Add ethtool ntuple filters support
Subsystems (4)
v3 cover Add ethtool ntuple filters support
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:
v3:
- Fixed Saeed's review comments on v2.
- Fixed modifying the netdev->flags from driver.
- Fixed modifying the netdev features and hw_features after register_netdev.
- Removed unwanted ndo_features_check callback.
v2:
- 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 | 59 + .../ethernet/marvell/octeontx2/nic/otx2_ethtool.c | 58 +- .../ethernet/marvell/octeontx2/nic/otx2_flows.c | 820 ++++++++++++ .../net/ethernet/marvell/octeontx2/nic/otx2_pf.c | 307 ++++- .../net/ethernet/marvell/octeontx2/nic/otx2_txrx.c | 16 + .../net/ethernet/marvell/octeontx2/nic/otx2_vf.c | 5 + 20 files changed, 3862 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
Signature · 1 line
2.16.5
PATCH v3 1/13 octeontx2-af: Modify default KEX profile to extract TX packet fields
From: Stanislaw Kardach <[email protected]>
The current default Key Extraction(KEX) profile can only use RX packet fields while generating the MCAM search key. The profile can't be used for matching TX packet fields. This patch modifies the default KEX profile to add support for extracting TX packet fields into MCAM search key. Enabled Tx KPU packet parsing by configuring TX PKIND in tx_parse_cfg.
Also modified the default KEX profile to extract VLAN TCI from the LB_PTR and exact byte offset of VLAN header. The NPC KPU parser was modified to point LB_PTR to the starting byte offset of VLAN header which points to the tpid field.
--- .../ethernet/marvell/octeontx2/af/npc_profile.h | 71 ++++++++++++++++++++-- .../net/ethernet/marvell/octeontx2/af/rvu_nix.c | 6 ++ 2 files changed, 72 insertions(+), 5 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/npc_profile.h +66 -5
@@ -13386,8 +13386,8 @@ static struct npc_mcam_kex npc_mkex_default = { .kpu_version = NPC_KPU_PROFILE_VER, .keyx_cfg = { /* nibble: LA..LE (ltype only) + Channel */ - [NIX_INTF_RX] = ((u64)NPC_MCAM_KEY_X2 << 32) | 0x49247, - [NIX_INTF_TX] = ((u64)NPC_MCAM_KEY_X2 << 32) | ((1ULL << 19) - 1), + [NIX_INTF_RX] = ((u64)NPC_MCAM_KEY_X2 << 32) | 0x249207, + [NIX_INTF_TX] = ((u64)NPC_MCAM_KEY_X2 << 32) | 0x249200, }, .intf_lid_lt_ld = {/* Default RX MCAM KEX profile */
@@ -13405,12 +13405,14 @@ static struct npc_mcam_kex npc_mkex_default = {/* Layer B: Single VLAN (CTAG) */ /* CTAG VLAN[2..3] + Ethertype, 4 bytes, KW0[63:32] */ [NPC_LT_LB_CTAG] = { - KEX_LD_CFG(0x03, 0x0, 0x1, 0x0, 0x4), + KEX_LD_CFG(0x03, 0x2, 0x1, 0x0, 0x4), }, /* Layer B: Stacked VLAN (STAG|QinQ) */ [NPC_LT_LB_STAG_QINQ] = { -/* CTAG VLAN[2..3] + Ethertype, 4 bytes, KW0[63:32] */ - KEX_LD_CFG(0x03, 0x4, 0x1, 0x0, 0x4), + /* Outer VLAN: 2 bytes, KW0[63:48] */ + KEX_LD_CFG(0x01, 0x2, 0x1, 0x0, 0x6), +/* Ethertype: 2 bytes, KW0[47:32] */ + KEX_LD_CFG(0x01, 0x8, 0x1, 0x0, 0x4), }, [NPC_LT_LB_FDSA] = {/* SWITCH PORT: 1 byte, KW0[63:48] */
@@ -13450,6 +13452,65 @@ static struct npc_mcam_kex npc_mkex_default = { }, }, }, + +/* Default TX MCAM KEX profile */ + [NIX_INTF_TX ] = { + [NPC_LID_LA ] = { +/* Layer A: Ethernet: */ + [NPC_LT_LA_IH_NIX_ETHER ] = { +/* PF_FUNC: 2B , KW0 [47:32] */ +KEX_LD_CFG (0x01 ,0x0 ,0x1 ,0x0 ,0x4 ), +/* DMAC: 6 bytes, KW1[63:16] */ +KEX_LD_CFG (0x05 ,0x8 ,0x1 ,0x0 ,0xa ), + }, + }, + [NPC_LID_LB ] = { +/* Layer B: Single VLAN (CTAG) */ + [NPC_LT_LB_CTAG ] = { +/* CTAG VLAN[2..3] KW0[63:48] */ +KEX_LD_CFG (0x01 ,0x2 ,0x1 ,0x0 ,0x6 ), +/* CTAG VLAN[2..3] KW1[15:0] */ +KEX_LD_CFG (0x01 ,0x4 ,0x1 ,0x0 ,0x8 ), + }, +/* Layer B: Stacked VLAN (STAG|QinQ) */ + [NPC_LT_LB_STAG_QINQ ] = { +/* Outer VLAN: 2 bytes, KW0[63:48] */ +KEX_LD_CFG (0x01 ,0x2 ,0x1 ,0x0 ,0x6 ), +/* Outer VLAN: 2 Bytes, KW1[15:0] */ +KEX_LD_CFG (0x01 ,0x8 ,0x1 ,0x0 ,0x8 ), + }, + }, + [NPC_LID_LC ] = { +/* Layer C: IPv4 */ + [NPC_LT_LC_IP ] = { +/* SIP+DIP: 8 bytes, KW2[63:0] */ +KEX_LD_CFG (0x07 ,0xc ,0x1 ,0x0 ,0x10 ), +/* TOS: 1 byte, KW1[63:56] */ +KEX_LD_CFG (0x0 ,0x1 ,0x1 ,0x0 ,0xf ), + }, +/* Layer C: IPv6 */ + [NPC_LT_LC_IP6 ] = { +/* Everything up to SADDR: 8 bytes, KW2[63:0] */ +KEX_LD_CFG (0x07 ,0x0 ,0x1 ,0x0 ,0x10 ), + }, + }, + [NPC_LID_LD ] = { +/* Layer D:UDP */ + [NPC_LT_LD_UDP ] = { +/* SPORT: 2 bytes, KW3[15:0] */ +KEX_LD_CFG (0x1 ,0x0 ,0x1 ,0x0 ,0x18 ), +/* DPORT: 2 bytes, KW3[31:16] */ +KEX_LD_CFG (0x1 ,0x2 ,0x1 ,0x0 ,0x1a ), + }, +/* Layer D:TCP */ + [NPC_LT_LD_TCP ] = { +/* SPORT: 2 bytes, KW3[15:0] */ +KEX_LD_CFG (0x1 ,0x0 ,0x1 ,0x0 ,0x18 ), +/* DPORT: 2 bytes, KW3[31:16] */ +KEX_LD_CFG (0x1 ,0x2 ,0x1 ,0x0 ,0x1a ), + }, + }, + }, }, };
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +6 -0
@@ -57,6 +57,8 @@ enum nix_makr_fmt_indexes { NIX_MARK_CFG_MAX, }; +#define NIX_TX_PKIND 63ULL +/* For now considering MC resources needed for broadcast * pkt replication only. i.e 256 HWVFs + 12 PFs. */
@@ -1182,6 +1184,10 @@ int rvu_mbox_handler_nix_lf_alloc(struct rvu *rvu,/* Config Rx pkt length, csum checks and apad enable / disable */ rvu_write64 (rvu, blkaddr,NIX_AF_LFX_RX_CFG (nixlf), req->rx_cfg); +/* Configure pkind for TX parse config, 63 from npc_profile */ + cfg =NIX_TX_PKIND ; +rvu_write64 (rvu, blkaddr,NIX_AF_LFX_TX_PARSE_CFG (nixlf), cfg); + intf =is_afvf (pcifunc) ?NIX_INTF_TYPE_LBK :NIX_INTF_TYPE_CGX ; err =nix_interface_init (rvu, pcifunc, intf, nixlf);if (err)
Signature · 1 line
2.16.5
Re: [PATCH v3 net-next 01/13] octeontx2-af: Modify default KEX profile to extract TX packet fields
Quoted 9 lines · Naveen Mamindlapalli
From: Stanislaw Kardach <[email protected]>
The current default Key Extraction(KEX) profile can only use RX packet fields while generating the MCAM search key. The profile can't be used for matching TX packet fields. This patch modifies the default KEX profile to add support for extracting TX packet fields into MCAM search key. Enabled Tx KPU packet parsing by configuring TX PKIND in
tx_parse_cfg.
Quoted 9 lines
Also modified the default KEX profile to extract VLAN TCI from the
LB_PTRand exact byte offset of VLAN header. The NPC KPU parser was modified to pointLB_PTRto the starting byte offset of VLAN header which points to the tpid field.Signed-off-by Stanislaw Kardach <[email protected]>Signed-off-by Sunil Goutham <[email protected]>Signed-off-by Naveen Mamindlapalli <[email protected]>
RE: [EXT] Re: [PATCH v3 net-next 01/13] octeontx2-af: Modify default KEX profile to extract TX packet fields
Hi Saeed,
Thanks for the review.
Quoted 38 lines
-----Original Message-----
From: Saeed Mahameed <[email protected]>
Sent: Friday, November 13, 2020 1:27 AM
To: Naveen Mamindlapalli <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; [email protected]; Sunil Kovvuri Goutham <[email protected]>; Linu Cherian <[email protected]>; Geethasowjanya Akula <[email protected]>; Jerin Jacob Kollanukkaran <[email protected]>; Subbaraya Sundeep Bhatta <[email protected]>; Hariprasad Kelam <[email protected]>
Subject: [EXT] Re: [PATCH v3 net-next 01/13] octeontx2-af: Modify default KEX profile to extract TX packet fieldsExternal Email
----------------------------------------------------------------------
Quoted 9 lines · Naveen Mamindlapalli
From: Stanislaw Kardach <[email protected]>
The current default Key Extraction(KEX) profile can only use RX packet fields while generating the MCAM search key. The profile can't be used for matching TX packet fields. This patch modifies the default KEX profile to add support for extracting TX packet fields into MCAM search key. Enabled Tx KPU packet parsing by configuring TX PKIND in
tx_parse_cfg.Quoted 9 lines
Also modified the default KEX profile to extract VLAN TCI from the
LB_PTRand exact byte offset of VLAN header. The NPC KPU parser was modified to pointLB_PTRto the starting byte offset of VLAN header which points to the tpid field.Signed-off-by Stanislaw Kardach <[email protected]>Signed-off-by Sunil Goutham <[email protected]>Signed-off-by Naveen Mamindlapalli <[email protected]>Reviewed-by Saeed Mahameed <[email protected]>
Re: [PATCH v3 net-next 01/13] octeontx2-af: Modify default KEX profile to extract TX packet fields
In reply to Naveen MamindlapalliQuoted 10 lines · Naveen Mamindlapalli
From: Stanislaw Kardach <[email protected]>
The current default Key Extraction(KEX) profile can only use RX packet fields while generating the MCAM search key. The profile can't be used for matching TX packet fields. This patch modifies the default KEX profile to add support for extracting TX packet fields into MCAM search key. Enabled Tx KPU packet parsing by configuring TX PKIND in
tx_parse_cfg.
Quoted 8 lines
Also modified the default KEX profile to extract VLAN TCI from the
LB_PTRand exact byte offset of VLAN header. The NPC KPU parser was modified to pointLB_PTRto the starting byte offset of VLAN header which points to the tpid field.Signed-off-by Stanislaw Kardach <[email protected]>Signed-off-by Sunil Goutham <[email protected]>Signed-off-by Naveen Mamindlapalli <[email protected]>
A bit more documentation would be useful. However other than that the code itself appears to make sense.
Quoted 10 lines
--- .../ethernet/marvell/octeontx2/af/npc_profile.h | 71 ++++++++++++++++++++-- .../net/ethernet/marvell/octeontx2/af/rvu_nix.c | 6 ++ 2 files changed, 72 insertions(+), 5 deletions(-)drivers/net/ethernet/marvell/octeontx2/af/npc_profile.h +0
-0
drivers/net/ethernet/marvell/octeontx2/af/npc_profile.h static struct npc_mcam_kex npc_mkex_default = { · line 13393
Quoted 10 lines
drivers/net/ethernet/marvell/octeontx2/af/npc_profile.h +2
-2@@ -13386,8 +13386,8 @@ static struct npc_mcam_kex npc_mkex_default = { .kpu_version = NPC_KPU_PROFILE_VER, .keyx_cfg = { /* nibble: LA..LE (ltype only) + Channel */ - [NIX_INTF_RX] = ((u64)NPC_MCAM_KEY_X2 << 32) | 0x49247, - [NIX_INTF_TX] = ((u64)NPC_MCAM_KEY_X2 << 32) | ((1ULL << 19) - 1), + [NIX_INTF_RX] = ((u64)NPC_MCAM_KEY_X2 << 32) | 0x249207, + [NIX_INTF_TX] = ((u64)NPC_MCAM_KEY_X2 << 32) | 0x249200, }, .intf_lid_lt_ld = {/* Default RX MCAM KEX profile */
//
Any sort of explanation for what some of these magic numbers means might be useful. I'm left wondering if the lower 32b is a bitfield or a fixed value. I am guessing bit field based on the fact that it was originally being set using ((1ULL << X) - 1) however if there were macros defined for each bit explaining what each bit was that would be useful.
drivers/net/ethernet/marvell/octeontx2/af/npc_profile.h static struct npc_mcam_kex npc_mkex_default = { · line 13409
Quoted 7 lines
drivers/net/ethernet/marvell/octeontx2/af/npc_profile.h +1
-1@@ -13405,12 +13405,14 @@ static struct npc_mcam_kex npc_mkex_default = {/* Layer B: Single VLAN (CTAG) */ /* CTAG VLAN[2..3] + Ethertype, 4 bytes, KW0[63:32] */ [NPC_LT_LB_CTAG] = { - KEX_LD_CFG(0x03, 0x0, 0x1, 0x0, 0x4), + KEX_LD_CFG(0x03, 0x2, 0x1, 0x0, 0x4), },
Similarly here some explanation for KEX_LD_CFG would be useful. From what I can tell it seems like this may be some sort of fix as you are adjusting the "hdr_ofs" field from 0 to 2.
drivers/net/ethernet/marvell/octeontx2/af/npc_profile.h static struct npc_mcam_kex npc_mkex_default = { · line 13415
Quoted 8 lines
drivers/net/ethernet/marvell/octeontx2/af/npc_profile.h +4
-2/* Layer B: Stacked VLAN (STAG|QinQ) */ [NPC_LT_LB_STAG_QINQ] = { -/* CTAG VLAN[2..3] + Ethertype, 4 bytes, KW0[63:32] */ - KEX_LD_CFG(0x03, 0x4, 0x1, 0x0, 0x4), + /* Outer VLAN: 2 bytes, KW0[63:48] */ + KEX_LD_CFG(0x01, 0x2, 0x1, 0x0, 0x6), +/* Ethertype: 2 bytes, KW0[47:32] */ + KEX_LD_CFG(0x01, 0x8, 0x1, 0x0, 0x4),
Just to confirm, are you matching up the outer VLAN with the inner Ethertype here? It seems like an odd combination. I assume you need the inner ethertype in order to identify the L3 traffic?
Quoted 5 lines
drivers/net/ethernet/marvell/octeontx2/af/npc_profile.h +0
-0}, [NPC_LT_LB_FDSA] = {/* SWITCH PORT: 1 byte, KW0[63:48] */ @@ -13450,6 +13452,65 @@ static struct npc_mcam_kex npc_mkex_default = { },
drivers/net/ethernet/marvell/octeontx2/af/npc_profile.h static struct npc_mcam_kex npc_mkex_default = { · line 13462
Quoted 10 lines
drivers/net/ethernet/marvell/octeontx2/af/npc_profile.h +8
-0}, }, + + /* Default TX MCAM KEX profile */ + [NIX_INTF_TX] = { + [NPC_LID_LA] = { + /* Layer A: Ethernet: */ + [NPC_LT_LA_IH_NIX_ETHER] = { +/* PF_FUNC: 2B , KW0 [47:32] */ + KEX_LD_CFG(0x01, 0x0, 0x1, 0x0, 0x4),
I'm assuming you have an 8B internal header that is being parsed? A comment explaining that this is parsing a preamble that is at the start of things might be useful.
Quoted 31 lines
drivers/net/ethernet/marvell/octeontx2/af/npc_profile.h +31
-0+/* DMAC: 6 bytes, KW1[63:16] */ + KEX_LD_CFG(0x05, 0x8, 0x1, 0x0, 0xa), + }, + }, + [NPC_LID_LB] = { +/* Layer B: Single VLAN (CTAG) */ + [NPC_LT_LB_CTAG] = { +/* CTAG VLAN[2..3] KW0[63:48] */ +KEX_LD_CFG (0x01 ,0x2 ,0x1 ,0x0 ,0x6 ), +/* CTAG VLAN[2..3] KW1[15:0] */ + KEX_LD_CFG(0x01, 0x4, 0x1, 0x0, 0x8), + }, +/* Layer B: Stacked VLAN (STAG|QinQ) */ + [NPC_LT_LB_STAG_QINQ] = { +/* Outer VLAN: 2 bytes, KW0[63:48] */ +KEX_LD_CFG (0x01 ,0x2 ,0x1 ,0x0 ,0x6 ), +/* Outer VLAN: 2 Bytes, KW1[15:0] */ + KEX_LD_CFG(0x01, 0x8, 0x1, 0x0, 0x8), + }, + }, + [NPC_LID_LC] = { +/* Layer C: IPv4 */ + [NPC_LT_LC_IP] = { +/* SIP+DIP: 8 bytes, KW2[63:0] */ +KEX_LD_CFG (0x07 ,0xc ,0x1 ,0x0 ,0x10 ), +/* TOS: 1 byte, KW1[63:56] */ + KEX_LD_CFG(0x0, 0x1, 0x1, 0x0, 0xf), + }, +/* Layer C: IPv6 */ + [NPC_LT_LC_IP6] = { +/* Everything up to SADDR: 8 bytes, KW2[63:0] */
drivers/net/ethernet/marvell/octeontx2/af/npc_profile.h static struct npc_mcam_kex npc_mkex_default = { · line 13503
Quoted 10 lines
drivers/net/ethernet/marvell/octeontx2/af/npc_profile.h +10
-0+ KEX_LD_CFG(0x07, 0x0, 0x1, 0x0, 0x10), + }, + }, + [NPC_LID_LD] = { +/* Layer D:UDP */ + [NPC_LT_LD_UDP] = { +/* SPORT: 2 bytes, KW3[15:0] */ +KEX_LD_CFG (0x1 ,0x0 ,0x1 ,0x0 ,0x18 ), +/* DPORT: 2 bytes, KW3[31:16] */ + KEX_LD_CFG(0x1, 0x2, 0x1, 0x0, 0x1a),
I am curious why this is being done as two pieces instead of just one. From what I can tell you could just have a single rule that copies the 4 bytes for both ports in one shot and they would end up in the same place wouldn't they?
Quoted 18 lines
drivers/net/ethernet/marvell/octeontx2/af/npc_profile.h +10
-0+ }, + /* Layer D:TCP */ + [NPC_LT_LD_TCP] = { +/* SPORT: 2 bytes, KW3[15:0] */ +KEX_LD_CFG (0x1 ,0x0 ,0x1 ,0x0 ,0x18 ), +/* DPORT: 2 bytes, KW3[31:16] */ + KEX_LD_CFG(0x1, 0x2, 0x1, 0x0, 0x1a), + }, + }, + }, }, };drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +0
-0
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c enum nix_makr_fmt_indexes { · line 61
Quoted 5 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +2
-0@@ -57,6 +57,8 @@ enum nix_makr_fmt_indexes { NIX_MARK_CFG_MAX, }; +#define NIX_TX_PKIND 63ULL +
A comment explaining the magic number would be useful. From what I can tell this looks like a "just turn everything on" sort of config where you are enabling bit flags 0 - 5.
Quoted 17 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +4
-1/* For now considering MC resources needed for broadcast * pkt replication only. i.e 256 HWVFs + 12 PFs. */ @@ -1182,6 +1184,10 @@ int rvu_mbox_handler_nix_lf_alloc(struct rvu *rvu,/* Config Rx pkt length, csum checks and apad enable / disable */ rvu_write64 (rvu, blkaddr,NIX_AF_LFX_RX_CFG (nixlf), req->rx_cfg); +/* Configure pkind for TX parse config, 63 from npc_profile */ + cfg =NIX_TX_PKIND ; +rvu_write64 (rvu, blkaddr,NIX_AF_LFX_TX_PARSE_CFG (nixlf), cfg); + intf =is_afvf (pcifunc) ?NIX_INTF_TYPE_LBK :NIX_INTF_TYPE_CGX ; err =nix_interface_init (rvu, pcifunc, intf, nixlf);if (err) --2.16.5
PATCH v3 2/13 octeontx2-af: Verify MCAM entry channel and PF_FUNC
In reply to Naveen MamindlapalliFrom: Subbaraya Sundeep <[email protected]>
This patch adds support to verify the channel number sent by mailbox requester before writing MCAM entry for Ingress packets. Similarly for Egress packets, verifying the PF_FUNC sent by the mailbox user.
--- drivers/net/ethernet/marvell/octeontx2/af/rvu.c | 4 +- drivers/net/ethernet/marvell/octeontx2/af/rvu.h | 2 + .../net/ethernet/marvell/octeontx2/af/rvu_npc.c | 78 ++++++++++++++++++++++ 3 files changed, 82 insertions(+), 2 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu.c +2 -2
@@ -2642,7 +2642,7 @@ static void rvu_enable_afvf_intr(struct rvu *rvu)#define PCI_DEVID_OCTEONTX2_LBK 0xA061 -static int lbk_get_num_chans (void ) +int rvu_get_num_lbk_chans (void ) {struct pci_dev *pdev;void __iomem *base;
@@ -2677,7 +2677,7 @@ static int rvu_enable_sriov(struct rvu *rvu)return 0 ; } - chans =lbk_get_num_chans (); + chans =rvu_get_num_lbk_chans ();if (chans <0 )return chans;
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +2 -0
@@ -445,6 +445,7 @@ int rvu_get_lf(struct rvu *rvu, struct rvu_block *block, u16 pcifunc, u16 slot);int rvu_lf_reset (struct rvu *rvu,struct rvu_block *block,int lf);int rvu_get_blkaddr (struct rvu *rvu,int blktype,u16 pcifunc);int rvu_poll_reg (struct rvu *rvu,u64 block,u64 offset,u64 mask,bool zero); +int rvu_get_num_lbk_chans (void );/* RVU HW reg validation */ enum regmap_block {
@@ -535,6 +536,7 @@ bool is_npc_intf_tx(u8 intf);bool is_npc_intf_rx (u8 intf);bool is_npc_interface_valid (struct rvu *rvu,u8 intf);int rvu_npc_get_tx_nibble_cfg (struct rvu *rvu,u64 nibble_ena); +int npc_mcam_verify_channel (struct rvu *rvu,u16 pcifunc,u8 intf,u16 channel);#ifdef CONFIG_DEBUG_FS void rvu_dbg_init (struct rvu *rvu);
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c +78 -0
120 lines not on this page · raw message
Signature · 1 line
2.16.5
Re: [PATCH v3 net-next 02/13] octeontx2-af: Verify MCAM entry channel and PF_FUNC
Quoted 8 lines · Naveen Mamindlapalli
From: Subbaraya Sundeep <[email protected]>
This patch adds support to verify the channel number sent by mailbox requester before writing MCAM entry for Ingress packets. Similarly for Egress packets, verifying the
PF_FUNCsent by the mailbox user.
Quoted 4 lines
Signed-off-by Subbaraya Sundeep <[email protected]>Signed-off-by Kiran Kumar K <[email protected]>Signed-off-by Sunil Goutham <[email protected]>Signed-off-by Naveen Mamindlapalli <[email protected]>
One minor nit below. Otherwise looks good to me.
Quoted 162 lines
--- drivers/net/ethernet/marvell/octeontx2/af/rvu.c | 4 +- drivers/net/ethernet/marvell/octeontx2/af/rvu.h | 2 + .../net/ethernet/marvell/octeontx2/af/rvu_npc.c | 78 ++++++++++++++++++++++ 3 files changed, 82 insertions(+), 2 deletions(-)drivers/net/ethernet/marvell/octeontx2/af/rvu.c +2
-2@@ -2642,7 +2642,7 @@ static void rvu_enable_afvf_intr(struct rvu *rvu)#define PCI_DEVID_OCTEONTX2_LBK 0xA061 -static int lbk_get_num_chans (void ) +int rvu_get_num_lbk_chans (void ) {struct pci_dev *pdev;void __iomem *base;@@ -2677,7 +2677,7 @@ static int rvu_enable_sriov(struct rvu *rvu)return 0 ; } - chans =lbk_get_num_chans (); + chans =rvu_get_num_lbk_chans ();if (chans <0 )return chans;drivers/net/ethernet/marvell/octeontx2/af/rvu.h +2
-0@@ -445,6 +445,7 @@ int rvu_get_lf(struct rvu *rvu, struct rvu_block *block, u16 pcifunc, u16 slot);int rvu_lf_reset (struct rvu *rvu,struct rvu_block *block,int lf);int rvu_get_blkaddr (struct rvu *rvu,int blktype,u16 pcifunc);int rvu_poll_reg (struct rvu *rvu,u64 block,u64 offset,u64 mask,bool zero); +int rvu_get_num_lbk_chans (void );/* RVU HW reg validation */ enum regmap_block {@@ -535,6 +536,7 @@ bool is_npc_intf_tx(u8 intf);bool is_npc_intf_rx (u8 intf);bool is_npc_interface_valid (struct rvu *rvu,u8 intf);int rvu_npc_get_tx_nibble_cfg (struct rvu *rvu,u64 nibble_ena); +int npc_mcam_verify_channel (struct rvu *rvu,u16 pcifunc,u8 intf,u16 channel);#ifdef CONFIG_DEBUG_FS void rvu_dbg_init (struct rvu *rvu);drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c +67
-0@@ -28,6 +28,8 @@#define NPC_PARSE_RESULT_DMAC_OFFSET 8#define NPC_HW_TSTAMP_OFFSET 8 +#define NPC_KEX_CHAN_MASK 0xFFFULL +#define NPC_KEX_PF_FUNC_MASK 0xFFFFULLstatic const char def_pfl_name[] ="default" ;@@ -63,6 +65,54 @@ int rvu_npc_get_tx_nibble_cfg(struct rvu *rvu, u64 nibble_ena)return 0 ; } +static int npc_mcam_verify_pf_func (struct rvu *rvu, +struct mcam_entry *entry_data,u8 intf, +u16 pcifunc) +{ +u16 pf_func, pf_func_mask; + +if (is_npc_intf_rx (intf)) +return 0 ; + + pf_func_mask = (entry_data->kw_mask[0 ] >>32 ) & +NPC_KEX_PF_FUNC_MASK ; + pf_func = (entry_data->kw[0 ] >>32 ) &NPC_KEX_PF_FUNC_MASK ; + + pf_func =be16_to_cpu ((__force __be16 )pf_func); +if (pf_func_mask !=NPC_KEX_PF_FUNC_MASK || + ((pf_func & ~RVU_PFVF_FUNC_MASK ) != + (pcifunc & ~RVU_PFVF_FUNC_MASK ))) +return -EINVAL ; + +return 0 ; +} + +int npc_mcam_verify_channel (struct rvu *rvu,u16 pcifunc,u8 intf,u16 channel) +{ +int pf =rvu_get_pf (pcifunc); +u8 cgx_id, lmac_id; +int base =0 , end; + +if (is_npc_intf_tx (intf)) +return 0 ; + +if (is_afvf (pcifunc)) { + end =rvu_get_num_lbk_chans (); +if (end <0 ) +return -EINVAL ; + }else { +rvu_get_cgx_lmac_id (rvu->pf2cgxlmac_map[pf], &cgx_id, &lmac_id); + base =NIX_CHAN_CGX_LMAC_CHX (cgx_id, lmac_id,0x0 ); +/* CGX mapped functions has maximum of 16 channels */ + end =NIX_CHAN_CGX_LMAC_CHX (cgx_id, lmac_id,0xF ); + } + +if (channel < base || channel > end) +return -EINVAL ; + +return 0 ; +} +void rvu_npc_set_pkind (struct rvu *rvu,int pkind,struct rvu_pfvf *pfvf) {int blkaddr;@@ -1935,6 +1985,7 @@ int rvu_mbox_handler_npc_mcam_write_entry(struct rvu *rvu,struct rvu_pfvf *pfvf =rvu_get_pfvf (rvu, req->hdr.pcifunc);struct npc_mcam *mcam = &rvu->hw->mcam;u16 pcifunc = req->hdr.pcifunc; +u16 channel, chan_mask;int blkaddr, rc;u8 nix_intf;@@ -1942,6 +1993,10 @@ int rvu_mbox_handler_npc_mcam_write_entry(struct rvu *rvu,if (blkaddr <0 )return NPC_MCAM_INVALID_REQ ; + chan_mask = req->entry_data.kw_mask[0 ] &NPC_KEX_CHAN_MASK ; + channel = req->entry_data.kw[0 ] &NPC_KEX_CHAN_MASK ; + channel &= chan_mask; +mutex_lock (&mcam->lock); rc =npc_mcam_verify_entry (mcam, pcifunc, req->entry);if (rc)@@ -1963,6 +2018,17 @@ int rvu_mbox_handler_npc_mcam_write_entry(struct rvu *rvu,else nix_intf = pfvf->nix_rx_intf; +if (npc_mcam_verify_channel (rvu, pcifunc, req->intf, channel)) { + rc =NPC_MCAM_INVALID_REQ ; + goto exit; + } + +if (npc_mcam_verify_pf_func (rvu, &req->entry_data, req->intf, + pcifunc)) { + rc =NPC_MCAM_INVALID_REQ ; + goto exit; + } +npc_config_mcam_entry (rvu, mcam, blkaddr, req->entry, nix_intf, &req->entry_data, req->enable_entry);@@ -2299,6 +2365,7 @@ int rvu_mbox_handler_npc_mcam_alloc_and_write_entry(struct rvu *rvu,struct npc_mcam *mcam = &rvu->hw->mcam;u16 entry =NPC_MCAM_ENTRY_INVALID ;u16 cntr =NPC_MCAM_ENTRY_INVALID ; +u16 channel, chan_mask;int blkaddr, rc;u8 nix_intf;
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c int rvu_mbox_handler_npc_mcam_alloc_and_write_entry(struct rvu *rvu, · line 2385
Quoted 10 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c +7
-0@@ -2309,6 +2376,17 @@ int rvu_mbox_handler_npc_mcam_alloc_and_write_entry(struct rvu *rvu,if (!is_npc_interface_valid (rvu, req->intf))return NPC_MCAM_INVALID_REQ ; + chan_mask = req->entry_data.kw_mask[0 ] &NPC_KEX_CHAN_MASK ; + channel = req->entry_data.kw[0 ] &NPC_KEX_CHAN_MASK ; + channel &= chan_mask; + +if (npc_mcam_verify_channel (rvu, req->hdr.pcifunc, req->intf, channel)) +return NPC_MCAM_INVALID_REQ ; +
Why not just move the code for pulling the channel into the npc_mcam_verify_channel function like you did with the pf_func? Then you can avoid declaring variables here that won't be used anywhere else in the function.
Quoted 10 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c +4
-1+if (npc_mcam_verify_pf_func (rvu, &req->entry_data, req->intf, + req->hdr.pcifunc)) +return NPC_MCAM_INVALID_REQ ; +/* Try to allocate a MCAM entry */ entry_req.hdr.pcifunc = req->hdr.pcifunc; entry_req.contig = true; --2.16.5
PATCH v3 3/13 octeontx2-af: Generate key field bit mask from KEX profile
In reply to Naveen MamindlapalliFrom: Subbaraya Sundeep <[email protected]>
Key Extraction(KEX) profile decides how the packet metadata such as layer information and selected packet data bytes at each layer are placed in MCAM search key. This patch reads the configured KEX profile parameters to find out the bit position and bit mask for each field. The information is used when programming the MCAM match data by SW to match a packet flow and take appropriate action on the flow. This patch also verifies the mandatory fields such as channel and DMAC are not overwritten by the KEX configuration of other fields.
--- drivers/net/ethernet/marvell/octeontx2/af/Makefile | 2 +- drivers/net/ethernet/marvell/octeontx2/af/npc.h | 48 ++ drivers/net/ethernet/marvell/octeontx2/af/rvu.h | 38 ++ .../net/ethernet/marvell/octeontx2/af/rvu_npc.c | 11 +- .../net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c | 562 +++++++++++++++++++++ 5 files changed, 658 insertions(+), 3 deletions(-) create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c
drivers/net/ethernet/marvell/octeontx2/af/Makefile +1 -1
@@ -9,4 +9,4 @@ obj-$(CONFIG_OCTEONTX2_AF) += octeontx2_af.o octeontx2_mbox-y := mbox.o rvu_trace.o octeontx2_af-y := cgx.o rvu.o rvu_cgx.o rvu_npa.o rvu_nix.o \ - rvu_reg.o rvu_npc.o rvu_debugfs.o ptp.o + rvu_reg.o rvu_npc.o rvu_debugfs.o ptp.o rvu_npc_fs.o
drivers/net/ethernet/marvell/octeontx2/af/npc.h +48 -0
54 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +38 -0
@@ -15,6 +15,7 @@#include "rvu_struct.h" #include "common.h" #include "mbox.h" +#include "npc.h" /* PCI device IDs */ #define PCI_DEVID_OCTEONTX2_RVU_AF 0xA065
@@ -105,6 +106,36 @@ struct nix_mce_list {int max; }; +/* layer meta data to uniquely identify a packet header field */ +struct npc_layer_mdata { +u8 lid; +u8 ltype; +u8 hdr; +u8 key; +u8 len; +}; + +/* Structure to represent a field present in the +* generated key. A key field may present anywhere and can +* be of any size in the generated key. Once this structure +* is populated for fields of interest then field's presence +* and location (if present) can be known. +*/ +struct npc_key_field { +/* Masks where all set bits indicate position +* of a field in the key +*/ +u64 kw_mask[NPC_MAX_KWS_IN_KEY ]; +/* Number of words in the key a field spans. If a field is +* of 16 bytes and key offset is 4 then the field will use +* 4 bytes in KW0, 8 bytes in KW1 and 4 bytes in KW2 and +* nr_kws will be 3(KW0, KW1 and KW2). +*/ +int nr_kws; +/* used by packet header fields */ +struct npc_layer_mdata layer_mdata; +}; +struct npc_mcam {struct rsrc_bmap counters;struct mutex lock;/* MCAM entries and counters update lock */
@@ -128,6 +159,11 @@ struct npc_mcam {u16 hprio_count;u16 hprio_end;u16 rx_miss_act_cntr;/* Counter for RX MISS action */ +/* fields present in the generated key */ +struct npc_key_field tx_key_fields[NPC_KEY_FIELDS_MAX ]; +struct npc_key_field rx_key_fields[NPC_KEY_FIELDS_MAX ]; +u64 tx_features; +u64 rx_features; };/* Structure for per RVU func info ie PF/VF */
@@ -537,6 +573,8 @@ bool is_npc_intf_rx(u8 intf);bool is_npc_interface_valid (struct rvu *rvu,u8 intf);int rvu_npc_get_tx_nibble_cfg (struct rvu *rvu,u64 nibble_ena);int npc_mcam_verify_channel (struct rvu *rvu,u16 pcifunc,u8 intf,u16 channel); +int npc_flow_steering_init (struct rvu *rvu,int blkaddr); +const char *npc_get_field_name (u8 hdr);#ifdef CONFIG_DEBUG_FS void rvu_dbg_init (struct rvu *rvu);
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c +9 -2
@@ -1400,12 +1400,19 @@ int rvu_npc_init(struct rvu *rvu)rvu_npc_setup_interfaces (rvu, blkaddr); +/* Configure MKEX profile */ +npc_load_mkex_profile (rvu, blkaddr, rvu->mkex_pfl_name); + err =npc_mcam_rsrcs_init (rvu, blkaddr);if (err)return err; -/* Configure MKEX profile */ -npc_load_mkex_profile (rvu, blkaddr, rvu->mkex_pfl_name); + err =npc_flow_steering_init (rvu, blkaddr); +if (err) { +dev_err (rvu->dev, +"Incorrect mkex profile loaded using default mkex\n" ); +npc_load_mkex_profile (rvu, blkaddr, def_pfl_name); + }return 0 ; }
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c new file +562 -0
562 lines not on this page · raw message
Signature · 1 line
2.16.5
Re: [PATCH v3 net-next 03/13] octeontx2-af: Generate key field bit mask from KEX profile
Quoted 12 lines · Naveen Mamindlapalli
From: Subbaraya Sundeep <[email protected]>
Key Extraction(KEX) profile decides how the packet metadata such as layer information and selected packet data bytes at each layer are placed in MCAM search key. This patch reads the configured KEX profile parameters to find out the bit position and bit mask for each field. The information is used when programming the MCAM match data by SW to match a packet flow and take appropriate action on the flow. This patch also verifies the mandatory fields such as channel and DMAC are not overwritten by the KEX configuration of other fields.
Quoted 3 lines
Signed-off-by Subbaraya Sundeep <[email protected]>Signed-off-by Sunil Goutham <[email protected]>Signed-off-by Naveen Mamindlapalli <[email protected]>
A few minor spelling issues, otherwise it looks fine.
Quoted 91 lines
--- drivers/net/ethernet/marvell/octeontx2/af/Makefile | 2 +- drivers/net/ethernet/marvell/octeontx2/af/npc.h | 48 ++ drivers/net/ethernet/marvell/octeontx2/af/rvu.h | 38 ++ .../net/ethernet/marvell/octeontx2/af/rvu_npc.c | 11 +- .../net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c | 562 +++++++++++++++++++++ 5 files changed, 658 insertions(+), 3 deletions(-) create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.cdrivers/net/ethernet/marvell/octeontx2/af/Makefile +1
-1@@ -9,4 +9,4 @@ obj-$(CONFIG_OCTEONTX2_AF) += octeontx2_af.o octeontx2_mbox-y := mbox.o rvu_trace.o octeontx2_af-y := cgx.o rvu.o rvu_cgx.o rvu_npa.o rvu_nix.o \ - rvu_reg.o rvu_npc.o rvu_debugfs.o ptp.o + rvu_reg.o rvu_npc.o rvu_debugfs.o ptp.o rvu_npc_fs.odrivers/net/ethernet/marvell/octeontx2/af/npc.h +48
-0@@ -140,6 +140,54 @@ enum npc_kpu_lh_ltype { NPC_LT_LH_CUSTOM1 = 0xF, }; +/* list of known and supported fields in packet header and +* fields present in key structure. +*/ +enum key_fields { +NPC_DMAC , +NPC_SMAC , +NPC_ETYPE , +NPC_OUTER_VID , +NPC_TOS , +NPC_SIP_IPV4 , +NPC_DIP_IPV4 , +NPC_SIP_IPV6 , +NPC_DIP_IPV6 , +NPC_SPORT_TCP , +NPC_DPORT_TCP , +NPC_SPORT_UDP , +NPC_DPORT_UDP , +NPC_SPORT_SCTP , +NPC_DPORT_SCTP , +NPC_HEADER_FIELDS_MAX , +NPC_CHAN =NPC_HEADER_FIELDS_MAX ,/* Valid when Rx */ +NPC_PF_FUNC ,/* Valid when Tx */ +NPC_ERRLEV , +NPC_ERRCODE , +NPC_LXMB , +NPC_LA , +NPC_LB , +NPC_LC , +NPC_LD , +NPC_LE , +NPC_LF , +NPC_LG , +NPC_LH , +/* ether type for untagged frame */ +NPC_ETYPE_ETHER , +/* ether type for single tagged frame */ +NPC_ETYPE_TAG1 , +/* ether type for double tagged frame */ +NPC_ETYPE_TAG2 , +/* outer vlan tci for single tagged frame */ +NPC_VLAN_TAG1 , +/* outer vlan tci for double tagged frame */ +NPC_VLAN_TAG2 , +/* other header fields programmed to extract but not of our interest */ +NPC_UNKNOWN , +NPC_KEY_FIELDS_MAX , +}; +struct npc_kpu_profile_cam {u8 state;u8 state_mask;drivers/net/ethernet/marvell/octeontx2/af/rvu.h +1
-0@@ -15,6 +15,7 @@#include "rvu_struct.h" #include "common.h" #include "mbox.h" +#include "npc.h" /* PCI device IDs */ #define PCI_DEVID_OCTEONTX2_RVU_AF 0xA065
drivers/net/ethernet/marvell/octeontx2/af/rvu.h struct nix_mce_list { · line 109
Quoted 4 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +1
-0@@ -105,6 +106,36 @@ struct nix_mce_list {int max; }; +/* layer meta data to uniquely identify a packet header field */
s/meta data/metadata/
Quoted 8 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +8
-0+struct npc_layer_mdata { +u8 lid; +u8 ltype; +u8 hdr; +u8 key; +u8 len; +}; +
<snip>
drivers/net/ethernet/marvell/octeontx2/af/rvu.h
Quoted 12 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +12
-0+/* Handle header fields which can come from multiple layers like +* etype, outer vlan tci. These fields should have same position in +* the key otherwise to install a mcam rule more than one entry is +* needed which complicates mcam space management. +*/ + etype_ether = &key_fields[NPC_ETYPE_ETHER ]; + etype_tag1 = &key_fields[NPC_ETYPE_TAG1 ]; + etype_tag2 = &key_fields[NPC_ETYPE_TAG2 ]; + vlan_tag1 = &key_fields[NPC_VLAN_TAG1 ]; + vlan_tag2 = &key_fields[NPC_VLAN_TAG2 ]; + +/* if key profile programmed does not extract ether type at all */
s/ether type/Ethertype/
drivers/net/ethernet/marvell/octeontx2/af/rvu.h
Quoted 4 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +4
-0+if (!etype_ether->nr_kws && !etype_tag1->nr_kws && !etype_tag2->nr_kws) + goto vlan_tci; + +/* if key profile programmed extracts ether type from one layer */
Same issue here and a few other places, replace "ether type" with "Ethertype".
Quoted 6 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +5
-0+if (etype_ether->nr_kws && !etype_tag1->nr_kws && !etype_tag2->nr_kws) + key_fields[NPC_ETYPE ] = *etype_ether; +if (!etype_ether->nr_kws && etype_tag1->nr_kws && !etype_tag2->nr_kws) + key_fields[NPC_ETYPE ] = *etype_tag1; + if (!etype_ether->nr_kws && !etype_tag1->nr_kw
PATCH v3 4/13 octeontx2-af: Add mbox messages to install and delete MCAM rules
In reply to Naveen MamindlapalliFrom: Subbaraya Sundeep <[email protected]>
Added new mailbox messages to install and delete MCAM rules. These mailbox messages will be used for adding/deleting ethtool n-tuple filters by NIX PF. The installed MCAM rules are stored in a list that will be traversed later to delete the MCAM entries when the interface is brought down or when PCIe FLR is received. The delete mailbox supports deleting a single MCAM entry or range of entries or all the MCAM entries owned by the pcifunc. Each MCAM entry can be associated with a HW match stat entry if the mailbox requester wants to check the hit count for debugging.
Modified adding default unicast DMAC match rule using install flow API. The default unicast DMAC match entry installed by Administrative Function is saved and can be changed later by the mailbox user to fit additional fields, or the default MCAM entry rule action can be used for other flow rules installed later.
Modified rvu_mbox_handler_nix_lf_free mailbox to add a flag to disable or delete the MCAM entries. The MCAM entries are disabled when the interface is brought down and deleted in FLR handler. The disabled MCAM entries will be re-enabled when the interface is brought up again.
--- drivers/net/ethernet/marvell/octeontx2/af/common.h | 2 + drivers/net/ethernet/marvell/octeontx2/af/mbox.h | 76 ++- drivers/net/ethernet/marvell/octeontx2/af/npc.h | 57 +- drivers/net/ethernet/marvell/octeontx2/af/rvu.h | 13 + .../net/ethernet/marvell/octeontx2/af/rvu_nix.c | 19 +- .../net/ethernet/marvell/octeontx2/af/rvu_npc.c | 217 ++++++- .../net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c | 721 +++++++++++++++++++++ .../net/ethernet/marvell/octeontx2/nic/otx2_pf.c | 12 +- 8 files changed, 1065 insertions(+), 52 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/common.h +2 -0
@@ -162,6 +162,8 @@ enum nix_scheduler {#define NIX_RX_ACTIONOP_UCAST_IPSEC (0x2ull)#define NIX_RX_ACTIONOP_MCAST (0x3ull)#define NIX_RX_ACTIONOP_RSS (0x4ull) +/* Use the RX action set in the default unicast entry */ +#define NIX_RX_ACTION_DEFAULT (0xfull)/* NIX TX action operation*/ #define NIX_TX_ACTIONOP_DROP (0x0ull)
drivers/net/ethernet/marvell/octeontx2/af/mbox.h +75 -1
97 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/af/npc.h +53 -4
68 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +13 -0
@@ -147,6 +147,7 @@ struct npc_mcam {u16 *entry2cntr_map;u16 *cntr2pfvf_map;u16 *cntr_refcnt; +u16 *entry2target_pffunc;u8 keysize;/* MCAM keysize 112/224/448 bits */ u8 banks;/* Number of MCAM banks */ u8 banks_per_entry;/* Number of keywords in key */
@@ -164,6 +165,7 @@ struct npc_mcam {struct npc_key_field rx_key_fields[NPC_KEY_FIELDS_MAX ];u64 tx_features;u64 rx_features; +struct list_head mcam_rules; };/* Structure for per RVU func info ie PF/VF */
@@ -218,6 +220,8 @@ struct rvu_pfvf {int rxvlan_index;bool rxvlan; +struct rvu_npc_mcam_rule *def_ucast_rule; +bool cgx_in_use;/* this PF/VF using CGX? */ int cgx_users;/* number of cgx users - used only by PFs */
@@ -558,6 +562,7 @@ void rvu_npc_install_bcast_match_entry(struct rvu *rvu, u16 pcifunc,void rvu_npc_enable_bcast_entry (struct rvu *rvu,u16 pcifunc,bool enable);int rvu_npc_update_rxvlan (struct rvu *rvu,u16 pcifunc,int nixlf);void rvu_npc_disable_mcam_entries (struct rvu *rvu,u16 pcifunc,int nixlf); +void rvu_npc_free_mcam_entries (struct rvu *rvu,u16 pcifunc,int nixlf);void rvu_npc_disable_default_entries (struct rvu *rvu,u16 pcifunc,int nixlf);void rvu_npc_enable_default_entries (struct rvu *rvu,u16 pcifunc,int nixlf); void rvu_npc_update_flowkey_alg_idx(struct rvu *rvu, u16 pcifunc, int nixlf,
@@ -575,6 +580,14 @@ int rvu_npc_get_tx_nibble_cfg(struct rvu *rvu, u64 nibble_ena);int npc_mcam_verify_channel (struct rvu *rvu,u16 pcifunc,u8 intf,u16 channel);int npc_flow_steering_init (struct rvu *rvu,int blkaddr);const char *npc_get_field_name (u8 hdr); +bool rvu_npc_write_default_rule (struct rvu *rvu,int blkaddr,int nixlf, +u16 pcifunc,u8 intf,struct mcam_entry *entry, +int *entry_index); +int npc_get_bank (struct npc_mcam *mcam,int index); +void npc_mcam_enable_flows (struct rvu *rvu,u16 target); +void npc_mcam_disable_flows (struct rvu *rvu,u16 target); +void npc_enable_mcam_entry (struct rvu *rvu,struct npc_mcam *mcam, +int blkaddr,int index,bool enable);#ifdef CONFIG_DEBUG_FS void rvu_dbg_init (struct rvu *rvu);
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +12 -7
@@ -304,7 +304,6 @@ static void nix_interface_deinit(struct rvu *rvu, u16 pcifunc, u8 nixlf) pfvf->maxlen =0 ; pfvf->minlen =0 ; - pfvf->rxvlan = false;/* Remove this PF_FUNC from bcast pkt replication list */ err =nix_update_bcast_mce_list (rvu, pcifunc, false);
@@ -1230,7 +1229,7 @@ int rvu_mbox_handler_nix_lf_alloc(struct rvu *rvu,return rc; } -int rvu_mbox_handler_nix_lf_free (struct rvu *rvu,struct msg_req *req, +int rvu_mbox_handler_nix_lf_free (struct rvu *rvu,struct nix_lf_free_req *req,struct msg_rsp *rsp) {struct rvu_hwinfo *hw = rvu->hw;
@@ -1249,6 +1248,11 @@ int rvu_mbox_handler_nix_lf_free(struct rvu *rvu, struct msg_req *req,if (nixlf <0 )return NIX_AF_ERR_AF_LF_INVALID ; +if (req->flags &NIX_LF_DISABLE_FLOWS ) +rvu_npc_disable_mcam_entries (rvu, pcifunc, nixlf); +else +rvu_npc_free_mcam_entries (rvu, pcifunc, nixlf); +nix_interface_deinit (rvu, pcifunc, nixlf);/* Reset this NIX LF */
@@ -2764,8 +2768,6 @@ int rvu_mbox_handler_nix_set_mac_addr(struct rvu *rvu,rvu_npc_install_ucast_entry (rvu, pcifunc, nixlf, pfvf->rx_chan_base, req->mac_addr); -rvu_npc_update_rxvlan (rvu, pcifunc, nixlf); -return 0 ; }
@@ -2812,9 +2814,6 @@ int rvu_mbox_handler_nix_set_rx_mode(struct rvu *rvu, struct nix_rx_mode *req,else rvu_npc_install_promisc_entry (rvu, pcifunc, nixlf, pfvf->rx_chan_base, allmulti); - -rvu_npc_update_rxvlan (rvu, pcifunc, nixlf); -return 0 ; }
@@ -3378,6 +3377,8 @@ int rvu_mbox_handler_nix_lf_start_rx(struct rvu *rvu, struct msg_req *req,rvu_npc_enable_default_entries (rvu, pcifunc, nixlf); +npc_mcam_enable_flows (rvu, pcifunc); +return rvu_cgx_start_stop_io (rvu, pcifunc, true); }
@@ -3393,6 +3394,8 @@ int rvu_mbox_handler_nix_lf_stop_rx(struct rvu *rvu, struct msg_req *req,rvu_npc_disable_default_entries (rvu, pcifunc, nixlf); +npc_mcam_disable_flows (rvu, pcifunc); +return rvu_cgx_start_stop_io (rvu, pcifunc, false); }
@@ -3405,6 +3408,8 @@ void rvu_nix_lf_teardown(struct rvu *rvu, u16 pcifunc, int blkaddr, int nixlf) ctx_req.hdr.pcifunc = pcifunc;/* Cleanup NPC MCAM entries, free Tx scheduler queues being used */ +rvu_npc_disable_mcam_entries (rvu, pcifunc, nixlf); +rvu_npc_free_mcam_entries (rvu, pcifunc, nixlf);nix_interface_deinit (rvu, pcifunc, nixlf);nix_rx_sync (rvu, blkaddr);nix_txschq_free (rvu, pcifunc);
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c +181 -36
333 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c +721 -0
726 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +8 -4
@@ -1278,6 +1278,7 @@ static void otx2_free_sq_res(struct otx2_nic *pf)static int otx2_init_hw_resources (struct otx2_nic *pf) { +struct nix_lf_free_req *free_req;struct mbox *mbox = &pf->mbox;struct otx2_hw *hw = &pf->hw;struct msg_req *req;
@@ -1359,8 +1360,9 @@ static int otx2_init_hw_resources(struct otx2_nic *pf)otx2_aura_pool_free (pf); err_free_nix_lf:mutex_lock (&mbox->lock); - req =otx2_mbox_alloc_msg_nix_lf_free (mbox); -if (req) { + free_req =otx2_mbox_alloc_msg_nix_lf_free (mbox); +if (free_req) { + free_req->flags =NIX_LF_DISABLE_FLOWS ;if (otx2_sync_mbox_msg (mbox))dev_err (pf->dev,"%s failed to free nixlf\n" , __func__); }
@@ -1379,6 +1381,7 @@ static int otx2_init_hw_resources(struct otx2_nic *pf)static void otx2_free_hw_resources (struct otx2_nic *pf) {struct otx2_qset *qset = &pf->qset; +struct nix_lf_free_req *free_req;struct mbox *mbox = &pf->mbox;struct otx2_cq_queue *cq;struct msg_req *req;
@@ -1419,8 +1422,9 @@ static void otx2_free_hw_resources(struct otx2_nic *pf)mutex_lock (&mbox->lock);/* Reset NIX LF */ - req =otx2_mbox_alloc_msg_nix_lf_free (mbox); -if (req) { + free_req =otx2_mbox_alloc_msg_nix_lf_free (mbox); +if (free_req) { + free_req->flags =NIX_LF_DISABLE_FLOWS ;if (otx2_sync_mbox_msg (mbox))dev_err (pf->dev,"%s failed to free nixlf\n" , __func__); }
Signature · 1 line
2.16.5
Re: [PATCH v3 net-next 04/13] octeontx2-af: Add mbox messages to install and delete MCAM rules
Quoted 25 lines · Naveen Mamindlapalli
From: Subbaraya Sundeep <[email protected]>
Added new mailbox messages to install and delete MCAM rules. These mailbox messages will be used for adding/deleting ethtool n-tuple filters by NIX PF. The installed MCAM rules are stored in a list that will be traversed later to delete the MCAM entries when the interface is brought down or when PCIe FLR is received. The delete mailbox supports deleting a single MCAM entry or range of entries or all the MCAM entries owned by the pcifunc. Each MCAM entry can be associated with a HW match stat entry if the mailbox requester wants to check the hit count for debugging.
Modified adding default unicast DMAC match rule using install flow API. The default unicast DMAC match entry installed by Administrative Function is saved and can be changed later by the mailbox user to fit additional fields, or the default MCAM entry rule action can be used for other flow rules installed later.
Modified
rvu_mbox_handler_nix_lf_freemailbox to add a flag to disable or delete the MCAM entries. The MCAM entries are disabled when the interface is brought down and deleted in FLR handler. The disabled MCAM entries will be re-enabled when the interface is brought up again.
Quoted 3 lines
Signed-off-by Subbaraya Sundeep <[email protected]>Signed-off-by Sunil Goutham <[email protected]>Signed-off-by Naveen Mamindlapalli <[email protected]>
A couple minor issues to address, called out in comments below.
Quoted 11 lines
--- drivers/net/ethernet/marvell/octeontx2/af/common.h | 2 + drivers/net/ethernet/marvell/octeontx2/af/mbox.h | 76 ++- drivers/net/ethernet/marvell/octeontx2/af/npc.h | 57 +- drivers/net/ethernet/marvell/octeontx2/af/rvu.h | 13 + .../net/ethernet/marvell/octeontx2/af/rvu_nix.c | 19 +- .../net/ethernet/marvell/octeontx2/af/rvu_npc.c | 217 ++++++- .../net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c | 721 +++++++++++++++++++++ .../net/ethernet/marvell/octeontx2/nic/otx2_pf.c | 12 +- 8 files changed, 1065 insertions(+), 52 deletions(-)
<snip>
Quoted 79 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c +43
-3@@ -219,7 +219,7 @@ static int npc_get_nixlf_mcam_index(struct npc_mcam *mcam,return npc_get_ucast_mcam_index (mcam, pcifunc, nixlf); } -static int npc_get_bank (struct npc_mcam *mcam,int index) +int npc_get_bank (struct npc_mcam *mcam,int index) {int bank = index / mcam->banksize;@@ -241,8 +241,8 @@ static bool is_mcam_entry_enabled(struct rvu *rvu, struct npc_mcam *mcam,return (cfg &1 ); } -static void npc_enable_mcam_entry (struct rvu *rvu,struct npc_mcam *mcam, -int blkaddr,int index,bool enable) +void npc_enable_mcam_entry (struct rvu *rvu,struct npc_mcam *mcam, +int blkaddr,int index,bool enable) {int bank =npc_get_bank (mcam, index);int actbank = bank;@@ -359,6 +359,41 @@ static void npc_get_keyword(struct mcam_entry *entry, int idx, *cam0 = ~*cam1 & kw_mask; } +static void npc_get_default_entry_action (struct rvu *rvu,struct npc_mcam *mcam, +int blkaddr,int index, +struct mcam_entry *entry) +{ +u16 owner, target_func; +struct rvu_pfvf *pfvf; +int bank, nixlf; +u64 rx_action; + + owner = mcam->entry2pfvf_map[index]; + target_func = (entry->action >>4 ) &0xffff ; +/* return incase target is PF or LBK or rule owner is not PF */ +if (is_afvf (target_func) || (owner &RVU_PFVF_FUNC_MASK ) || + !(target_func &RVU_PFVF_FUNC_MASK )) +return ; + + pfvf =rvu_get_pfvf (rvu, target_func); + mcam->entry2target_pffunc[index] = target_func; +/* return if nixlf is not attached or initialized */ +if (!is_nixlf_attached (rvu, target_func) || !pfvf->def_ucast_rule) +return ; + +/* get VF ucast entry rule */ +nix_get_nixlf (rvu, target_func, &nixlf,NULL ); + index =npc_get_nixlf_mcam_index (mcam, target_func, + nixlf,NIXLF_UCAST_ENTRY ); + bank =npc_get_bank (mcam, index); + index &= (mcam->banksize -1 ); + + rx_action =rvu_read64 (rvu, blkaddr, +NPC_AF_MCAMEX_BANKX_ACTION (index, bank)); +if (rx_action) + entry->action = rx_action; +} +static void npc_config_mcam_entry (struct rvu *rvu,struct npc_mcam *mcam,int blkaddr,int index,u8 intf,struct mcam_entry *entry,bool enable)@@ -406,6 +441,11 @@ static void npc_config_mcam_entry(struct rvu *rvu, struct npc_mcam *mcam, NPC_AF_MCAMEX_BANKX_CAMX_W1(index, bank, 0), cam0); } +/* copy VF default entry action to the VF mcam entry */ +if (intf ==NIX_INTF_RX && actindex < mcam->bmap_entries) +npc_get_default_entry_action (rvu, mcam, blkaddr, actindex, + entry); +/* Set 'action' */ rvu_write64 (rvu, blkaddr,NPC_AF_MCAMEX_BANKX_ACTION (index, actbank), entry->action);
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c void rvu_npc_install_ucast_entry(struct rvu *rvu, u16 pcifunc, · line 516
Quoted 4 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c +1
-0@@ -473,11 +513,12 @@ void rvu_npc_install_ucast_entry(struct rvu *rvu, u16 pcifunc, int nixlf, u64 chan, u8 *mac_addr) { struct rvu_pfvf *pfvf = rvu_get_pfvf(rvu, pcifunc); +u8 mac_mask[] = { [0 ...ETH_ALEN ] =0xFF };
Is this supposed to be a 7 byte long array? I assume that is what is meant by the 0 ... ETH_ALEN which would imply it covers entries 0 - 6. This might be better as:
u8 mac_mask[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c void rvu_npc_install_ucast_entry(struct rvu *rvu, u16 pcifunc, · line 519
Quoted 3 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c +2
-0+struct npc_install_flow_req req = {0 }; +struct npc_install_flow_rsp rsp = {0 };struct npc_mcam *mcam = &rvu->hw->mcam;
Since the mcam line is longer normally it should be before the 2 new lines in order to maintain the reverse xmas tree format.
Quoted 33 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c +1
-14-struct mcam_entry entry = { {0 } };struct nix_rx_action action; -int blkaddr, index, kwi; -u64 mac =0 ; +int blkaddr, index;/* AF's VFs work in promiscuous mode */ if (is_afvf (pcifunc))@@ -487,20 +528,9 @@ void rvu_npc_install_ucast_entry(struct rvu *rvu, u16 pcifunc,if (blkaddr <0 )return ; -for (index =ETH_ALEN -1 ; index >=0 ; index--) - mac |= ((u64)*mac_addr++) << (8 * index); - index =npc_get_nixlf_mcam_index (mcam, pcifunc, nixlf,NIXLF_UCAST_ENTRY ); -/* Match ingress channel and DMAC */ - entry.kw[0 ] = chan; - entry.kw_mask[0 ] =0xFFFULL ; - - kwi =NPC_PARSE_RESULT_DMAC_OFFSET /sizeof (u64); - entry.kw[kwi] = mac; - entry.kw_mask[kwi] =BIT_ULL (48 ) -1 ; -/* Don't change the action if entry is already enabled * Otherwise RSS action may get overwritten. */ @@ -513,20 +543,20 @@ void rvu_npc_install_ucast_entry(struct rvu *rvu, u16 pcifunc, action.pf_func = pcifunc; }
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c void rvu_npc_install_ucast_entry(struct rvu *rvu, u16 pcifunc, · line 548
Quoted 10 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c +3
-7- entry.action = *(u64 *)&action; -npc_config_mcam_entry (rvu, mcam, blkaddr, index, - pfvf->nix_rx_intf, &entry, true); - -/* add VLAN matching, setup action and save entry back for later */ - entry.kw[0 ] |= (NPC_LT_LB_STAG_QINQ |NPC_LT_LB_CTAG ) <<20 ; - entry.kw_mask[0 ] |= (NPC_LT_LB_STAG_QINQ &NPC_LT_LB_CTAG ) <<20 ; + req.default_rule =1 ; +ether_addr_copy (req.packet.dmac, mac_addr); +ether_addr_copy (req.mask.dmac, mac_mask);
If this is all you were using the mac_mask for you could probably just use a memset here to achieve the same thing and save yourself the trouble of allocating the mac_mask. See eth_broadcast_addr().
Quoted 19 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c +10
-6+ req.features =BIT_ULL (NPC_DMAC ); + req.channel = chan; + req.intf = pfvf->nix_rx_intf; + req.op = action.op; + req.hdr.pcifunc =0 ;/* AF is requester */ + req.vf = action.pf_func; + req.index = action.index; + req.match_id = action.match_id; + req.flow_key_alg = action.flow_key_alg; - entry.vtag_action =VTAG0_VALID_BIT | -FIELD_PREP (VTAG0_TYPE_MASK ,0 ) | -FIELD_PREP (VTAG0_LID_MASK ,NPC_LID_LA ) | -FIELD_PREP (VTAG0_RELPTR_MASK ,12 ); - -memcpy (&pfvf->entry, &entry,sizeof (entry)); +rvu_mbox_handler_npc_install_flow (rvu, &req, &rsp); }
<snip>
Quoted 15 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c +15
-0+static void npc_update_flow (struct rvu *rvu,struct mcam_entry *entry, +u64 features,struct flow_msg *pkt, +struct flow_msg *mask, +struct rvu_npc_mcam_rule *output,u8 intf) +{ +u64 dmac_mask =ether_addr_to_u64 (mask->dmac); +u64 smac_mask =ether_addr_to_u64 (mask->smac); +u64 dmac_val =ether_addr_to_u64 (pkt->dmac); +u64 smac_val =ether_addr_to_u64 (pkt->smac); +struct flow_msg *opkt = &output->packet; +struct flow_msg *omask = &output->mask; + +if (!features) +return ; +
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c
Quoted 10 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c +10
-0+#define NPC_WRITE_FLOW (field, member, val_lo, val_hi, mask_lo, mask_hi) \ +do { \ + if (features & BIT_ULL((field))) { \ + npc_update_entry(rvu, (field), entry, (val_lo), (val_hi), \ + (mask_lo), (mask_hi), intf); \ + memcpy(&opkt->member, &pkt->member, sizeof(pkt->member)); \ + memcpy(&omask->member, &mask->member, sizeof(mask->member)); \ + } \ +} while (0) +
The placement of this macro seems wierd to me. Either it needs to be boe moved before the function declaration, or it should be defined where it is used instead of this block above it.
Quoted 43 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c +43
-0+/* For tcp/udp/sctp LTYPE should be present in entry */ +if (features & (BIT_ULL (NPC_SPORT_TCP ) |BIT_ULL (NPC_DPORT_TCP ))) +npc_update_entry (rvu,NPC_LD , entry,NPC_LT_LD_TCP , +0 , ~0ULL ,0 , intf); +if (features & (BIT_ULL (NPC_SPORT_UDP ) |BIT_ULL (NPC_DPORT_UDP ))) +npc_update_entry (rvu,NPC_LD , entry,NPC_LT_LD_UDP , +0 , ~0ULL ,0 , intf); +if (features & (BIT_ULL (NPC_SPORT_SCTP ) |BIT_ULL (NPC_DPORT_SCTP ))) +npc_update_entry (rvu,NPC_LD , entry,NPC_LT_LD_SCTP , +0 , ~0ULL ,0 , intf); + +if (features &BIT_ULL (NPC_OUTER_VID )) +npc_update_entry (rvu,NPC_LB , entry, +NPC_LT_LB_STAG_QINQ |NPC_LT_LB_CTAG ,0 , +NPC_LT_LB_STAG_QINQ &NPC_LT_LB_CTAG ,0 , intf); + +NPC_WRITE_FLOW (NPC_DMAC , dmac, dmac_val,0 , dmac_mask,0 ); +NPC_WRITE_FLOW (NPC_SMAC , smac, smac_val,0 , smac_mask,0 ); +NPC_WRITE_FLOW (NPC_ETYPE , etype,ntohs (pkt->etype),0 , +ntohs (mask->etype),0 ); +NPC_WRITE_FLOW (NPC_SIP_IPV4 , ip4src,ntohl (pkt->ip4src),0 , +ntohl (mask->ip4src),0 ); +NPC_WRITE_FLOW (NPC_DIP_IPV4 , ip4dst,ntohl (pkt->ip4dst),0 , +ntohl (mask->ip4dst),0 ); +NPC_WRITE_FLOW (NPC_SPORT_TCP , sport,ntohs (pkt->sport),0 , +ntohs (mask->sport),0 ); +NPC_WRITE_FLOW (NPC_SPORT_UDP , sport,ntohs (pkt->sport),0 , +ntohs (mask->sport),0 ); +NPC_WRITE_FLOW (NPC_DPORT_TCP , dport,ntohs (pkt->dport),0 , +ntohs (mask->dport),0 ); +NPC_WRITE_FLOW (NPC_DPORT_UDP , dport,ntohs (pkt->dport),0 , +ntohs (mask->dport),0 ); +NPC_WRITE_FLOW (NPC_SPORT_SCTP , sport,ntohs (pkt->sport),0 , +ntohs (mask->sport),0 ); +NPC_WRITE_FLOW (NPC_DPORT_SCTP , dport,ntohs (pkt->dport),0 , +ntohs (mask->dport),0 ); + +NPC_WRITE_FLOW (NPC_OUTER_VID , vlan_tci,ntohs (pkt->vlan_tci),0 , +ntohs (mask->vlan_tci),0 ); + +npc_update_ipv6_flow (rvu, entry, features, pkt, mask, output, intf); +} +
PATCH v3 5/13 octeontx2-pf: Add support for ethtool ntuple filters
In reply to Naveen MamindlapalliFrom: Subbaraya Sundeep <[email protected]>
This patch adds support for adding and deleting ethtool ntuple filters. The filters for ether, ipv4, ipv6, tcp, udp and sctp are supported. The mask is also supported. The supported actions are drop and direct to a queue. Additionally we support FLOW_EXT field vlan_tci and FLOW_MAC_EXT.
The NIX PF will allocate total 32 MCAM entries for the use of ethtool ntuple filters. The Administrative Function(AF) will install/delete the MCAM rules when NIX PF sends mailbox message to install/delete the ntuple filters.
Ethtool ntuple filters support is restricted to PFs as of now and PF can install ntuple filters to direct the traffic to its VFs. Hence added a separate callback for VFs to get/set RSS configuration.
--- .../net/ethernet/marvell/octeontx2/nic/Makefile | 2 +- .../ethernet/marvell/octeontx2/nic/otx2_common.h | 31 ++ .../ethernet/marvell/octeontx2/nic/otx2_ethtool.c | 58 +- .../ethernet/marvell/octeontx2/nic/otx2_flows.c | 603 +++++++++++++++++++++ .../net/ethernet/marvell/octeontx2/nic/otx2_pf.c | 18 +- 5 files changed, 707 insertions(+), 5 deletions(-) create mode 100644 drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c
drivers/net/ethernet/marvell/octeontx2/nic/Makefile +1 -1
@@ -7,7 +7,7 @@ obj-$(CONFIG_OCTEONTX2_PF) += octeontx2_nicpf.o obj-$(CONFIG_OCTEONTX2_VF) += octeontx2_nicvf.o octeontx2_nicpf-y := otx2_pf.o otx2_common.o otx2_txrx.o otx2_ethtool.o \ - otx2_ptp.o + otx2_ptp.o otx2_flows.o octeontx2_nicvf-y := otx2_vf.o ccflags-y += -I$(srctree)/drivers/net/ethernet/marvell/octeontx2/af
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +31 -0
@@ -18,6 +18,7 @@#include <linux/timecounter.h> #include <mbox.h> +#include <npc.h> #include "otx2_reg.h" #include "otx2_txrx.h" #include <rvu_trace.h>
@@ -228,6 +229,16 @@ struct otx2_ptp {#define OTX2_HW_TIMESTAMP_LEN 8 +struct otx2_flow_config { +u16 entry[NPC_MAX_NONCONTIG_ENTRIES ]; +u32 nr_flows; +#define OTX2_MAX_NTUPLE_FLOWS 32 +#define OTX2_MCAM_COUNT OTX2_MAX_NTUPLE_FLOWS +u32 ntuple_offset; +u32 ntuple_max_flows; +struct list_head flow_list; +}; +struct otx2_nic {void __iomem *reg_base;struct net_device *netdev;
@@ -238,6 +249,8 @@ struct otx2_nic {#define OTX2_FLAG_RX_TSTAMP_ENABLED BIT_ULL(0)#define OTX2_FLAG_TX_TSTAMP_ENABLED BIT_ULL(1)#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_RX_PAUSE_ENABLED BIT_ULL(9)#define OTX2_FLAG_TX_PAUSE_ENABLED BIT_ULL(10)u64 flags;
@@ -275,6 +288,8 @@ struct otx2_nic {struct otx2_ptp *ptp;struct hwtstamp_config tstamp; + +struct otx2_flow_config *flow_cfg; };static inline bool is_otx2_lbkvf (struct pci_dev *pdev)
@@ -644,4 +659,20 @@ int otx2_open(struct net_device *netdev);int otx2_stop (struct net_device *netdev);int otx2_set_real_num_queues (struct net_device *netdev,int tx_queues,int rx_queues); +/* MCAM filter related APIs */ +int otx2_mcam_flow_init (struct otx2_nic *pf); +int otx2_alloc_mcam_entries (struct otx2_nic *pfvf); +void otx2_mcam_flow_del (struct otx2_nic *pf); +int otx2_destroy_ntuple_flows (struct otx2_nic *pf); +int otx2_destroy_mcam_flows (struct otx2_nic *pfvf); +int otx2_get_flow (struct otx2_nic *pfvf, +struct ethtool_rxnfc *nfc,u32 location); +int otx2_get_all_flows (struct otx2_nic *pfvf, +struct ethtool_rxnfc *nfc,u32 *rule_locs); +int otx2_add_flow (struct otx2_nic *pfvf, +struct ethtool_rx_flow_spec *fsp); +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); +#endif /* OTX2_COMMON_H */
drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c +56 -2
76 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c new file +603 -0
603 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +16 -2
@@ -1733,7 +1733,6 @@ static void otx2_do_set_rx_mode(struct work_struct *work) req->mode =NIX_RX_MODE_UCAST ; -/* We don't support MAC address filtering yet */ if (netdev->flags &IFF_PROMISC ) req->mode |=NIX_RX_MODE_PROMISC ;else if (netdev->flags & (IFF_ALLMULTI |IFF_MULTICAST ))
@@ -1747,11 +1746,16 @@ static int otx2_set_features(struct net_device *netdev, netdev_features_t features) {netdev_features_t changed = features ^ netdev->features; +bool ntuple = !!(features &NETIF_F_NTUPLE );struct otx2_nic *pf =netdev_priv (netdev);if ((changed &NETIF_F_LOOPBACK ) &&netif_running (netdev))return otx2_cgx_config_loopback (pf, features &NETIF_F_LOOPBACK ); + +if ((changed &NETIF_F_NTUPLE ) && !ntuple) +otx2_destroy_ntuple_flows (pf); +return 0 ; }
@@ -2114,6 +2118,13 @@ static int otx2_probe(struct pci_dev *pdev, const struct pci_device_id *id) netdev->hw_features |=NETIF_F_LOOPBACK |NETIF_F_RXALL ; + err =otx2_mcam_flow_init (pf); +if (err) + goto err_ptp_destroy; + +if (pf->flags &OTX2_FLAG_NTUPLE_SUPPORT ) + netdev->hw_features |=NETIF_F_NTUPLE ; + netdev->gso_max_segs =OTX2_MAX_GSO_SEGS ; netdev->watchdog_timeo =OTX2_TX_TIMEOUT ;
@@ -2126,7 +2137,7 @@ static int otx2_probe(struct pci_dev *pdev, const struct pci_device_id *id) err =register_netdev (netdev);if (err) {dev_err (dev,"Failed to register netdevice\n" ); - goto err_ptp_destroy; + goto err_del_mcam_entries; } err =otx2_wq_init (pf);
@@ -2146,6 +2157,8 @@ static int otx2_probe(struct pci_dev *pdev, const struct pci_device_id *id) err_unreg_netdev:unregister_netdev (netdev); +err_del_mcam_entries: +otx2_mcam_flow_del (pf); err_ptp_destroy:otx2_ptp_destroy (pf); err_detach_rsrc:
@@ -2304,6 +2317,7 @@ static void otx2_remove(struct pci_dev *pdev)destroy_workqueue (pf->otx2_wq);otx2_ptp_destroy (pf); +otx2_mcam_flow_del (pf);otx2_detach_resources (&pf->mbox);otx2_disable_mbox_intr (pf);otx2_pfaf_mbox_destroy (pf);
Signature · 1 line
2.16.5
PATCH v3 6/13 octeontx2-pf: Add support for unicast MAC address filtering
In reply to Naveen MamindlapalliFrom: Hariprasad Kelam <[email protected]>
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.
--- .../ethernet/marvell/octeontx2/nic/otx2_common.h | 15 ++- .../ethernet/marvell/octeontx2/nic/otx2_flows.c | 120 ++++++++++++++++++++- .../net/ethernet/marvell/octeontx2/nic/otx2_pf.c | 15 ++- 3 files changed, 143 insertions(+), 7 deletions(-)
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +14 -1
@@ -229,12 +229,21 @@ 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;#define OTX2_MAX_NTUPLE_FLOWS 32 -#define OTX2_MCAM_COUNT OTX2_MAX_NTUPLE_FLOWS +#define OTX2_MAX_UNICAST_FLOWS 8 +#define OTX2_MCAM_COUNT (OTX2_MAX_NTUPLE_FLOWS + \ + OTX2_MAX_UNICAST_FLOWS)u32 ntuple_offset; +u32 unicast_offset;u32 ntuple_max_flows;struct list_head flow_list; };
@@ -251,6 +260,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;
@@ -279,6 +289,7 @@ struct otx2_nic {struct refill_work *refill_wrk;struct workqueue_struct *otx2_wq;struct work_struct rx_mode_work; +struct otx2_mac_table *mac_table;/* Ethtool stuff */ u32 msg_enable;
@@ -674,5 +685,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 */
drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c +115 -5
141 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +14 -1
@@ -1720,10 +1720,20 @@ static void otx2_do_set_rx_mode(struct work_struct *work) struct otx2_nic *pf = container_of(work, struct otx2_nic, rx_mode_work);struct net_device *netdev = pf->netdev;struct nix_rx_mode *req; +bool promisc = false;if (!(netdev->flags &IFF_UP ))return ; +if ((netdev->flags &IFF_PROMISC ) || + (netdev_uc_count (netdev) >OTX2_MAX_UNICAST_FLOWS )) { + promisc = true; + } + +/* Write unicast address to mcam entries or del from mcam */ +if (!promisc && 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) {
@@ -1733,7 +1743,7 @@ static void otx2_do_set_rx_mode(struct work_struct *work) req->mode =NIX_RX_MODE_UCAST ; -if (netdev->flags &IFF_PROMISC ) +if (promisc) req->mode |=NIX_RX_MODE_PROMISC ;else if (netdev->flags & (IFF_ALLMULTI |IFF_MULTICAST )) req->mode |=NIX_RX_MODE_ALLMULTI ;
@@ -2125,6 +2135,9 @@ static int otx2_probe(struct pci_dev *pdev, const struct pci_device_id *id)if (pf->flags &OTX2_FLAG_NTUPLE_SUPPORT ) netdev->hw_features |=NETIF_F_NTUPLE ; +if (pf->flags &OTX2_FLAG_UCAST_FLTR_SUPPORT ) + netdev->priv_flags |=IFF_UNICAST_FLT ; + netdev->gso_max_segs =OTX2_MAX_GSO_SEGS ; netdev->watchdog_timeo =OTX2_TX_TIMEOUT ;
Signature · 1 line
2.16.5
PATCH v3 7/13 octeontx2-af: Add debugfs entry to dump the MCAM rules
In reply to Naveen MamindlapalliFrom: Subbaraya Sundeep <[email protected]>
Add debugfs support to dump the MCAM rules installed using NPC_INSTALL_FLOW mbox message. Debugfs file can display mcam entry, counter if any, flow type and counter hits.
Ethtool will dump the ntuple flows related to the PF only. The debugfs file gives systemwide view of the MCAM rules installed by all the PF's.
Below is the example output when the debugfs file is read:
~ # mount -t debugfs none /sys/kernel/debug
~ # cat /sys/kernel/debug/octeontx2/npc/mcam_rules
Installed by: PF1
direction: RX
mcam entry: 227
udp source port 23 mask 0xffff
Forward to: PF1 VF0
action: Direct to queue 0
enabled: yes
counter: 1
hits: 0--- .../ethernet/marvell/octeontx2/af/rvu_debugfs.c | 197 +++++++++++++++++++++ 1 file changed, 197 insertions(+)
drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c +197 -0
@@ -1770,6 +1770,198 @@ static int rvu_dbg_npc_rx_miss_stats_display(struct seq_file *filp,RVU_DEBUG_SEQ_FOPS (npc_rx_miss_act, npc_rx_miss_stats_display,NULL ); +static void rvu_dbg_npc_mcam_show_flows (struct seq_file *s, +struct rvu_npc_mcam_rule *rule) +{ +u8 bit; + +for_each_set_bit (bit, (unsigned long *)&rule->features,64 ) { +seq_printf (s,"\t%s " ,npc_get_field_name (bit)); +switch (bit) { +case NPC_DMAC : +seq_printf (s,"%pM " , rule->packet.dmac); +seq_printf (s,"mask %pM\n" , rule->mask.dmac); +break ; +case NPC_SMAC : +seq_printf (s,"%pM " , rule->packet.smac); +seq_printf (s,"mask %pM\n" , rule->mask.smac); +break ; +case NPC_ETYPE : +seq_printf (s,"0x%x " ,ntohs (rule->packet.etype)); +seq_printf (s,"mask 0x%x\n" ,ntohs (rule->mask.etype)); +break ; +case NPC_OUTER_VID : +seq_printf (s,"%d " ,ntohs (rule->packet.vlan_tci)); +seq_printf (s,"mask 0x%x\n" , +ntohs (rule->mask.vlan_tci)); +break ; +case NPC_TOS : +seq_printf (s,"%d " , rule->packet.tos); +seq_printf (s,"mask 0x%x\n" , rule->mask.tos); +break ; +case NPC_SIP_IPV4 : +seq_printf (s,"%pI4 " , &rule->packet.ip4src); +seq_printf (s,"mask %pI4\n" , &rule->mask.ip4src); +break ; +case NPC_DIP_IPV4 : +seq_printf (s,"%pI4 " , &rule->packet.ip4dst); +seq_printf (s,"mask %pI4\n" , &rule->mask.ip4dst); +break ; +case NPC_SIP_IPV6 : +seq_printf (s,"%pI6 " , rule->packet.ip6src); +seq_printf (s,"mask %pI6\n" , rule->mask.ip6src); +break ; +case NPC_DIP_IPV6 : +seq_printf (s,"%pI6 " , rule->packet.ip6dst); +seq_printf (s,"mask %pI6\n" , rule->mask.ip6dst); +break ; +case NPC_SPORT_TCP : +case NPC_SPORT_UDP : +case NPC_SPORT_SCTP : +seq_printf (s,"%d " ,ntohs (rule->packet.sport)); +seq_printf (s,"mask 0x%x\n" ,ntohs (rule->mask.sport)); +break ; +case NPC_DPORT_TCP : +case NPC_DPORT_UDP : +case NPC_DPORT_SCTP : +seq_printf (s,"%d " ,ntohs (rule->packet.dport)); +seq_printf (s,"mask 0x%x\n" ,ntohs (rule->mask.dport)); +break ; +default : +break ; + } + } +} + +static void rvu_dbg_npc_mcam_show_action (struct seq_file *s, +struct rvu_npc_mcam_rule *rule) +{ +if (rule->intf ==NIX_INTF_TX ) { +switch (rule->tx_action.op) { +case NIX_TX_ACTIONOP_DROP : +seq_puts (s,"\taction: Drop\n" ); +break ; +case NIX_TX_ACTIONOP_UCAST_DEFAULT : +seq_puts (s,"\taction: Unicast to default channel\n" ); +break ; +case NIX_TX_ACTIONOP_UCAST_CHAN : +seq_printf (s,"\taction: Unicast to channel %d\n" , + rule->tx_action.index); +break ; +case NIX_TX_ACTIONOP_MCAST : +seq_puts (s,"\taction: Multicast\n" ); +break ; +case NIX_TX_ACTIONOP_DROP_VIOL : +seq_puts (s,"\taction: Lockdown Violation Drop\n" ); +break ; +default : +break ; + }; + }else { +switch (rule->rx_action.op) { +case NIX_RX_ACTIONOP_DROP : +seq_puts (s,"\taction: Drop\n" ); +break ; +case NIX_RX_ACTIONOP_UCAST : +seq_printf (s,"\taction: Direct to queue %d\n" , + rule->rx_action.index); +break ; +case NIX_RX_ACTIONOP_RSS : +seq_puts (s,"\taction: RSS\n" ); +break ; +case NIX_RX_ACTIONOP_UCAST_IPSEC : +seq_puts (s,"\taction: Unicast ipsec\n" ); +break ; +case NIX_RX_ACTIONOP_MCAST : +seq_puts (s,"\taction: Multicast\n" ); +break ; +default : +break ; + }; + } +} + +static const char *rvu_dbg_get_intf_name (int intf) +{ +switch (intf) { +case NIX_INTFX_RX (0 ): +return "NIX0_RX" ; +case NIX_INTFX_RX (1 ): +return "NIX1_RX" ; +case NIX_INTFX_TX (0 ): +return "NIX0_TX" ; +case NIX_INTFX_TX (1 ): +return "NIX1_TX" ; +default : +break ; + } + +return "unknown" ; +} + +static int rvu_dbg_npc_mcam_show_rules (struct seq_file *s,void *unused) +{ +struct rvu_npc_mcam_rule *iter; +struct rvu *rvu = s->private; +struct npc_mcam *mcam; +int pf, vf =-1 ; +int blkaddr; +u16 target; +u64 hits; + + blkaddr =rvu_get_blkaddr (rvu,BLKTYPE_NPC ,0 ); +if (blkaddr <0 ) +return 0 ; + + mcam = &rvu->hw->mcam; + +mutex_lock (&mcam->lock); +list_for_each_entry (iter, &mcam->mcam_rules, list) { + pf = (iter->owner >>RVU_PFVF_PF_SHIFT ) &RVU_PFVF_PF_MASK ; +seq_printf (s,"\n\tInstalled by: PF%d " , pf); + +if (iter->owner &RVU_PFVF_FUNC_MASK ) { + vf = (iter->owner &RVU_PFVF_FUNC_MASK ) -1 ; +seq_printf (s,"VF%d" , vf); + } +seq_puts (s,"\n" ); + +seq_printf (s,"\tdirection: %s\n" ,is_npc_intf_rx (iter->intf) ? +"RX" :"TX" ); +seq_printf (s,"\tinterface: %s\n" , +rvu_dbg_get_intf_name (iter->intf)); +seq_printf (s,"\tmcam entry: %d\n" , iter->entry); + +rvu_dbg_npc_mcam_show_flows (s, iter); +if (iter->intf ==NIX_INTF_RX ) { + target = iter->rx_action.pf_func; + pf = (target >>RVU_PFVF_PF_SHIFT ) &RVU_PFVF_PF_MASK ; +seq_printf (s,"\tForward to: PF%d " , pf); + +if (target &RVU_PFVF_FUNC_MASK ) { + vf = (target &RVU_PFVF_FUNC_MASK ) -1 ; +seq_printf (s,"VF%d" , vf); + } +seq_puts (s,"\n" ); + } + +rvu_dbg_npc_mcam_show_action (s, iter); +seq_printf (s,"\tenabled: %s\n" , iter->enable ?"yes" :"no" ); + +if (!iter->has_cntr) +continue ; +seq_printf (s,"\tcounter: %d\n" , iter->cntr); + + hits =rvu_read64 (rvu, blkaddr,NPC_AF_MATCH_STATX (iter->cntr)); +seq_printf (s,"\thits: %lld\n" , hits); + } +mutex_unlock (&mcam->lock); + +return 0 ; +} + +RVU_DEBUG_SEQ_FOPS (npc_mcam_rules, npc_mcam_show_rules,NULL ); +static void rvu_dbg_npc_init (struct rvu *rvu) {const struct device *dev = &rvu->pdev->dev;
@@ -1784,6 +1976,11 @@ static void rvu_dbg_npc_init(struct rvu *rvu)if (!pfile) goto create_failed; + pfile =debugfs_create_file ("mcam_rules" ,0444 , rvu->rvu_dbg.npc, + rvu, &rvu_dbg_npc_mcam_rules_fops); +if (!pfile) + goto create_failed; + pfile =debugfs_create_file ("rx_miss_act_stats" ,0444 , rvu->rvu_dbg.npc, rvu, &rvu_dbg_npc_rx_miss_act_fops);if (!pfile)
Signature · 1 line
2.16.5
Re: [PATCH v3 net-next 07/13] octeontx2-af: Add debugfs entry to dump the MCAM rules
Quoted 14 lines · Naveen Mamindlapalli
From: Subbaraya Sundeep <[email protected]>
Add debugfs support to dump the MCAM rules installed using
NPC_INSTALL_FLOWmbox message. Debugfs file can display mcam entry, counter if any, flow type and counter hits.Ethtool will dump the ntuple flows related to the PF only. The debugfs file gives systemwide view of the MCAM rules installed by all the PF's.
Below is the example output when the debugfs file is read:
~ # mount -t debugfs none/sys/kernel/debug
~ # cat/sys/kernel/debug/octeontx2/npc/mcam_rules
Quoted 10 lines
Installed by: PF1
direction: RX
mcam entry: 227
udp source port 23 mask 0xffff
Forward to: PF1 VF0
action: Direct to queue 0
enabled: yes
counter: 1
hits: 0I don't want to block this series or anything, but you might want to use devlink dpipe interface for this:
https://www.kernel.org/doc/html/latest/networking/devlink/devlink-dpipe.html
As a future patch of course.
Thanks,
Saeed.
PATCH v3 8/13 octeontx2-af: Modify nix_vtag_cfg mailbox to support TX VTAG entries
In reply to Naveen MamindlapalliFrom: Vamsi Attunuru <[email protected]>
This patch modifies the existing nix_vtag_config mailbox message to allocate and free TX VTAG entries as requested by a NIX PF. The TX VTAG entries are global resource that shared by all PFs and each entry specifies the size of VTAG to insert and the VTAG header data to insert. The mailbox response contains the entry index which is used by mailbox requester in configuring the NPC_TX_VTAG_ACTION for any MCAM entry.
--- drivers/net/ethernet/marvell/octeontx2/af/mbox.h | 60 +++++-- drivers/net/ethernet/marvell/octeontx2/af/rvu.h | 8 + .../net/ethernet/marvell/octeontx2/af/rvu_nix.c | 195 ++++++++++++++++++++- 3 files changed, 250 insertions(+), 13 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/mbox.h +50 -10
@@ -204,7 +204,8 @@ M(NIX_TXSCH_ALLOC, 0x8004, nix_txsch_alloc, \ M(NIX_TXSCH_FREE, 0x8005, nix_txsch_free, nix_txsch_free_req, msg_rsp) \ M(NIX_TXSCHQ_CFG, 0x8006, nix_txschq_cfg, nix_txschq_config, msg_rsp) \ M(NIX_STATS_RST, 0x8007, nix_stats_rst, msg_req, msg_rsp) \ -M(NIX_VTAG_CFG, 0x8008, nix_vtag_cfg, nix_vtag_config, msg_rsp) \ +M (NIX_VTAG_CFG ,0x8008 , nix_vtag_cfg, nix_vtag_config, \ + nix_vtag_config_rsp) \M (NIX_RSS_FLOWKEY_CFG ,0x8009 , nix_rss_flowkey_cfg, \ nix_rss_flowkey_cfg, \ nix_rss_flowkey_cfg_rsp) \
@@ -477,6 +478,7 @@ enum nix_af_status {NIX_AF_ERR_LSO_CFG_FAIL =-418 ,NIX_AF_INVAL_NPA_PF_FUNC =-419 ,NIX_AF_INVAL_SSO_PF_FUNC =-420 , + NIX_AF_ERR_TX_VTAG_NOSPC = -421, };/* For NIX LF context alloc and init */
@@ -516,7 +518,8 @@ struct nix_lf_alloc_rsp {struct nix_lf_free_req {struct mbox_msghdr hdr; -#define NIX_LF_DISABLE_FLOWS BIT_ULL(0) +#define NIX_LF_DISABLE_FLOWS BIT_ULL(0) +#define NIX_LF_DONT_FREE_TX_VTAG BIT_ULL(1)u64 flags; };
@@ -610,14 +613,40 @@ struct nix_vtag_config {union {/* valid when cfg_type is '0' */ struct { -/* tx vlan0 tag(C-VLAN) */ -u64 vlan0; -/* tx vlan1 tag(S-VLAN) */ -u64 vlan1; -/* insert tx vlan tag */ -u8 insert_vlan :1 ; -/* insert tx double vlan tag */ -u8 double_vlan :1 ; +u64 vtag0; +u64 vtag1; + +/* cfg_vtag0 & cfg_vtag1 fields are valid +* when free_vtag0 & free_vtag1 are '0's. +*/ +/* cfg_vtag0 = 1 to configure vtag0 */ +u8 cfg_vtag0 :1 ; +/* cfg_vtag1 = 1 to configure vtag1 */ +u8 cfg_vtag1 :1 ; + +/* vtag0_idx & vtag1_idx are only valid when +* both cfg_vtag0 & cfg_vtag1 are '0's, +* these fields are used along with free_vtag0 +* & free_vtag1 to free the nix lf's tx_vlan +* configuration. +* +* Denotes the indices of tx_vtag def registers +* that needs to be cleared and freed. +*/ +int vtag0_idx; +int vtag1_idx; + +/* free_vtag0 & free_vtag1 fields are valid +* when cfg_vtag0 & cfg_vtag1 are '0's. +*/ +/* free_vtag0 = 1 clears vtag0 configuration +* vtag0_idx denotes the index to be cleared. +*/ +u8 free_vtag0 :1 ; +/* free_vtag1 = 1 clears vtag1 configuration +* vtag1_idx denotes the index to be cleared. +*/ +u8 free_vtag1 :1 ; } tx;/* valid when cfg_type is '1' */
@@ -632,6 +661,17 @@ struct nix_vtag_config { }; }; +struct nix_vtag_config_rsp { +struct mbox_msghdr hdr; +int vtag0_idx; +int vtag1_idx; +/* Indices of tx_vtag def registers used to configure +* tx vtag0 & vtag1 headers, these indices are valid +* when nix_vtag_config mbox requested for vtag0 and/ +* or vtag1 configuration. +*/ +}; +struct nix_rss_flowkey_cfg {struct mbox_msghdr hdr;int mcam_index;/* MCAM entry index to modify */
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +8 -0
@@ -264,6 +264,13 @@ struct nix_lso {u8 in_use; }; +struct nix_txvlan { +#define NIX_TX_VTAG_DEF_MAX 0x400 +struct rsrc_bmap rsrc; +u16 *entry2pfvf_map; +struct mutex rsrc_lock;/* Serialize resource alloc/free */ +}; +struct nix_hw {int blkaddr;struct rvu *rvu;
@@ -272,6 +279,7 @@ struct nix_hw {struct nix_flowkey flowkey;struct nix_mark_format mark_format;struct nix_lso lso; +struct nix_txvlan txvlan; };/* RVU block's capabilities or functionality,
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +192 -3
249 lines not on this page · raw message
Signature · 1 line
2.16.5
PATCH v3 9/13 octeontx2-pf: Implement ingress/egress VLAN offload
In reply to Naveen MamindlapalliFrom: Hariprasad Kelam <[email protected]>
This patch implements egress VLAN offload by appending NIX_SEND_EXT_S header to NIX_SEND_HDR_S. The VLAN TCI information is specified in the NIX_SEND_EXT_S. The VLAN offload in the ingress path is implemented by configuring the NIX_RX_VTAG_ACTION_S to strip and capture the outer vlan fields. The NIX PF allocates one MCAM entry for Rx VLAN offload.
--- drivers/net/ethernet/marvell/octeontx2/af/mbox.h | 13 +++ .../net/ethernet/marvell/octeontx2/af/rvu_nix.c | 3 +- .../ethernet/marvell/octeontx2/nic/otx2_common.c | 8 +- .../ethernet/marvell/octeontx2/nic/otx2_common.h | 8 +- .../ethernet/marvell/octeontx2/nic/otx2_flows.c | 102 +++++++++++++++++++++ .../net/ethernet/marvell/octeontx2/nic/otx2_pf.c | 16 ++++ .../net/ethernet/marvell/octeontx2/nic/otx2_txrx.c | 16 ++++ .../net/ethernet/marvell/octeontx2/nic/otx2_vf.c | 5 + 8 files changed, 167 insertions(+), 4 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/mbox.h +13 -0
@@ -479,6 +479,19 @@ enum nix_af_status {NIX_AF_INVAL_NPA_PF_FUNC =-419 ,NIX_AF_INVAL_SSO_PF_FUNC =-420 ,NIX_AF_ERR_TX_VTAG_NOSPC =-421 , + NIX_AF_ERR_RX_VTAG_INUSE = -422, +}; + +/* For NIX RX vtag action */ +enum nix_rx_vtag0_type { +NIX_AF_LFX_RX_VTAG_TYPE0 ,/* reserved for rx vlan offload */ +NIX_AF_LFX_RX_VTAG_TYPE1 , +NIX_AF_LFX_RX_VTAG_TYPE2 , +NIX_AF_LFX_RX_VTAG_TYPE3 , +NIX_AF_LFX_RX_VTAG_TYPE4 , +NIX_AF_LFX_RX_VTAG_TYPE5 , +NIX_AF_LFX_RX_VTAG_TYPE6 , +NIX_AF_LFX_RX_VTAG_TYPE7 , };/* For NIX LF context alloc and init */
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +2 -1
@@ -1986,7 +1986,8 @@ static int nix_rx_vtag_cfg(struct rvu *rvu, int nixlf, int blkaddr, {u64 regval = req->vtag_size; -if (req->rx.vtag_type >7 || req->vtag_size >VTAGSIZE_T8 ) +if (req->rx.vtag_type >NIX_AF_LFX_RX_VTAG_TYPE7 || + req->vtag_size >VTAGSIZE_T8 )return -EINVAL ;if (req->rx.capture_vtag)
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +6 -2
@@ -191,10 +191,14 @@ int otx2_set_mac_address(struct net_device *netdev, void *p)if (!is_valid_ether_addr (addr->sa_data))return -EADDRNOTAVAIL ; -if (!otx2_hw_set_mac_addr (pfvf, addr->sa_data)) +if (!otx2_hw_set_mac_addr (pfvf, addr->sa_data)) {memcpy (netdev->dev_addr, addr->sa_data, netdev->addr_len); -else +/* update dmac field in vlan offload rule */ +if (pfvf->flags &OTX2_FLAG_RX_VLAN_SUPPORT ) +otx2_install_rxvlan_offload_flow (pfvf); + }else {return -EPERM ; + }return 0 ; }
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +7 -1
@@ -240,10 +240,13 @@ struct otx2_flow_config {u32 nr_flows;#define OTX2_MAX_NTUPLE_FLOWS 32#define OTX2_MAX_UNICAST_FLOWS 8 +#define OTX2_MAX_VLAN_FLOWS 1#define OTX2_MCAM_COUNT (OTX2_MAX_NTUPLE_FLOWS + \ - OTX2_MAX_UNICAST_FLOWS) + OTX2_MAX_UNICAST_FLOWS + \ + OTX2_MAX_VLAN_FLOWS)u32 ntuple_offset;u32 unicast_offset; +u32 rx_vlan_offset;u32 ntuple_max_flows;struct list_head flow_list; };
@@ -261,6 +264,7 @@ struct otx2_nic {#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_VLAN_SUPPORT BIT_ULL(6)#define OTX2_FLAG_RX_PAUSE_ENABLED BIT_ULL(9)#define OTX2_FLAG_TX_PAUSE_ENABLED BIT_ULL(10)u64 flags;
@@ -687,5 +691,7 @@ 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); +int otx2_enable_rxvlan (struct otx2_nic *pf,bool enable); +int otx2_install_rxvlan_offload_flow (struct otx2_nic *pfvf);#endif /* OTX2_COMMON_H */
drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c +102 -0
113 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +16 -0
@@ -1566,6 +1566,9 @@ int otx2_open(struct net_device *netdev)otx2_set_cints_affinity (pf); +if (pf->flags &OTX2_FLAG_RX_VLAN_SUPPORT ) +otx2_enable_rxvlan (pf, true); +/* When reinitializing enable time stamping if it is enabled before */ if (pf->flags &OTX2_FLAG_TX_TSTAMP_ENABLED ) { pf->flags &= ~OTX2_FLAG_TX_TSTAMP_ENABLED ;
@@ -1763,6 +1766,10 @@ static int otx2_set_features(struct net_device *netdev,return otx2_cgx_config_loopback (pf, features &NETIF_F_LOOPBACK ); +if ((changed &NETIF_F_HW_VLAN_CTAG_RX ) &&netif_running (netdev)) +return otx2_enable_rxvlan (pf, + features &NETIF_F_HW_VLAN_CTAG_RX ); +if ((changed &NETIF_F_NTUPLE ) && !ntuple)otx2_destroy_ntuple_flows (pf);
@@ -2138,6 +2145,15 @@ static int otx2_probe(struct pci_dev *pdev, const struct pci_device_id *id)if (pf->flags &OTX2_FLAG_UCAST_FLTR_SUPPORT ) netdev->priv_flags |=IFF_UNICAST_FLT ; +/* Support TSO on tag interface */ + netdev->vlan_features |= netdev->features; + netdev->hw_features |=NETIF_F_HW_VLAN_CTAG_TX | +NETIF_F_HW_VLAN_STAG_TX ; +if (pf->flags &OTX2_FLAG_RX_VLAN_SUPPORT ) + netdev->hw_features |=NETIF_F_HW_VLAN_CTAG_RX | +NETIF_F_HW_VLAN_STAG_RX ; + netdev->features |= netdev->hw_features; + netdev->gso_max_segs =OTX2_MAX_GSO_SEGS ; netdev->watchdog_timeo =OTX2_TX_TIMEOUT ;
drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c +16 -0
@@ -556,6 +556,19 @@ static void otx2_sqe_add_ext(struct otx2_nic *pfvf, struct otx2_snd_queue *sq, ext->tstmp =1 ; } +#define OTX2_VLAN_PTR_OFFSET (ETH_HLEN - ETH_TLEN) +if (skb_vlan_tag_present (skb)) { +if (skb->vlan_proto ==htons (ETH_P_8021Q )) { + ext->vlan1_ins_ena =1 ; + ext->vlan1_ins_ptr =OTX2_VLAN_PTR_OFFSET ; + ext->vlan1_ins_tci =skb_vlan_tag_get (skb); + }else if (skb->vlan_proto ==htons (ETH_P_8021AD )) { + ext->vlan0_ins_ena =1 ; + ext->vlan0_ins_ptr =OTX2_VLAN_PTR_OFFSET ; + ext->vlan0_ins_tci =skb_vlan_tag_get (skb); + } + } + *offset +=sizeof (*ext); }
@@ -871,6 +884,9 @@ bool otx2_sq_append_skb(struct net_device *netdev, struct otx2_snd_queue *sq, }if (skb_shinfo (skb)->gso_size && !is_hw_tso_supported (pfvf, skb)) { +/* Insert vlan tag before giving pkt to tso */ +if (skb_vlan_tag_present (skb)) + skb =__vlan_hwaccel_push_inside (skb);otx2_sq_append_tso (pfvf, sq, skb, qidx);return true; }
drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c +5 -0
@@ -558,6 +558,11 @@ static int otx2vf_probe(struct pci_dev *pdev, const struct pci_device_id *id)NETIF_F_SG |NETIF_F_TSO |NETIF_F_TSO6 |NETIF_F_GSO_UDP_L4 ; netdev->features = netdev->hw_features; +/* Support TSO on tag interface */ + netdev->vlan_features |= netdev->features; + netdev->hw_features |=NETIF_F_HW_VLAN_CTAG_TX | +NETIF_F_HW_VLAN_STAG_TX ; + netdev->features |= netdev->hw_features; netdev->gso_max_segs =OTX2_MAX_GSO_SEGS ; netdev->watchdog_timeo =OTX2_TX_TIMEOUT ;
Signature · 1 line
2.16.5
PATCH v3 10/13 octeontx2-pf: Add support for SR-IOV management functions
In reply to Naveen MamindlapalliThis patch adds support for ndo_set_vf_mac, ndo_set_vf_vlan and ndo_get_vf_config handlers. The traffic redirection based on the VF mac address or vlan id is done by installing MCAM rules. Reserved RX_VTAG_TYPE7 in each NIXLF for VF VLAN which strips the VLAN tag from ingress VLAN traffic. The NIX PF allocates two MCAM entries for VF VLAN feature, one used for ingress VTAG strip and another entry for egress VTAG insertion.
This patch also updates the MAC address in PF installed VF VLAN rule upon receiving nix_lf_start_rx mbox request for VF since Administrative Function driver will assign a valid MAC addr in nix_lf_start_rx function.
--- drivers/net/ethernet/marvell/octeontx2/af/npc.h | 1 + drivers/net/ethernet/marvell/octeontx2/af/rvu.h | 4 + .../net/ethernet/marvell/octeontx2/af/rvu_nix.c | 14 ++ .../net/ethernet/marvell/octeontx2/af/rvu_npc.c | 88 ++++++++ .../net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c | 40 ++++ .../net/ethernet/marvell/octeontx2/af/rvu_struct.h | 11 + .../ethernet/marvell/octeontx2/nic/otx2_common.h | 9 + .../ethernet/marvell/octeontx2/nic/otx2_flows.c | 9 +- .../net/ethernet/marvell/octeontx2/nic/otx2_pf.c | 246 +++++++++++++++++++++ 9 files changed, 420 insertions(+), 2 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/npc.h +1 -0
@@ -452,6 +452,7 @@ struct rvu_npc_mcam_rule {bool has_cntr;u8 default_rule;bool enable; + bool vfvlan_cfg; };#endif /* NPC_H */
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +4 -0
@@ -209,6 +209,7 @@ struct rvu_pfvf {u16 maxlen;u16 minlen; +u8 pf_set_vf_cfg;u8 mac_addr[ETH_ALEN ];/* MAC address of this PF/VF */ /* Broadcast pkt replication info */
@@ -596,6 +597,9 @@ void npc_mcam_enable_flows(struct rvu *rvu, u16 target);void npc_mcam_disable_flows (struct rvu *rvu,u16 target);void npc_enable_mcam_entry (struct rvu *rvu,struct npc_mcam *mcam,int blkaddr,int index,bool enable); +void npc_read_mcam_entry (struct rvu *rvu,struct npc_mcam *mcam, +int blkaddr,u16 src,struct mcam_entry *entry, +u8 *intf,u8 *ena);#ifdef CONFIG_DEBUG_FS void rvu_dbg_init (struct rvu *rvu);
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +14 -0
@@ -1196,6 +1196,11 @@ int rvu_mbox_handler_nix_lf_alloc(struct rvu *rvu,/* Disable NPC entries as NIXLF's contexts are not initialized yet */ rvu_npc_disable_default_entries (rvu, pcifunc, nixlf); +/* Configure RX VTAG Type 7 (strip) for vf vlan */ +rvu_write64 (rvu, blkaddr, +NIX_AF_LFX_RX_VTAG_TYPEX (nixlf,NIX_AF_LFX_RX_VTAG_TYPE7 ), +VTAGSIZE_T4 |VTAG_STRIP ); + goto exit; free_mem:
@@ -1990,6 +1995,10 @@ static int nix_rx_vtag_cfg(struct rvu *rvu, int nixlf, int blkaddr, req->vtag_size > VTAGSIZE_T8)return -EINVAL ; +/* RX VTAG Type 7 reserved for vf vlan */ +if (req->rx.vtag_type ==NIX_AF_LFX_RX_VTAG_TYPE7 ) +return NIX_AF_ERR_RX_VTAG_INUSE ; +if (req->rx.capture_vtag) regval |=BIT_ULL (5 );if (req->rx.strip_vtag)
@@ -2933,6 +2942,7 @@ int rvu_mbox_handler_nix_set_mac_addr(struct rvu *rvu,struct nix_set_mac_addr *req, struct msg_rsp *rsp) { + bool from_vf = req->hdr.pcifunc & RVU_PFVF_FUNC_MASK;u16 pcifunc = req->hdr.pcifunc;int blkaddr, nixlf, err;struct rvu_pfvf *pfvf;
@@ -2943,6 +2953,10 @@ int rvu_mbox_handler_nix_set_mac_addr(struct rvu *rvu, pfvf =rvu_get_pfvf (rvu, pcifunc); +/* VF can't overwrite admin(PF) changes */ +if (from_vf && pfvf->pf_set_vf_cfg) +return -EPERM ; +ether_addr_copy (pfvf->mac_addr, req->mac_addr); rvu_npc_install_ucast_entry(rvu, pcifunc, nixlf,
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c +88 -0
100 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c +40 -0
@@ -1065,6 +1065,9 @@ static int npc_install_flow(struct rvu *rvu, int blkaddr, u16 target,if (req->default_rule) pfvf->def_ucast_rule = rule; +if (pfvf->pf_set_vf_cfg && req->vtag0_type ==NIX_AF_LFX_RX_VTAG_TYPE7 ) + rule->vfvlan_cfg = true; +return 0 ; }
@@ -1113,6 +1116,10 @@ int rvu_mbox_handler_npc_install_flow(struct rvu *rvu, pfvf =rvu_get_pfvf (rvu, target); +/* PF installing for its VF */ +if (req->hdr.pcifunc && !from_vf && req->vf) + pfvf->pf_set_vf_cfg =1 ; +/* update req destination mac addr */ if ((req->features &BIT_ULL (NPC_DMAC )) &&is_npc_intf_rx (req->intf) &&is_zero_ether_addr (req->packet.dmac)) {
@@ -1210,6 +1217,36 @@ int rvu_mbox_handler_npc_delete_flow(struct rvu *rvu,return 0 ; } +static int npc_update_dmac_value (struct rvu *rvu,int npcblkaddr, +struct rvu_npc_mcam_rule *rule, +struct rvu_pfvf *pfvf) +{ +struct npc_mcam_write_entry_req write_req = {0 }; +struct mcam_entry *entry = &write_req.entry_data; +struct npc_mcam *mcam = &rvu->hw->mcam; +struct msg_rsp rsp; +u8 intf, enable; +int err; + +ether_addr_copy (rule->packet.dmac, pfvf->mac_addr); + +npc_read_mcam_entry (rvu, mcam, npcblkaddr, rule->entry, + entry, &intf, &enable); + +npc_update_entry (rvu,NPC_DMAC , entry, +ether_addr_to_u64 (pfvf->mac_addr),0 , +0xffffffffffffull ,0 , intf); + + write_req.hdr.pcifunc = rule->owner; + write_req.entry = rule->entry; + +mutex_unlock (&mcam->lock); + err =rvu_mbox_handler_npc_mcam_write_entry (rvu, &write_req, &rsp); +mutex_lock (&mcam->lock); + +return err; +} +void npc_mcam_enable_flows (struct rvu *rvu,u16 target) {struct rvu_pfvf *pfvf =rvu_get_pfvf (rvu, target);
@@ -1236,6 +1273,9 @@ void npc_mcam_enable_flows(struct rvu *rvu, u16 target)continue ; } +if (rule->vfvlan_cfg) +npc_update_dmac_value (rvu, blkaddr, rule, pfvf); +if (rule->rx_action.op ==NIX_RX_ACTION_DEFAULT ) {if (!def_ucast_rule)continue ;
drivers/net/ethernet/marvell/octeontx2/af/rvu_struct.h +11 -0
@@ -921,4 +921,15 @@ enum nix_vtag_size {VTAGSIZE_T4 =0x0 , VTAGSIZE_T8 = 0x1, }; + +enum nix_tx_vtag_op { +NOP =0x0 , +VTAG_INSERT =0x1 , +VTAG_REPLACE =0x2 , +}; + +/* NIX RX VTAG actions */ +#define VTAG_STRIP BIT_ULL(4) +#define VTAG_CAPTURE BIT_ULL(5) +#endif /* RVU_STRUCT_H */
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +9 -0
@@ -206,6 +206,9 @@ struct otx2_vf_config {struct otx2_nic *pf;struct delayed_work link_event_work;bool intf_down;/* interface was either configured or not */ +u8 mac[ETH_ALEN ]; +u16 vlan; +int tx_vtag_idx; };struct flr_work {
@@ -247,6 +250,10 @@ struct otx2_flow_config {u32 ntuple_offset;u32 unicast_offset;u32 rx_vlan_offset; +u32 vf_vlan_offset; +#define OTX2_PER_VF_VLAN_FLOWS 2/* rx+tx per VF */ +#define OTX2_VF_VLAN_RX_INDEX 0 +#define OTX2_VF_VLAN_TX_INDEX 1u32 ntuple_max_flows;struct list_head flow_list; };
@@ -265,6 +272,8 @@ struct otx2_nic {#define OTX2_FLAG_NTUPLE_SUPPORT BIT_ULL(4)#define OTX2_FLAG_UCAST_FLTR_SUPPORT BIT_ULL(5)#define OTX2_FLAG_RX_VLAN_SUPPORT BIT_ULL(6) +#define OTX2_FLAG_VF_VLAN_SUPPORT BIT_ULL(7) +#define OTX2_FLAG_PF_SHUTDOWN BIT_ULL(8)#define OTX2_FLAG_RX_PAUSE_ENABLED BIT_ULL(9)#define OTX2_FLAG_TX_PAUSE_ENABLED BIT_ULL(10)u64 flags;
drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c +7 -2
@@ -24,6 +24,7 @@ int otx2_alloc_mcam_entries(struct otx2_nic *pfvf)struct otx2_flow_config *flow_cfg = pfvf->flow_cfg;struct npc_mcam_alloc_entry_req *req;struct npc_mcam_alloc_entry_rsp *rsp; +int vf_vlan_max_flows;int i;mutex_lock (&pfvf->mbox.lock);
@@ -34,8 +35,9 @@ int otx2_alloc_mcam_entries(struct otx2_nic *pfvf)return -ENOMEM ; } + vf_vlan_max_flows = pfvf->total_vfs *OTX2_PER_VF_VLAN_FLOWS ; req->contig = false; - req->count =OTX2_MCAM_COUNT ; + req->count =OTX2_MCAM_COUNT + vf_vlan_max_flows;/* Send message to AF */ if (otx2_sync_mbox_msg (&pfvf->mbox)) {
@@ -55,7 +57,9 @@ int otx2_alloc_mcam_entries(struct otx2_nic *pfvf) flow_cfg->ntuple_offset =0 ; pfvf->flags |=OTX2_FLAG_NTUPLE_SUPPORT ; }else { - flow_cfg->ntuple_offset =0 ; + flow_cfg->vf_vlan_offset =0 ; + flow_cfg->ntuple_offset = flow_cfg->vf_vlan_offset + + vf_vlan_max_flows; flow_cfg->unicast_offset = flow_cfg->ntuple_offset +OTX2_MAX_NTUPLE_FLOWS ; flow_cfg->rx_vlan_offset = flow_cfg->unicast_offset +
@@ -63,6 +67,7 @@ int otx2_alloc_mcam_entries(struct otx2_nic *pfvf) pfvf->flags |=OTX2_FLAG_NTUPLE_SUPPORT ; pfvf->flags |=OTX2_FLAG_UCAST_FLTR_SUPPORT ; pfvf->flags |=OTX2_FLAG_RX_VLAN_SUPPORT ; + pfvf->flags |=OTX2_FLAG_VF_VLAN_SUPPORT ; }for (i =0 ; i < rsp->count; i++)
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +246 -0
270 lines not on this page · raw message
Signature · 1 line
2.16.5
PATCH v3 11/13 octeontx2-af: Handle PF-VF mac address changes
In reply to Naveen MamindlapalliFrom: Hariprasad Kelam <[email protected]>
This patch handles the VF mac address changes as given below.
1. mac addr configrued by VF will be retained until VF module unload.
2. mac addr configred by PF for VF will be retained until power cycle.
3. mac addr confgired by PF for its VF can't be overwritten by VF.
--- drivers/net/ethernet/marvell/octeontx2/af/rvu.c | 12 +++++++++++- drivers/net/ethernet/marvell/octeontx2/af/rvu.h | 2 ++ drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c | 9 +++++++++ drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c | 17 ++++++++++++++--- 4 files changed, 36 insertions(+), 4 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu.c +11 -1
@@ -727,6 +727,10 @@ static void rvu_setup_pfvf_macaddress(struct rvu *rvu)u64 *mac;for (pf =0 ; pf < hw->total_pfs; pf++) { +/* For PF0(AF), Assign MAC address to only VFs (LBKVFs) */ +if (!pf) + goto lbkvf; +if (!is_pf_cgxmapped (rvu, pf))continue ;/* Assign MAC address to PF */
@@ -740,8 +744,10 @@ static void rvu_setup_pfvf_macaddress(struct rvu *rvu) }else {eth_random_addr (pfvf->mac_addr); } +ether_addr_copy (pfvf->default_mac, pfvf->mac_addr); -/* Assign MAC address to VFs */ +lbkvf: +/* Assign MAC address to VFs*/ rvu_get_pf_numvfs (rvu, pf, &numvfs, &hwvf);for (vf =0 ; vf < numvfs; vf++, hwvf++) { pfvf = &rvu->hwvf[hwvf];
@@ -754,6 +760,7 @@ static void rvu_setup_pfvf_macaddress(struct rvu *rvu) }else {eth_random_addr (pfvf->mac_addr); } +ether_addr_copy (pfvf->default_mac, pfvf->mac_addr); } } }
@@ -1176,6 +1183,9 @@ static void rvu_detach_block(struct rvu *rvu, int pcifunc, int blktype)if (blkaddr <0 )return ; +if (blktype ==BLKTYPE_NIX ) +rvu_nix_reset_mac (pfvf, pcifunc); + block = &hw->block[blkaddr]; num_lfs =rvu_get_rsrc_mapcount (pfvf, block->addr);
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +2 -0
@@ -211,6 +211,7 @@ struct rvu_pfvf {u8 pf_set_vf_cfg;u8 mac_addr[ETH_ALEN ];/* MAC address of this PF/VF */ +u8 default_mac[ETH_ALEN ];/* MAC address from FWdata */ /* Broadcast pkt replication info */ u16 bcast_mce_idx;
@@ -553,6 +554,7 @@ int nix_get_nixlf(struct rvu *rvu, u16 pcifunc, int *nixlf, int *nix_blkaddr);int nix_update_bcast_mce_list (struct rvu *rvu,u16 pcifunc,bool add);struct nix_hw *get_nix_hw (struct rvu_hwinfo *hw,int blkaddr);int rvu_get_next_nix_blkaddr (struct rvu *rvu,int blkaddr); +void rvu_nix_reset_mac (struct rvu_pfvf *pfvf,int pcifunc);/* NPC APIs */ int rvu_npc_init (struct rvu *rvu);
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +9 -0
@@ -3737,3 +3737,12 @@ int rvu_mbox_handler_nix_lso_format_cfg(struct rvu *rvu,return 0 ; } + +void rvu_nix_reset_mac (struct rvu_pfvf *pfvf,int pcifunc) +{ +bool from_vf = !!(pcifunc &RVU_PFVF_FUNC_MASK ); + +/* overwrite vf mac address with default_mac */ +if (from_vf) +ether_addr_copy (pfvf->mac_addr, pfvf->default_mac); +}
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c +14 -3
@@ -938,7 +938,8 @@ static void npc_update_tx_entry(struct rvu *rvu, struct rvu_pfvf *pfvf,static int npc_install_flow (struct rvu *rvu,int blkaddr,u16 target,int nixlf,struct rvu_pfvf *pfvf,struct npc_install_flow_req *req, -struct npc_install_flow_rsp *rsp,bool enable) +struct npc_install_flow_rsp *rsp,bool enable, +bool pf_set_vfs_mac) {struct rvu_npc_mcam_rule *def_ucast_rule = pfvf->def_ucast_rule;u64 features, installed_features, missing_features =0 ;
@@ -1065,6 +1066,12 @@ static int npc_install_flow(struct rvu *rvu, int blkaddr, u16 target,if (req->default_rule) pfvf->def_ucast_rule = rule; +/* VF's MAC address is being changed via PF */ +if (pf_set_vfs_mac) { +ether_addr_copy (pfvf->default_mac, req->packet.dmac); +ether_addr_copy (pfvf->mac_addr, req->packet.dmac); + } +if (pfvf->pf_set_vf_cfg && req->vtag0_type ==NIX_AF_LFX_RX_VTAG_TYPE7 ) rule->vfvlan_cfg = true;
@@ -1078,6 +1085,7 @@ int rvu_mbox_handler_npc_install_flow(struct rvu *rvu,bool from_vf = !!(req->hdr.pcifunc &RVU_PFVF_FUNC_MASK );int blkaddr, nixlf, err;struct rvu_pfvf *pfvf; +bool pf_set_vfs_mac = false;bool enable = true;u16 target;
@@ -1102,8 +1110,11 @@ int rvu_mbox_handler_npc_install_flow(struct rvu *rvu,if (!req->hdr.pcifunc) target = req->vf;/* PF installing for its VF */ -else if (!from_vf && req->vf) +else if (!from_vf && req->vf) { target = (req->hdr.pcifunc & ~RVU_PFVF_FUNC_MASK ) | req->vf; + pf_set_vfs_mac = req->default_rule && + (req->features &BIT_ULL (NPC_DMAC )); + }/* msg received from PF/VF */ else target = req->hdr.pcifunc;
@@ -1152,7 +1163,7 @@ int rvu_mbox_handler_npc_install_flow(struct rvu *rvu,return -EINVAL ;return npc_install_flow (rvu, blkaddr, target, nixlf, pfvf, req, rsp, - enable); + enable, pf_set_vfs_mac); } static int npc_delete_flow(struct rvu *rvu, struct rvu_npc_mcam_rule *rule,
Signature · 1 line
2.16.5
PATCH v3 12/13 octeontx2-af: Add new mbox messages to retrieve MCAM entries
In reply to Naveen MamindlapalliThis patch introduces new mailbox mesages to retrieve a given MCAM entry or base flow steering rule of a VF installed by its parent PF. This helps while updating the existing MCAM rules with out re-framing the whole mailbox request again. The INSTALL FLOW mailbox consumer can read-modify-write the existing entry. Similarly while installing new flow rules for a VF, the base flow steering rule match creteria is copied to the new flow rule and the deltas are appended to the new rule.
--- drivers/net/ethernet/marvell/octeontx2/af/mbox.h | 22 +++++++ .../net/ethernet/marvell/octeontx2/af/rvu_npc.c | 70 ++++++++++++++++++++++ 2 files changed, 92 insertions(+)
drivers/net/ethernet/marvell/octeontx2/af/mbox.h +22 -0
@@ -192,6 +192,11 @@ M(NPC_INSTALL_FLOW, 0x600d, npc_install_flow, \ npc_install_flow_req, npc_install_flow_rsp) \ M(NPC_DELETE_FLOW, 0x600e, npc_delete_flow, \ npc_delete_flow_req, msg_rsp) \ +M(NPC_MCAM_READ_ENTRY, 0x600f, npc_mcam_read_entry, \ + npc_mcam_read_entry_req, \ + npc_mcam_read_entry_rsp) \ +M(NPC_MCAM_READ_BASE_RULE, 0x6011, npc_read_base_steer_rule, \ + msg_req, npc_mcam_read_base_rule_rsp) \/* NIX mbox IDs (range 0x8000 - 0xFFFF) */ \M (NIX_LF_ALLOC ,0x8000 , nix_lf_alloc, \ nix_lf_alloc_req, nix_lf_alloc_rsp) \
@@ -1009,6 +1014,23 @@ struct npc_delete_flow_req {u8 all;/* PF + VFs */ }; +struct npc_mcam_read_entry_req { +struct mbox_msghdr hdr; +u16 entry;/* MCAM entry to read */ +}; + +struct npc_mcam_read_entry_rsp { +struct mbox_msghdr hdr; +struct mcam_entry entry_data; +u8 intf; +u8 enable; +}; + +struct npc_mcam_read_base_rule_rsp { +struct mbox_msghdr hdr; +struct mcam_entry entry; +}; +enum ptp_op {PTP_OP_ADJFINE =0 ,PTP_OP_GET_CLOCK =1 ,
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c +70 -0
79 lines not on this page · raw message
Signature · 1 line
2.16.5
PATCH v3 13/13 octeontx2-af: Delete NIX_RXVLAN_ALLOC mailbox message
In reply to Naveen MamindlapalliFrom: Subbaraya Sundeep <[email protected]>
Since mailbox message for installing flows is in place, remove the RXVLAN_ALLOC mbox message which is redundant.
--- drivers/net/ethernet/marvell/octeontx2/af/mbox.h | 1 - drivers/net/ethernet/marvell/octeontx2/af/rvu.h | 6 --- .../net/ethernet/marvell/octeontx2/af/rvu_nix.c | 59 ---------------------- .../net/ethernet/marvell/octeontx2/af/rvu_npc.c | 24 --------- 4 files changed, 90 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/mbox.h +0 -1
@@ -226,7 +226,6 @@ M(NIX_SET_RX_CFG, 0x8010, nix_set_rx_cfg, nix_rx_cfg, msg_rsp) \M (NIX_LSO_FORMAT_CFG ,0x8011 , nix_lso_format_cfg, \ nix_lso_format_cfg, \ nix_lso_format_cfg_rsp) \ -M(NIX_RXVLAN_ALLOC, 0x8012, nix_rxvlan_alloc, msg_req, msg_rsp) \ M(NIX_LF_PTP_TX_ENABLE, 0x8013, nix_lf_ptp_tx_enable, msg_req, msg_rsp) \ M(NIX_LF_PTP_TX_DISABLE, 0x8014, nix_lf_ptp_tx_disable, msg_req, msg_rsp) \ M(NIX_BP_ENABLE, 0x8016, nix_bp_enable, nix_bp_cfg_req, \
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +0 -6
@@ -217,11 +217,6 @@ struct rvu_pfvf {u16 bcast_mce_idx;struct nix_mce_list bcast_mce_list; -/* VLAN offload */ -struct mcam_entry entry; -int rxvlan_index; -bool rxvlan; -struct rvu_npc_mcam_rule *def_ucast_rule;bool cgx_in_use;/* this PF/VF using CGX? */
@@ -571,7 +566,6 @@ void rvu_npc_enable_promisc_entry(struct rvu *rvu, u16 pcifunc, int nixlf);void rvu_npc_install_bcast_match_entry (struct rvu *rvu,u16 pcifunc,int nixlf,u64 chan);void rvu_npc_enable_bcast_entry (struct rvu *rvu,u16 pcifunc,bool enable); -int rvu_npc_update_rxvlan (struct rvu *rvu,u16 pcifunc,int nixlf);void rvu_npc_disable_mcam_entries (struct rvu *rvu,u16 pcifunc,int nixlf);void rvu_npc_free_mcam_entries (struct rvu *rvu,u16 pcifunc,int nixlf);void rvu_npc_disable_default_entries (struct rvu *rvu,u16 pcifunc,int nixlf);
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +0 -59
65 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c +0 -24
@@ -2731,30 +2731,6 @@ int rvu_mbox_handler_npc_get_kex_cfg(struct rvu *rvu, struct msg_req *req,return 0 ; } -int rvu_npc_update_rxvlan (struct rvu *rvu,u16 pcifunc,int nixlf) -{ -struct rvu_pfvf *pfvf =rvu_get_pfvf (rvu, pcifunc); -struct npc_mcam *mcam = &rvu->hw->mcam; -int blkaddr, index; -bool enable; - - blkaddr =rvu_get_blkaddr (rvu,BLKTYPE_NPC ,0 ); -if (blkaddr <0 ) -return NIX_AF_ERR_AF_LF_INVALID ; - -if (!pfvf->rxvlan) -return 0 ; - - index =npc_get_nixlf_mcam_index (mcam, pcifunc, nixlf, -NIXLF_UCAST_ENTRY ); - pfvf->entry.action =npc_get_mcam_action (rvu, mcam, blkaddr, index); - enable =is_mcam_entry_enabled (rvu, mcam, blkaddr, index); -npc_config_mcam_entry (rvu, mcam, blkaddr, pfvf->rxvlan_index, - pfvf->nix_rx_intf, &pfvf->entry, enable); - -return 0 ; -} -bool rvu_npc_write_default_rule (struct rvu *rvu,int blkaddr,int nixlf,u16 pcifunc,u8 intf,struct mcam_entry *entry,int *index)
Signature · 1 line
2.16.5
Quoted 21 lines · 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 mailboxNIX_RXVLAN_ALLOC.
Quoted 10 lines
Change-log:
v3:
- Fixed Saeed's review comments on v2.
- Fixed modifying thenetdev->flagsfrom driver.
- Fixed modifying the netdev features andhw_featuresafterregister_netdev.
- Removed unwantedndo_features_checkcallback.
v2:
- Fixed the sparse issues reported by Jakub.
Hi Saeed,
Thanks for the review.
Quoted 49 lines
-----Original Message-----
From: Saeed Mahameed <[email protected]>
Sent: Friday, November 13, 2020 1:47 AM
To: Naveen Mamindlapalli <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; [email protected]; Sunil Kovvuri Goutham <[email protected]>; Linu Cherian <[email protected]>; Geethasowjanya Akula <[email protected]>; Jerin Jacob Kollanukkaran <[email protected]>; Subbaraya Sundeep Bhatta <[email protected]>; Hariprasad Kelam <[email protected]>
Subject: [EXT] Re: [PATCH v3 net-next 00/13] Add ethtool ntuple filters supportExternal Email
----------------------------------------------------------------------
Quoted 21 lines · 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 mailboxNIX_RXVLAN_ALLOC.Quoted 10 lines
Change-log:
v3:
- Fixed Saeed's review comments on v2.
- Fixed modifying thenetdev->flagsfrom driver.
- Fixed modifying the netdev features andhw_featuresafterregister_netdev.
- Removed unwantedndo_features_checkcallback.
v2:
- Fixed the sparse issues reported by Jakub.Reviewed-by Saeed Mahameed <[email protected]>