Skip to contentSkip to conversation

octeontx2: Miscellaneous fixes

PATCH Superseded Sai Krishna 3 participants 22 messages Apr 7, 2023 – Apr 14, 2023

Subsystems (4)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v2 cover octeontx2: Miscellaneous fixes

This patchset includes following fixes.

Patch #1 Fix for the race condition while updating APR table

Patch #2 Fix for bit positions in NPC, MCAM table entries

Patch #3 Fix driver crash resulting from invalid interface type information retrieved from firmware

Patch #4 Fix incorrect mask used while installing filters inlovling fragmented packets

Patch #5 Fixes for NPC field hash extract w.r.t IPV6 hash reduction,
IPV6 filed hash configuration, parser confiuration destination address hash.

Patch #6 Fix for skipping mbox initialization for PFs disabled by firmware.

Patch #7 Fix disabling packet I/O in case of mailbox timeout.

Geetha sowjanya (1):
octeontx2-af: Secure APR table update with the lock

Hariprasad Kelam (1):
octeontx2-af: Add validation for lmac type

Ratheesh Kannoth (3):
octeontx2-af: Fix start and end bit for scan config
octeontx2-af: Fix issues with NPC field hash extract
octeontx2-af: Skip PFs if not enabled

Subbaraya Sundeep (1):
octeontx2-pf: Disable packet I/O for graceful exit

Suman Ghosh (1):
octeontx2-af: Update correct mask to filter IPv4 fragments

---
v2 changes:
Fixed review comments given by Leon Romanovsky
1. Updated lmac_type in case of invalid lmac
2. Modified commit message

 .../net/ethernet/marvell/octeontx2/af/cgx.c   |   8 ++
 .../net/ethernet/marvell/octeontx2/af/mbox.c  |   5 +-
 .../net/ethernet/marvell/octeontx2/af/mbox.h  |  19 ++-
 .../net/ethernet/marvell/octeontx2/af/rvu.c   |  38 +++++-
 .../ethernet/marvell/octeontx2/af/rvu_cn10k.c |   8 +-
 .../marvell/octeontx2/af/rvu_npc_fs.c         |  28 ++--
 .../marvell/octeontx2/af/rvu_npc_fs.h         |   4 +
 .../marvell/octeontx2/af/rvu_npc_hash.c       | 125 ++++++++++--------
 .../marvell/octeontx2/af/rvu_npc_hash.h       |  10 +-
 .../marvell/octeontx2/nic/otx2_common.h       |   4 +-
 .../ethernet/marvell/octeontx2/nic/otx2_pf.c  |  11 +-
 .../ethernet/marvell/octeontx2/nic/otx2_tc.c  |   2 +-
 .../ethernet/marvell/octeontx2/nic/otx2_vf.c  |   8 +-
 13 files changed, 182 insertions(+), 88 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH v2 1/7 octeontx2-af: Secure APR table update with the lock

From: Geetha sowjanya <[email protected]>

APR table contains the lmtst base address of PF/VFs. These entries are updated by the PF/VF during the device probe. Due to race condition while updating the entries are getting corrupted. Hence secure the APR table update with the lock.

Fixes 893ae97214c3 ("octeontx2-af: cn10k: Support configurable LMTST regions")
---
 drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c +5 -3
index 4ad9ff025c96..8530250f6fba 100644
@@ -142,16 +142,17 @@ int rvu_mbox_handler_lmtst_tbl_setup(struct rvu *rvu,
 	 * region, if so, convert that IOVA to physical address and
 	 * populate LMT table with that address
 	 */
+	mutex_lock(&rvu->rsrc_lock);
 	if (req->use_local_lmt_region) {
 		err = rvu_get_lmtaddr(rvu, req->hdr.pcifunc,
 				      req->lmt_iova, &lmt_addr);
 		if (err < 0)
-			return err;
+			goto error;
 
 		/* Update the lmt addr for this PFFUNC in the LMT table */
 		err = rvu_update_lmtaddr(rvu, req->hdr.pcifunc, lmt_addr);
 		if (err)
-			return err;
+			goto error;
 	}
 
 	/* Reconfiguring lmtst map table in lmt region shared mode i.e. make
@@ -181,7 +182,7 @@ int rvu_mbox_handler_lmtst_tbl_setup(struct rvu *rvu,
 		 */
 		err = rvu_update_lmtaddr(rvu, req->hdr.pcifunc, val);
 		if (err)
-			return err;
+			goto error;
 	}
 
 	/* This mailbox can also be used to update word1 of APR_LMT_MAP_ENTRY_S
@@ -230,6 +231,7 @@ int rvu_mbox_handler_lmtst_tbl_setup(struct rvu *rvu,
 	}
 
 error:
+	mutex_unlock(&rvu->rsrc_lock);
 	return err;
 }
 
Signature · 1 line
2.25.1
#4 lore raw

PATCH v2 2/7 octeontx2-af: Fix start and end bit for scan config

In reply to Sai Krishna

From: Ratheesh Kannoth <[email protected]>

Fix the NPC nibble start and end positions in the bit map. Fix the depth of cam and mem table configuration. Increased the field size of dmac filter flows as cn10kb support large in number.

Fixes b747923afff8 ("octeontx2-af: Exact match support")
---
 drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c   | 5 ++---
 drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c | 4 ++--
 drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h | 4 ++--
 3 files changed, 6 insertions(+), 7 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c +2 -3
index 006beb5cf98d..27603078689a 100644
@@ -593,9 +593,8 @@ static int npc_scan_kex(struct rvu *rvu, int blkaddr, u8 intf)
 	 * exact match code.
 	 */
 	masked_cfg = cfg & NPC_EXACT_NIBBLE;
-	bitnr = NPC_EXACT_NIBBLE_START;
-	for_each_set_bit_from(bitnr, (unsigned long *)&masked_cfg,
-			      NPC_EXACT_NIBBLE_START) {
+	bitnr = NPC_EXACT_NIBBLE_START - 1;
+	for_each_set_bit_from(bitnr, (unsigned long *)&masked_cfg, NPC_EXACT_NIBBLE_END + 1) {
 		npc_scan_exact_result(mcam, bitnr, key_nibble, intf);
 		key_nibble++;
 	}
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c +2 -2
index 20ebb9c95c73..6597af84aa36 100644
@@ -1868,9 +1868,9 @@ int rvu_npc_exact_init(struct rvu *rvu)
 	rvu->hw->table = table;
 
 	/* Read table size, ways and depth */
-	table->mem_table.depth = FIELD_GET(GENMASK_ULL(31, 24), npc_const3);
 	table->mem_table.ways = FIELD_GET(GENMASK_ULL(19, 16), npc_const3);
-	table->cam_table.depth = FIELD_GET(GENMASK_ULL(15, 0), npc_const3);
+	table->mem_table.depth = FIELD_GET(GENMASK_ULL(15, 0), npc_const3);
+	table->cam_table.depth = FIELD_GET(GENMASK_ULL(31, 24), npc_const3);
 
 	dev_dbg(rvu->dev, "%s: NPC exact match 4way_2k table(ways=%d, depth=%d)\n",
 		__func__,  table->mem_table.ways, table->cam_table.depth);
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +2 -2
index 3d22cc6a2804..99cdc871b59c 100644
@@ -335,11 +335,11 @@ struct otx2_flow_config {
 #define OTX2_PER_VF_VLAN_FLOWS	2 /* Rx + Tx per VF */
 #define OTX2_VF_VLAN_RX_INDEX	0
 #define OTX2_VF_VLAN_TX_INDEX	1
-	u16			max_flows;
-	u8			dmacflt_max_flows;
 	u32			*bmap_to_dmacindex;
 	unsigned long		*dmacflt_bmap;
 	struct list_head	flow_list;
+	u32			dmacflt_max_flows;
+	u16                     max_flows;
 };
 
 struct otx2_tc_info {
Signature · 1 line
2.25.1
#7 lore raw

PATCH v2 3/7 octeontx2-af: Add validation for lmac type

In reply to Sai Krishna

From: Hariprasad Kelam <[email protected]>

Upon physical link change, firmware reports to the kernel about the change along with the details like speed, lmac_type_id, etc. Kernel derives lmac_type based on lmac_type_id received from firmware.

In a few scenarios, firmware returns an invalid lmac_type_id, which is resulting in below kernel panic. This patch adds the missing validation of the lmac_type_id field.

Internal error: Oops: 96000005 [#1] PREEMPT SMP
[   35.321595] Modules linked in:
[   35.328982] CPU: 0 PID: 31 Comm: kworker/0:1 Not tainted
5.4.210-g2e3169d8e1bc-dirty #17
[   35.337014] Hardware name: Marvell CN103XX board (DT)
[   35.344297] Workqueue: events work_for_cpu_fn
[   35.352730] pstate: 40400089 (nZcv daIf +PAN -UAO)
[   35.360267] pc : strncpy+0x10/0x30
[   35.366595] lr : cgx_link_change_handler+0x90/0x180
Fixes 61071a871ea6 ("octeontx2-af: Forward CGX link notifications to PFs")
 drivers/net/ethernet/marvell/octeontx2/af/cgx.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/net/ethernet/marvell/octeontx2/af/cgx.c +8 -0
index 724df6398bbe..bd77152bb8d7 100644
@@ -1231,6 +1231,14 @@ static inline void link_status_user_format(u64 lstat,
 	linfo->an = FIELD_GET(RESP_LINKSTAT_AN, lstat);
 	linfo->fec = FIELD_GET(RESP_LINKSTAT_FEC, lstat);
 	linfo->lmac_type_id = FIELD_GET(RESP_LINKSTAT_LMAC_TYPE, lstat);
+
+	if (linfo->lmac_type_id >= LMAC_MODE_MAX) {
+		dev_err(&cgx->pdev->dev, "Unknown lmac_type_id %d reported by firmware on cgx port%d:%d",
+			linfo->lmac_type_id, cgx->cgx_id, lmac_id);
+		strncpy(linfo->lmac_type, "Unknown", LMACTYPE_STR_LEN - 1);
+		return;
+	}
+
 	lmac_string = cgx_lmactype_string[linfo->lmac_type_id];
 	strncpy(linfo->lmac_type, lmac_string, LMACTYPE_STR_LEN - 1);
 }
Signature · 1 line
2.25.1
#11 lore raw

PATCH v2 4/7 octeontx2-af: Update correct mask to filter IPv4 fragments

In reply to Sai Krishna

From: Suman Ghosh <[email protected]>

During the initial design, the IPv4 ip_flag mask was set to 0xff. Which results to filter only fragmets with (fragment_offset == 0). As part of the fix, updated the mask to 0x20 to filter all the fragmented packets irrespective of the fragment_offset value.

Fixes c672e3727989 ("octeontx2-pf: Add support to filter packet based on IP fragment")
---
 drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c +1 -1
index 044cc211424e..8392f63e433f 100644
@@ -544,7 +544,7 @@ static int otx2_tc_prepare_flow(struct otx2_nic *nic, struct otx2_tc_flow *node,
 		if (match.mask->flags & FLOW_DIS_IS_FRAGMENT) {
 			if (ntohs(flow_spec->etype) == ETH_P_IP) {
 				flow_spec->ip_flag = IPV4_FLAG_MORE;
-				flow_mask->ip_flag = 0xff;
+				flow_mask->ip_flag = IPV4_FLAG_MORE;
 				req->features |= BIT_ULL(NPC_IPFRAG_IPV4);
 			} else if (ntohs(flow_spec->etype) == ETH_P_IPV6) {
 				flow_spec->next_header = IPPROTO_FRAGMENT;
Signature · 1 line
2.25.1
#13 lore raw

PATCH v2 5/7 octeontx2-af: Fix issues with NPC field hash extract

In reply to Sai Krishna

From: Ratheesh Kannoth <[email protected]>

1. As per previous implementation, mask and control parameter to generate the field hash value was not passed to the caller program. Updated the secret key mbox to share that information as well, as a part of the fix.
2. Earlier implementation did not consider hash reduction of both source and destination IPv6 addresses. Only source IPv6 address was considered. This fix solves that and provides option to hash reduce both source and destination IPv6 addresses.
3. Fix endianness issue during hash reduction while storing the IPv6 source/destination address as hash keys.
4. Configure hardware parser based on hash extract feature enable flag for IPv6.

Fixes 56d9f5fd2246 ("octeontx2-af: Use hashed field in MCAM key")
 .../net/ethernet/marvell/octeontx2/af/mbox.h  |  16 ++-
 .../marvell/octeontx2/af/rvu_npc_fs.c         |  23 +++-
 .../marvell/octeontx2/af/rvu_npc_fs.h         |   4 +
 .../marvell/octeontx2/af/rvu_npc_hash.c       | 121 ++++++++++--------
 .../marvell/octeontx2/af/rvu_npc_hash.h       |  10 +-
 5 files changed, 108 insertions(+), 66 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/mbox.h +11 -5
index 5727d67e0259..0ce533848536 100644
@@ -245,9 +245,9 @@ M(NPC_MCAM_READ_BASE_RULE, 0x6011, npc_read_base_steer_rule,            \
 M(NPC_MCAM_GET_STATS, 0x6012, npc_mcam_entry_stats,                     \
 				   npc_mcam_get_stats_req,              \
 				   npc_mcam_get_stats_rsp)              \
-M(NPC_GET_SECRET_KEY, 0x6013, npc_get_secret_key,                     \
-				   npc_get_secret_key_req,              \
-				   npc_get_secret_key_rsp)              \
+M(NPC_GET_FIELD_HASH_INFO, 0x6013, npc_get_field_hash_info,                     \
+				   npc_get_field_hash_info_req,              \
+				   npc_get_field_hash_info_rsp)              \
 M(NPC_GET_FIELD_STATUS, 0x6014, npc_get_field_status,                     \
 				   npc_get_field_status_req,              \
 				   npc_get_field_status_rsp)              \
@@ -1524,14 +1524,20 @@ struct npc_mcam_get_stats_rsp {
 	u8 stat_ena; /* enabled */
 };
 
-struct npc_get_secret_key_req {
+struct npc_get_field_hash_info_req {
 	struct mbox_msghdr hdr;
 	u8 intf;
 };
 
-struct npc_get_secret_key_rsp {
+struct npc_get_field_hash_info_rsp {
 	struct mbox_msghdr hdr;
 	u64 secret_key[3];
+#define NPC_MAX_HASH 2
+#define NPC_MAX_HASH_MASK 2
+	/* NPC_AF_INTF(0..1)_HASH(0..1)_MASK(0..1) */
+	u64 hash_mask[NPC_MAX_INTF][NPC_MAX_HASH][NPC_MAX_HASH_MASK];
+	/* NPC_AF_INTF(0..1)_HASH(0..1)_RESULT_CTRL */
+	u64 hash_ctrl[NPC_MAX_INTF][NPC_MAX_HASH];
 };
 
 enum ptp_op {
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c +16 -7
index 27603078689a..6d63a0ef6d9c 100644
@@ -13,11 +13,6 @@
 #include "rvu_npc_fs.h"
 #include "rvu_npc_hash.h"
 
-#define NPC_BYTESM		GENMASK_ULL(19, 16)
-#define NPC_HDR_OFFSET		GENMASK_ULL(15, 8)
-#define NPC_KEY_OFFSET		GENMASK_ULL(5, 0)
-#define NPC_LDATA_EN		BIT_ULL(7)
-
 static const char * const npc_flow_names[] = {
 	[NPC_DMAC]	= "dmac",
 	[NPC_SMAC]	= "smac",
@@ -442,6 +437,7 @@ static void npc_handle_multi_layer_fields(struct rvu *rvu, int blkaddr, u8 intf)
 static void npc_scan_ldata(struct rvu *rvu, int blkaddr, u8 lid,
 			   u8 lt, u64 cfg, u8 intf)
 {
+	struct npc_mcam_kex_hash *mkex_hash = rvu->kpu.mkex_hash;
 	struct npc_mcam *mcam = &rvu->hw->mcam;
 	u8 hdr, key, nr_bytes, bit_offset;
 	u8 la_ltype, la_start;
@@ -490,8 +486,21 @@ do {									       \
 	NPC_SCAN_HDR(NPC_SIP_IPV4, NPC_LID_LC, NPC_LT_LC_IP, 12, 4);
 	NPC_SCAN_HDR(NPC_DIP_IPV4, NPC_LID_LC, NPC_LT_LC_IP, 16, 4);
 	NPC_SCAN_HDR(NPC_IPFRAG_IPV6, NPC_LID_LC, NPC_LT_LC_IP6_EXT, 6, 1);
-	NPC_SCAN_HDR(NPC_SIP_IPV6, NPC_LID_LC, NPC_LT_LC_IP6, 8, 16);
-	NPC_SCAN_HDR(NPC_DIP_IPV6, NPC_LID_LC, NPC_LT_LC_IP6, 24, 16);
+	if (rvu->hw->cap.npc_hash_extract) {
+		if (mkex_hash->lid_lt_ld_hash_en[intf][lid][lt][0])
+			NPC_SCAN_HDR(NPC_SIP_IPV6, NPC_LID_LC, NPC_LT_LC_IP6, 8, 4);
+		else
+			NPC_SCAN_HDR(NPC_SIP_IPV6, NPC_LID_LC, NPC_LT_LC_IP6, 8, 16);
+
+		if (mkex_hash->lid_lt_ld_hash_en[intf][lid][lt][1])
+			NPC_SCAN_HDR(NPC_DIP_IPV6, NPC_LID_LC, NPC_LT_LC_IP6, 24, 4);
+		else
+			NPC_SCAN_HDR(NPC_DIP_IPV6, NPC_LID_LC, NPC_LT_LC_IP6, 24, 16);
+	} else {
+		NPC_SCAN_HDR(NPC_SIP_IPV6, NPC_LID_LC, NPC_LT_LC_IP6, 8, 16);
+		NPC_SCAN_HDR(NPC_DIP_IPV6, NPC_LID_LC, NPC_LT_LC_IP6, 24, 16);
+	}
+
 	NPC_SCAN_HDR(NPC_SPORT_UDP, NPC_LID_LD, NPC_LT_LD_UDP, 0, 2);
 	NPC_SCAN_HDR(NPC_DPORT_UDP, NPC_LID_LD, NPC_LT_LD_UDP, 2, 2);
 	NPC_SCAN_HDR(NPC_SPORT_TCP, NPC_LID_LD, NPC_LT_LD_TCP, 0, 2);
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.h +4 -0
index bdd65ce56a32..3f5c9042d10e 100644
@@ -9,6 +9,10 @@
 #define __RVU_NPC_FS_H
 
 #define IPV6_WORDS	4
+#define NPC_BYTESM	GENMASK_ULL(19, 16)
+#define NPC_HDR_OFFSET	GENMASK_ULL(15, 8)
+#define NPC_KEY_OFFSET	GENMASK_ULL(5, 0)
+#define NPC_LDATA_EN	BIT_ULL(7)
 
 void npc_update_entry(struct rvu *rvu, enum key_fields type,
 		      struct mcam_entry *entry, u64 val_lo,
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c +69 -52

227 lines not on this page · raw message

drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.h +8 -2
index 3efeb09c58de..a1c3d987b804 100644
@@ -31,6 +31,12 @@
 	rvu_write64(rvu, blkaddr,	\
 		    NPC_AF_INTFX_HASHX_MASKX(intf, ld, mask_idx), cfg)
 
+#define GET_KEX_LD_HASH_CTRL(intf, ld)	\
+	rvu_read64(rvu, blkaddr, NPC_AF_INTFX_HASHX_RESULT_CTRL(intf, ld))
+
+#define GET_KEX_LD_HASH_MASK(intf, ld, mask_idx)	\
+	rvu_read64(rvu, blkaddr, NPC_AF_INTFX_HASHX_MASKX(intf, ld, mask_idx))
+
 #define SET_KEX_LD_HASH_CTRL(intf, ld, cfg) \
 	rvu_write64(rvu, blkaddr,	\
 		    NPC_AF_INTFX_HASHX_RESULT_CTRL(intf, ld), cfg)
@@ -56,8 +62,8 @@ void npc_update_field_hash(struct rvu *rvu, u8 intf,
 			   struct flow_msg *omask);
 void npc_config_secret_key(struct rvu *rvu, int blkaddr);
 void npc_program_mkex_hash(struct rvu *rvu, int blkaddr);
-u32 npc_field_hash_calc(u64 *ldata, struct npc_mcam_kex_hash *mkex_hash,
-			u64 *secret_key, u8 intf, u8 hash_idx);
+u32 npc_field_hash_calc(u64 *ldata, struct npc_get_field_hash_info_rsp rsp,
+			u8 intf, u8 hash_idx);
 
 static struct npc_mcam_kex_hash npc_mkex_hash_default __maybe_unused = {
 	.lid_lt_ld_hash_en = {
Signature · 1 line
2.25.1
#16 lore raw

PATCH v2 6/7 octeontx2-af: Skip PFs if not enabled

In reply to Sai Krishna

From: Ratheesh Kannoth <[email protected]>

Skip mbox initialization of disabled PFs. Firmware configures PFs and allocate mbox resources etc. Linux should configure particular PFs, which ever are enabled by firmware.

Fixes 9bdc47a6e328 ("octeontx2-af: Mbox communication support btw AF and it's VFs")
---
 .../net/ethernet/marvell/octeontx2/af/mbox.c  |  5 ++-
 .../net/ethernet/marvell/octeontx2/af/mbox.h  |  3 +-
 .../net/ethernet/marvell/octeontx2/af/rvu.c   | 38 ++++++++++++++++---
 3 files changed, 39 insertions(+), 7 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/mbox.c +4 -1
index 2898931d5260..9690ac01f02c 100644
@@ -157,7 +157,7 @@ EXPORT_SYMBOL(otx2_mbox_init);
  */
 int otx2_mbox_regions_init(struct otx2_mbox *mbox, void **hwbase,
 			   struct pci_dev *pdev, void *reg_base,
-			   int direction, int ndevs)
+			   int direction, int ndevs, unsigned long *pf_bmap)
 {
 	struct otx2_mbox_dev *mdev;
 	int devid, err;
@@ -169,6 +169,9 @@ int otx2_mbox_regions_init(struct otx2_mbox *mbox, void **hwbase,
 	mbox->hwbase = hwbase[0];
 
 	for (devid = 0; devid < ndevs; devid++) {
+		if (!test_bit(devid, pf_bmap))
+			continue;
+
 		mdev = &mbox->dev[devid];
 		mdev->mbase = hwbase[devid];
 		mdev->hwbase = hwbase[devid];
drivers/net/ethernet/marvell/octeontx2/af/mbox.h +2 -1
index 0ce533848536..26636a4d7dcc 100644
@@ -96,9 +96,10 @@ void otx2_mbox_destroy(struct otx2_mbox *mbox);
 int otx2_mbox_init(struct otx2_mbox *mbox, void __force *hwbase,
 		   struct pci_dev *pdev, void __force *reg_base,
 		   int direction, int ndevs);
+
 int otx2_mbox_regions_init(struct otx2_mbox *mbox, void __force **hwbase,
 			   struct pci_dev *pdev, void __force *reg_base,
-			   int direction, int ndevs);
+			   int direction, int ndevs, unsigned long *bmap);
 void otx2_mbox_msg_send(struct otx2_mbox *mbox, int devid);
 int otx2_mbox_wait_for_rsp(struct otx2_mbox *mbox, int devid);
 int otx2_mbox_busy_poll_for_rsp(struct otx2_mbox *mbox, int devid);
drivers/net/ethernet/marvell/octeontx2/af/rvu.c +33 -5
index 8683ce57ed3f..61c658fa3f28 100644
@@ -2282,7 +2282,7 @@ static inline void rvu_afvf_mbox_up_handler(struct work_struct *work)
 }
 
 static int rvu_get_mbox_regions(struct rvu *rvu, void **mbox_addr,
-				int num, int type)
+				int num, int type, unsigned long *pf_bmap)
 {
 	struct rvu_hwinfo *hw = rvu->hw;
 	int region;
@@ -2294,6 +2294,9 @@ static int rvu_get_mbox_regions(struct rvu *rvu, void **mbox_addr,
 	 */
 	if (type == TYPE_AFVF) {
 		for (region = 0; region < num; region++) {
+			if (!test_bit(region, pf_bmap))
+				continue;
+
 			if (hw->cap.per_pf_mbox_regs) {
 				bar4 = rvu_read64(rvu, BLKADDR_RVUM,
 						  RVU_AF_PFX_BAR4_ADDR(0)) +
@@ -2315,6 +2318,9 @@ static int rvu_get_mbox_regions(struct rvu *rvu, void **mbox_addr,
 	 * RVU_AF_PF_BAR4_ADDR register.
 	 */
 	for (region = 0; region < num; region++) {
+		if (!test_bit(region, pf_bmap))
+			continue;
+
 		if (hw->cap.per_pf_mbox_regs) {
 			bar4 = rvu_read64(rvu, BLKADDR_RVUM,
 					  RVU_AF_PFX_BAR4_ADDR(region));
@@ -2343,8 +2349,27 @@ static int rvu_mbox_init(struct rvu *rvu, struct mbox_wq_info *mw,
 	int err = -EINVAL, i, dir, dir_up;
 	void __iomem *reg_base;
 	struct rvu_work *mwork;
+	unsigned long *pf_bmap;
 	void **mbox_regions;
 	const char *name;
+	u64 cfg;
+
+	pf_bmap = devm_kcalloc(rvu->dev, BITS_TO_LONGS(num), sizeof(long), GFP_KERNEL);
+	if (!pf_bmap)
+		return -ENOMEM;
+
+	/* RVU VFs */
+	if (type == TYPE_AFVF)
+		bitmap_set(pf_bmap, 0, num);
+
+	if (type == TYPE_AFPF) {
+		/* Mark enabled PFs in bitmap */
+		for (i = 0; i < num; i++) {
+			cfg = rvu_read64(rvu, BLKADDR_RVUM, RVU_PRIV_PFX_CFG(i));
+			if (cfg & BIT_ULL(20))
+				set_bit(i, pf_bmap);
+		}
+	}
 
 	mbox_regions = kcalloc(num, sizeof(void *), GFP_KERNEL);
 	if (!mbox_regions)
@@ -2356,7 +2381,7 @@ static int rvu_mbox_init(struct rvu *rvu, struct mbox_wq_info *mw,
 		dir = MBOX_DIR_AFPF;
 		dir_up = MBOX_DIR_AFPF_UP;
 		reg_base = rvu->afreg_base;
-		err = rvu_get_mbox_regions(rvu, mbox_regions, num, TYPE_AFPF);
+		err = rvu_get_mbox_regions(rvu, mbox_regions, num, TYPE_AFPF, pf_bmap);
 		if (err)
 			goto free_regions;
 		break;
@@ -2365,7 +2390,7 @@ static int rvu_mbox_init(struct rvu *rvu, struct mbox_wq_info *mw,
 		dir = MBOX_DIR_PFVF;
 		dir_up = MBOX_DIR_PFVF_UP;
 		reg_base = rvu->pfreg_base;
-		err = rvu_get_mbox_regions(rvu, mbox_regions, num, TYPE_AFVF);
+		err = rvu_get_mbox_regions(rvu, mbox_regions, num, TYPE_AFVF, pf_bmap);
 		if (err)
 			goto free_regions;
 		break;
@@ -2396,16 +2421,19 @@ static int rvu_mbox_init(struct rvu *rvu, struct mbox_wq_info *mw,
 	}
 
 	err = otx2_mbox_regions_init(&mw->mbox, mbox_regions, rvu->pdev,
-				     reg_base, dir, num);
+				     reg_base, dir, num, pf_bmap);
 	if (err)
 		goto exit;
 
 	err = otx2_mbox_regions_init(&mw->mbox_up, mbox_regions, rvu->pdev,
-				     reg_base, dir_up, num);
+				     reg_base, dir_up, num, pf_bmap);
 	if (err)
 		goto exit;
 
 	for (i = 0; i < num; i++) {
+		if (!test_bit(i, pf_bmap))
+			continue;
+
 		mwork = &mw->mbox_wrk[i];
 		mwork->rvu = rvu;
 		INIT_WORK(&mwork->work, mbox_handler);
Signature · 1 line
2.25.1
#19 lore raw

PATCH v2 7/7 octeontx2-pf: Disable packet I/O for graceful exit

In reply to Sai Krishna

From: Subbaraya Sundeep <[email protected]>

At the stage of enabling packet I/O in otx2_open, If mailbox timeout occurs then interface ends up in down state where as hardware packet I/O is enabled. Hence disable packet I/O also before bailing out. This patch also free the LMTST per cpu structure on teardown, if the lmt_info pointer is not NULL.

Fixes 1ea0166da050 ("octeontx2-pf: Fix the device state on error")
---
 drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c | 11 ++++++++++-
 drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c |  8 +++++---
 2 files changed, 15 insertions(+), 4 deletions(-)
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +10 -1
index 179433d0a54a..52a57d2493dc 100644
@@ -1835,13 +1835,22 @@ int otx2_open(struct net_device *netdev)
 		otx2_dmacflt_reinstall_flows(pf);
 
 	err = otx2_rxtx_enable(pf, true);
-	if (err)
+	/* If a mbox communication error happens at this point then interface
+	 * will end up in a state such that it is in down state but hardware
+	 * mcam entries are enabled to receive the packets. Hence disable the
+	 * packet I/O.
+	 */
+	if (err == EIO)
+		goto err_disable_rxtx;
+	else if (err)
 		goto err_tx_stop_queues;
 
 	otx2_do_set_rx_mode(pf);
 
 	return 0;
 
+err_disable_rxtx:
+	otx2_rxtx_enable(pf, false);
 err_tx_stop_queues:
 	netif_tx_stop_all_queues(netdev);
 	netif_carrier_off(netdev);
drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c +5 -3
index ab126f8706c7..6ab4780f12fd 100644
@@ -621,7 +621,7 @@ static int otx2vf_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 
 	err = otx2vf_realloc_msix_vectors(vf);
 	if (err)
-		goto err_mbox_destroy;
+		goto err_detach_rsrc;
 
 	err = otx2_set_real_num_queues(netdev, qcount, qcount);
 	if (err)
@@ -709,7 +709,8 @@ static int otx2vf_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 err_ptp_destroy:
 	otx2_ptp_destroy(vf);
 err_detach_rsrc:
-	free_percpu(vf->hw.lmt_info);
+	if (vf->hw.lmt_info)
+		free_percpu(vf->hw.lmt_info);
 	if (test_bit(CN10K_LMTST, &vf->hw.cap_flag))
 		qmem_free(vf->dev, vf->dync_lmt);
 	otx2_detach_resources(&vf->mbox);
@@ -763,7 +764,8 @@ static void otx2vf_remove(struct pci_dev *pdev)
 	otx2_shutdown_tc(vf);
 	otx2vf_disable_mbox_intr(vf);
 	otx2_detach_resources(&vf->mbox);
-	free_percpu(vf->hw.lmt_info);
+	if (vf->hw.lmt_info)
+		free_percpu(vf->hw.lmt_info);
 	if (test_bit(CN10K_LMTST, &vf->hw.cap_flag))
 		qmem_free(vf->dev, vf->dync_lmt);
 	otx2vf_vfaf_mbox_destroy(vf);
Signature · 1 line
2.25.1
#20 lore raw

Re: [net PATCH v2 7/7] octeontx2-pf: Disable packet I/O for graceful exit

Quoted 12 lines · Sai Krishna

From: Subbaraya Sundeep <[email protected]>

At the stage of enabling packet I/O in otx2_open, If mailbox timeout occurs then interface ends up in down state where as hardware packet I/O is enabled. Hence disable packet I/O also before bailing out. This patch also free the LMTST per cpu structure on teardown, if the lmt_info pointer is not NULL.

Fixes 1ea0166da050 ("octeontx2-pf: Fix the device state on error")

...

drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c static int otx2vf_probe(struct pci_dev *pdev, const struct pci_device_id *id) · line 713

Quoted 7 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c +2 -1
@@ -709,7 +709,8 @@ static int otx2vf_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 err_ptp_destroy:
 	otx2_ptp_destroy(vf);
 err_detach_rsrc:
-	free_percpu(vf->hw.lmt_info);
+	if (vf->hw.lmt_info)
+		free_percpu(vf->hw.lmt_info);

free_percpu does nothing if it's argument is NULL. So there is no need for the if clause added here.

drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c static void otx2vf_remove(struct pci_dev *pdev) · line 768

Quoted 10 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c +2 -1
 	if (test_bit(CN10K_LMTST, &vf->hw.cap_flag))
 		qmem_free(vf->dev, vf->dync_lmt);
 	otx2_detach_resources(&vf->mbox);
@@ -763,7 +764,8 @@ static void otx2vf_remove(struct pci_dev *pdev)
 	otx2_shutdown_tc(vf);
 	otx2vf_disable_mbox_intr(vf);
 	otx2_detach_resources(&vf->mbox);
-	free_percpu(vf->hw.lmt_info);
+	if (vf->hw.lmt_info)
+		free_percpu(vf->hw.lmt_info);

Ditto.

Quoted 6 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c +0 -0
 	if (test_bit(CN10K_LMTST, &vf->hw.cap_flag))
 		qmem_free(vf->dev, vf->dync_lmt);
 	otx2vf_vfaf_mbox_destroy(vf);
Signature · 1 line
2.25.1
#2 lore raw

Re: [net PATCH v2 1/7] octeontx2-af: Secure APR table update with the lock

In reply to Sai Krishna
Quoted 7 lines · Sai Krishna

From: Geetha sowjanya <[email protected]>

APR table contains the lmtst base address of PF/VFs. These entries are updated by the PF/VF during the device probe. Due to race condition while updating the entries are getting corrupted. Hence secure the APR table update with the lock.

Hi Sai, Geetha,

I think it would be useful to describe what races with rvu_mbox_handler_lmtst_tbl_setup().

...

#5 lore raw

Re: [net PATCH v2 2/7] octeontx2-af: Fix start and end bit for scan config

In reply to Sai Krishna
Quoted 11 lines · Sai Krishna

From: Ratheesh Kannoth <[email protected]>

Fix the NPC nibble start and end positions in the bit map. Fix the depth of cam and mem table configuration. Increased the field size of dmac filter flows as cn10kb support large in number.

Fixes b747923afff8 ("octeontx2-af: Exact match support")

Hi Sai, Ratheesh,

this is fixing a number of things.
So I wonder if it would make sense to break this
into multiple patches: one per thing.

Reviewed-by on v2 3/7
#8 lore raw

Re: [net PATCH v2 3/7] octeontx2-af: Add validation for lmac type

In reply to Sai Krishna
Quoted 20 lines · Sai Krishna

From: Hariprasad Kelam <[email protected]>

Upon physical link change, firmware reports to the kernel about the change along with the details like speed, lmac_type_id, etc. Kernel derives lmac_type based on lmac_type_id received from firmware.

In a few scenarios, firmware returns an invalid lmac_type_id, which is resulting in below kernel panic. This patch adds the missing validation of the lmac_type_id field.

Internal error: Oops: 96000005 [#1] PREEMPT SMP
[   35.321595] Modules linked in:
[   35.328982] CPU: 0 PID: 31 Comm: kworker/0:1 Not tainted
5.4.210-g2e3169d8e1bc-dirty #17
[   35.337014] Hardware name: Marvell CN103XX board (DT)
[   35.344297] Workqueue: events work_for_cpu_fn
[   35.352730] pstate: 40400089 (nZcv daIf +PAN -UAO)
[   35.360267] pc : strncpy+0x10/0x30
[   35.366595] lr : cgx_link_change_handler+0x90/0x180
Quoted 7 lines
Fixes 61071a871ea6 ("octeontx2-af: Forward CGX link notifications to PFs")
 drivers/net/ethernet/marvell/octeontx2/af/cgx.c | 8 ++++++++
 1 file changed, 8 insertions(+)
Reviewed-by on v2 4/7
#12 lore raw

Re: [net PATCH v2 4/7] octeontx2-af: Update correct mask to filter IPv4 fragments

In reply to Sai Krishna
Quoted 11 lines · Sai Krishna

From: Suman Ghosh <[email protected]>

During the initial design, the IPv4 ip_flag mask was set to 0xff. Which results to filter only fragmets with (fragment_offset == 0). As part of the fix, updated the mask to 0x20 to filter all the fragmented packets irrespective of the fragment_offset value.

Fixes c672e3727989 ("octeontx2-pf: Add support to filter packet based on IP fragment")
#17 lore raw

Re: [net PATCH v2 6/7] octeontx2-af: Skip PFs if not enabled

In reply to Sai Krishna
Quoted 10 lines · Sai Krishna

From: Ratheesh Kannoth <[email protected]>

Skip mbox initialization of disabled PFs. Firmware configures PFs and allocate mbox resources etc. Linux should configure particular PFs, which ever are enabled by firmware.

Fixes 9bdc47a6e328 ("octeontx2-af: Mbox communication support btw AF and it's VFs")

...

drivers/net/ethernet/marvell/octeontx2/af/rvu.c static int rvu_mbox_init(struct rvu *rvu, struct mbox_wq_info *mw, · line 2357

Quoted 10 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu.c +4 -0
@@ -2343,8 +2349,27 @@ static int rvu_mbox_init(struct rvu *rvu, struct mbox_wq_info *mw,
 	int err = -EINVAL, i, dir, dir_up;
 	void __iomem *reg_base;
 	struct rvu_work *mwork;
+	unsigned long *pf_bmap;
 	void **mbox_regions;
 	const char *name;
+	u64 cfg;
+
+	pf_bmap = devm_kcalloc(rvu->dev, BITS_TO_LONGS(num), sizeof(long), GFP_KERNEL);

Hi Sai and Ratheesh,

I am a little confused about the lifecycle of pf_bmap. It is a local variable of this function.
But it is allocated using devm_kcalloc(), so it will persist for the life of the device.

Also, I note that rvu_mbox_init() has too call sites.
So is there a situation where a pf_bmap is allocated more than once for the same rvu->dev instance?

It seems to me it would be more appropriate to allocate bf_bmap using kcalloc() take clear to free it before leaving rvu_mbox_init(), as is already done for mbox_regions.

Quoted 2 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu.c +2 -0
+	if (!pf_bmap)
+		return -ENOMEM;

...

#14 lore raw

Re: [net PATCH v2 5/7] octeontx2-af: Fix issues with NPC field hash extract

In reply to Sai Krishna
Quoted 14 lines · Sai Krishna

From: Ratheesh Kannoth <[email protected]>

1. As per previous implementation, mask and control parameter to generate the field hash value was not passed to the caller program. Updated the secret key mbox to share that information as well, as a part of the fix.
2. Earlier implementation did not consider hash reduction of both source and destination IPv6 addresses. Only source IPv6 address was considered. This fix solves that and provides option to hash reduce both source and destination IPv6 addresses.
3. Fix endianness issue during hash reduction while storing the IPv6 source/destination address as hash keys.
4. Configure hardware parser based on hash extract feature enable flag for IPv6.

Hi Sai and Ratheesh,

there is a lot going on here.
Could you consider breaking this up into more than one patch?

#9 lore raw

Re: [net PATCH v2 3/7] octeontx2-af: Add validation for lmac type

In reply to Sai Krishna
Quoted 20 lines · Sai Krishna

From: Hariprasad Kelam <[email protected]>

Upon physical link change, firmware reports to the kernel about the change along with the details like speed, lmac_type_id, etc. Kernel derives lmac_type based on lmac_type_id received from firmware.

In a few scenarios, firmware returns an invalid lmac_type_id, which is resulting in below kernel panic. This patch adds the missing validation of the lmac_type_id field.

Internal error: Oops: 96000005 [#1] PREEMPT SMP
[   35.321595] Modules linked in:
[   35.328982] CPU: 0 PID: 31 Comm: kworker/0:1 Not tainted
5.4.210-g2e3169d8e1bc-dirty #17
[   35.337014] Hardware name: Marvell CN103XX board (DT)
[   35.344297] Workqueue: events work_for_cpu_fn
[   35.352730] pstate: 40400089 (nZcv daIf +PAN -UAO)
[   35.360267] pc : strncpy+0x10/0x30
[   35.366595] lr : cgx_link_change_handler+0x90/0x180
Quoted 5 lines
Fixes 61071a871ea6 ("octeontx2-af: Forward CGX link notifications to PFs")

Your patch missing --- trailers and probably won't apply correctly.

Thanks

Quoted 25 lines
 drivers/net/ethernet/marvell/octeontx2/af/cgx.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/net/ethernet/marvell/octeontx2/af/cgx.c +8 -0
index 724df6398bbe..bd77152bb8d7 100644
@@ -1231,6 +1231,14 @@ static inline void link_status_user_format(u64 lstat,
 	linfo->an = FIELD_GET(RESP_LINKSTAT_AN, lstat);
 	linfo->fec = FIELD_GET(RESP_LINKSTAT_FEC, lstat);
 	linfo->lmac_type_id = FIELD_GET(RESP_LINKSTAT_LMAC_TYPE, lstat);
+
+	if (linfo->lmac_type_id >= LMAC_MODE_MAX) {
+		dev_err(&cgx->pdev->dev, "Unknown lmac_type_id %d reported by firmware on cgx port%d:%d",
+			linfo->lmac_type_id, cgx->cgx_id, lmac_id);
+		strncpy(linfo->lmac_type, "Unknown", LMACTYPE_STR_LEN - 1);
+		return;
+	}
+
 	lmac_string = cgx_lmactype_string[linfo->lmac_type_id];
 	strncpy(linfo->lmac_type, lmac_string, LMACTYPE_STR_LEN - 1);
 }
Signature · 1 line
2.25.1
#10 lore raw

Re: [net PATCH v2 3/7] octeontx2-af: Add validation for lmac type

Please see inline,

Quoted 35 lines

-----Original Message-----
From: Leon Romanovsky <[email protected]>
Sent: Sunday, April 9, 2023 11:00 PM
To: Sai Krishna Gajula <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; linux- [email protected]; Sunil Kovvuri Goutham <[email protected]>; Geethasowjanya Akula <[email protected]>; [email protected]; Linu Cherian <[email protected]>; Jerin Jacob Kollanukkaran <[email protected]>; Hariprasad Kelam <[email protected]>; Subbaraya Sundeep Bhatta <[email protected]>
Subject: Re: [net PATCH v2 3/7] octeontx2-af: Add validation for lmac type

Quoted 20 lines · Sai Krishna

From: Hariprasad Kelam <[email protected]>

Upon physical link change, firmware reports to the kernel about the change along with the details like speed, lmac_type_id, etc. Kernel derives lmac_type based on lmac_type_id received from firmware.

In a few scenarios, firmware returns an invalid lmac_type_id, which is resulting in below kernel panic. This patch adds the missing validation of the lmac_type_id field.

Internal error: Oops: 96000005 [#1] PREEMPT SMP
[   35.321595] Modules linked in:
[   35.328982] CPU: 0 PID: 31 Comm: kworker/0:1 Not tainted
5.4.210-g2e3169d8e1bc-dirty #17
[   35.337014] Hardware name: Marvell CN103XX board (DT)
[   35.344297] Workqueue: events work_for_cpu_fn
[   35.352730] pstate: 40400089 (nZcv daIf +PAN -UAO)
[   35.360267] pc : strncpy+0x10/0x30
[   35.366595] lr : cgx_link_change_handler+0x90/0x180
Quoted 9 lines
Quoted 6 lines
Fixes 61071a871ea6 ("octeontx2-af: Forward CGX link notifications to

PFs")

Your patch missing --- trailers and probably won't apply correctly.

We will fix trailers errors in V3 patch.

Thanks,
Sai

Quoted 31 lines

Thanks

drivers/net/ethernet/marvell/octeontx2/af/cgx.c static inline void link_status_user_format(u64

Quoted 9 lines
 drivers/net/ethernet/marvell/octeontx2/af/cgx.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/net/ethernet/marvell/octeontx2/af/cgx.c +0 -0
index 724df6398bbe..bd77152bb8d7 100644
@@ -1231,6 +1231,14 @@ static inline void link_status_user_format(u64

lstat,

drivers/net/ethernet/marvell/octeontx2/af/cgx.c static inline void link_status_user_format(u64 lstat,

Quoted 3 lines
drivers/net/ethernet/marvell/octeontx2/af/cgx.c +0 -0
 	linfo->an = FIELD_GET(RESP_LINKSTAT_AN, lstat);
 	linfo->fec = FIELD_GET(RESP_LINKSTAT_FEC, lstat);
 	linfo->lmac_type_id = FIELD_GET(RESP_LINKSTAT_LMAC_TYPE,

lstat);

drivers/net/ethernet/marvell/octeontx2/af/cgx.c static inline void link_status_user_format(u64 lstat,

Quoted 3 lines
drivers/net/ethernet/marvell/octeontx2/af/cgx.c +3 -0
+
+	if (linfo->lmac_type_id >= LMAC_MODE_MAX) {
+		dev_err(&cgx->pdev->dev, "Unknown lmac_type_id %d

reported by firmware on cgx port%d:%d",

drivers/net/ethernet/marvell/octeontx2/af/cgx.c static inline void link_status_user_format(u64 · line 1238

Quoted 2 lines
drivers/net/ethernet/marvell/octeontx2/af/cgx.c +2 -0
+			linfo->lmac_type_id, cgx->cgx_id, lmac_id);
+		strncpy(linfo->lmac_type, "Unknown", LMACTYPE_STR_LEN -

1);

Quoted 8 lines
drivers/net/ethernet/marvell/octeontx2/af/cgx.c +3 -1
+		return;
+	}
+
 	lmac_string = cgx_lmactype_string[linfo->lmac_type_id];
 	strncpy(linfo->lmac_type, lmac_string, LMACTYPE_STR_LEN - 1);  }
--

2.25.1

#3 lore raw

Re: [net PATCH v2 1/7] octeontx2-af: Secure APR table update with the lock

In reply to Simon Horman

Please see inline,

Quoted 22 lines

-----Original Message-----
From: Simon Horman <[email protected]>
Sent: Saturday, April 8, 2023 8:03 PM
To: Sai Krishna Gajula <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; linux- [email protected]; Sunil Kovvuri Goutham <[email protected]>; Geethasowjanya Akula <[email protected]>; [email protected]; Linu Cherian <[email protected]>; Jerin Jacob Kollanukkaran <[email protected]>; Hariprasad Kelam <[email protected]>; Subbaraya Sundeep Bhatta <[email protected]>
Subject: Re: [net PATCH v2 1/7] octeontx2-af: Secure APR table update with the lock

Quoted 6 lines · Sai Krishna

From: Geetha sowjanya <[email protected]>

APR table contains the lmtst base address of PF/VFs.
These entries are updated by the PF/VF during the device probe. Due to race condition while updating the entries are getting corrupted. Hence secure the APR table update with the lock.

Quoted 4 lines

Hi Sai, Geetha,

I think it would be useful to describe what races with rvu_mbox_handler_lmtst_tbl_setup().

We will rewrite comment message and submit v3 patch.

Thanks,
Sai

Quoted 2 lines

...

#6 lore raw

Re: [net PATCH v2 2/7] octeontx2-af: Fix start and end bit for scan config

In reply to Simon Horman

Please see inline,

Quoted 28 lines

-----Original Message-----
From: Simon Horman <[email protected]>
Sent: Saturday, April 8, 2023 8:11 PM
To: Sai Krishna Gajula <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; linux- [email protected]; Sunil Kovvuri Goutham <[email protected]>; Geethasowjanya Akula <[email protected]>; [email protected]; Linu Cherian <[email protected]>; Jerin Jacob Kollanukkaran <[email protected]>; Hariprasad Kelam <[email protected]>; Subbaraya Sundeep Bhatta <[email protected]>; Ratheesh Kannoth <[email protected]>
Subject: Re: [net PATCH v2 2/7] octeontx2-af: Fix start and end bit for scan config

Quoted 11 lines · Sai Krishna

From: Ratheesh Kannoth <[email protected]>

Fix the NPC nibble start and end positions in the bit map. Fix the depth of cam and mem table configuration.
Increased the field size of dmac filter flows as cn10kb support large in number.

Fixes b747923afff8 ("octeontx2-af: Exact match support")
Quoted 5 lines

Hi Sai, Ratheesh,

this is fixing a number of things.
So I wonder if it would make sense to break this into multiple patches: one per thing.

We will break this patch into multiple patches and submit v3.

Thanks,
Sai

#21 lore raw

Re: [net PATCH v2 7/7] octeontx2-pf: Disable packet I/O for graceful exit

In reply to Simon Horman

Please see inline,

Quoted 30 lines

-----Original Message-----
From: Simon Horman <[email protected]>
Sent: Saturday, April 8, 2023 8:00 PM
To: Sai Krishna Gajula <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; linux- [email protected]; Sunil Kovvuri Goutham <[email protected]>; Geethasowjanya Akula <[email protected]>; [email protected]; Linu Cherian <[email protected]>; Jerin Jacob Kollanukkaran <[email protected]>; Hariprasad Kelam <[email protected]>; Subbaraya Sundeep Bhatta <[email protected]>
Subject: Re: [net PATCH v2 7/7] octeontx2-pf: Disable packet I/O for graceful exit

Quoted 12 lines · Sai Krishna

From: Subbaraya Sundeep <[email protected]>

At the stage of enabling packet I/O in otx2_open, If mailbox timeout occurs then interface ends up in down state where as hardware packet I/O is enabled. Hence disable packet I/O also before bailing out. This patch also free the LMTST per cpu structure on teardown, if the lmt_info pointer is not NULL.

Fixes 1ea0166da050 ("octeontx2-pf: Fix the device state on error")

...

Quoted 11 lines

drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c static int otx2vf_probe(struct pci_dev *pdev, · line 714

Quoted 8 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c +2 -1
@@ -709,7 +709,8 @@ static int otx2vf_probe(struct pci_dev *pdev,
 const struct pci_device_id *id)
 err_ptp_destroy:
 	otx2_ptp_destroy(vf);
 err_detach_rsrc:
-	free_percpu(vf->hw.lmt_info);
+	if (vf->hw.lmt_info)
+		free_percpu(vf->hw.lmt_info);

free_percpu does nothing if it's argument is NULL. So there is no need for the if clause added here.

We will submit v3 patch as per review comments.

Quoted 13 lines

drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c static void otx2vf_remove(struct pci_dev *pdev) · line 768

Quoted 11 lines
(quoted diff) +0 -0
 	if (test_bit(CN10K_LMTST, &vf->hw.cap_flag))
 		qmem_free(vf->dev, vf->dync_lmt);
drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c +2 -1
 	otx2_detach_resources(&vf->mbox);
@@ -763,7 +764,8 @@ static void otx2vf_remove(struct pci_dev *pdev)
 	otx2_shutdown_tc(vf);
 	otx2vf_disable_mbox_intr(vf);
 	otx2_detach_resources(&vf->mbox);
-	free_percpu(vf->hw.lmt_info);
+	if (vf->hw.lmt_info)
+		free_percpu(vf->hw.lmt_info);

Ditto.

We will submit v3 patch as per review comments.

Thanks,
Sai

Quoted 7 lines
Quoted 7 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c +0 -1
 	if (test_bit(CN10K_LMTST, &vf->hw.cap_flag))
 		qmem_free(vf->dev, vf->dync_lmt);
 	otx2vf_vfaf_mbox_destroy(vf);
--

2.25.1

#15 lore raw

Re: [net PATCH v2 5/7] octeontx2-af: Fix issues with NPC field hash extract

In reply to Simon Horman

Please see inline,

Quoted 31 lines

-----Original Message-----
From: Simon Horman <[email protected]>
Sent: Saturday, April 8, 2023 8:51 PM
To: Sai Krishna Gajula <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; linux- [email protected]; Sunil Kovvuri Goutham <[email protected]>; Geethasowjanya Akula <[email protected]>; [email protected]; Linu Cherian <[email protected]>; Jerin Jacob Kollanukkaran <[email protected]>; Hariprasad Kelam <[email protected]>; Subbaraya Sundeep Bhatta <[email protected]>; Ratheesh Kannoth <[email protected]>
Subject: Re: [net PATCH v2 5/7] octeontx2-af: Fix issues with NPC field hash extract

Quoted 14 lines · Sai Krishna

From: Ratheesh Kannoth <[email protected]>

1. As per previous implementation, mask and control parameter to generate the field hash value was not passed to the caller program. Updated the secret key mbox to share that information as well, as a part of the fix.
2. Earlier implementation did not consider hash reduction of both source and destination IPv6 addresses. Only source IPv6 address was considered. This fix solves that and provides option to hash reduce both source and destination IPv6 addresses.
3. Fix endianness issue during hash reduction while storing the IPv6 source/destination address as hash keys.
4. Configure hardware parser based on hash extract feature enable flag for IPv6.

Quoted 4 lines

Hi Sai and Ratheesh,

there is a lot going on here.
Could you consider breaking this up into more than one patch?

We will break this patch into multiple patches and submit v3.

Thanks,
Sai

#18 lore raw

Re: [net PATCH v2 6/7] octeontx2-af: Skip PFs if not enabled

In reply to Simon Horman

Please see inline,

Quoted 50 lines

-----Original Message-----
From: Simon Horman <[email protected]>
Sent: Saturday, April 8, 2023 8:26 PM
To: Sai Krishna Gajula <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; linux- [email protected]; Sunil Kovvuri Goutham <[email protected]>; Geethasowjanya Akula <[email protected]>; [email protected]; Linu Cherian <[email protected]>; Jerin Jacob Kollanukkaran <[email protected]>; Hariprasad Kelam <[email protected]>; Subbaraya Sundeep Bhatta <[email protected]>; Ratheesh Kannoth <[email protected]>
Subject: Re: [net PATCH v2 6/7] octeontx2-af: Skip PFs if not enabled

Quoted 11 lines · Sai Krishna

From: Ratheesh Kannoth <[email protected]>

Skip mbox initialization of disabled PFs. Firmware configures PFs and allocate mbox resources etc. Linux should configure particular PFs, which ever are enabled by firmware.

Fixes 9bdc47a6e328 ("octeontx2-af: Mbox communication support btw AF

and it's VFs")

...

Review static int rvu_mbox_init(struct rvu *rvu, struct

Quoted 1 line
(quoted diff) +0 -0
@@ -2343,8 +2349,27 @@ static int rvu_mbox_init(struct rvu *rvu, struct

mbox_wq_info *mw,

drivers/net/ethernet/marvell/octeontx2/af/rvu.c static int rvu_mbox_init(struct rvu *rvu, struct mbox_wq_info *mw,

Quoted 9 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu.c +4 -0
 	int err = -EINVAL, i, dir, dir_up;
 	void __iomem *reg_base;
 	struct rvu_work *mwork;
+	unsigned long *pf_bmap;
 	void **mbox_regions;
 	const char *name;
+	u64 cfg;
+
+	pf_bmap = devm_kcalloc(rvu->dev, BITS_TO_LONGS(num),

sizeof(long),

Review static int rvu_mbox_init(struct rvu *rvu, struct · line 2358

Quoted 1 line
(quoted diff) +1 -0
+GFP_KERNEL);

Hi Sai and Ratheesh,

I am a little confused about the lifecycle of pf_bmap.
It is a local variable of this function.
But it is allocated using devm_kcalloc(), so it will persist for the life of the device.

Quoted 8 lines

Also, I note that rvu_mbox_init() has too call sites.
So is there a situation where a pf_bmap is allocated more than once for the same rvu->dev instance?

It seems to me it would be more appropriate to allocate bf_bmap using kcalloc() take clear to free it before leaving rvu_mbox_init(), as is already done for mbox_regions.

We will prepare v3 patch according to the suggested changes using kcalloc().

Quoted 4 lines
Quoted 2 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu.c +2 -0
+	if (!pf_bmap)
+		return -ENOMEM;

...