Skip to contentSkip to conversation

qed: Read device port count from the shmem

PATCH Applied Sudarsana Reddy Kalluru 2 participants 2 messages Feb 21, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qed: Read device port count from the shmem

Read port count from the shared memory instead of driver deriving this value. This change simplifies the driver implementation and also avoids any dependencies for finding the port-count.

---
 drivers/net/ethernet/qlogic/qed/qed.h     |  6 +-
 drivers/net/ethernet/qlogic/qed/qed_dev.c | 95 ++++++++++++-------------------
 drivers/net/ethernet/qlogic/qed/qed_l2.c  |  4 +-
 drivers/net/ethernet/qlogic/qed/qed_mcp.h |  4 --
 drivers/net/ethernet/qlogic/qed/qed_ptp.c |  2 +-
 5 files changed, 44 insertions(+), 67 deletions(-)
drivers/net/ethernet/qlogic/qed/qed.h +5 -1
index 2d21c94..43a57ec 100644
@@ -753,6 +753,7 @@ struct qed_dev {
 #define CHIP_BOND_ID_SHIFT              0
 
 	u8				num_engines;
+	u8				num_ports;
 	u8				num_ports_in_engine;
 	u8				num_funcs_in_port;
 
@@ -892,7 +893,6 @@ void qed_configure_vp_wfq_on_link_change(struct qed_dev *cdev,
 
 void qed_clean_wfq_db(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
 int qed_device_num_engines(struct qed_dev *cdev);
-int qed_device_get_port_id(struct qed_dev *cdev);
 void qed_set_fw_mac_addr(__le16 *fw_msb,
 			 __le16 *fw_mid, __le16 *fw_lsb, u8 *mac);
 
@@ -939,6 +939,10 @@ void qed_db_recovery_execute(struct qed_hwfn *p_hwfn,
 	writel((u32)val, (void __iomem *)((u8 __iomem *)\
 					  (cdev->doorbells) + (db_addr)))
 
+#define MFW_PORT(_p_hwfn)       ((_p_hwfn)->abs_pf_id %			  \
+				  qed_device_num_ports((_p_hwfn)->cdev))
+int qed_device_num_ports(struct qed_dev *cdev);
+
 /* Prototypes */
 int qed_fill_dev_info(struct qed_dev *cdev,
 		      struct qed_dev_info *dev_info);
drivers/net/ethernet/qlogic/qed/qed_dev.c +35 -60

120 lines not on this page · raw message

drivers/net/ethernet/qlogic/qed/qed_l2.c +3 -1
index 58be1c4..5764172 100644
@@ -1898,6 +1898,7 @@ static void _qed_get_vport_stats(struct qed_dev *cdev,
 		struct qed_hwfn *p_hwfn = &cdev->hwfns[i];
 		struct qed_ptt *p_ptt = IS_PF(cdev) ? qed_ptt_acquire(p_hwfn)
 						    :  NULL;
+		bool b_get_port_stats;
 
 		if (IS_PF(cdev)) {
 			/* The main vport index is relative first */
@@ -1912,8 +1913,9 @@ static void _qed_get_vport_stats(struct qed_dev *cdev,
 			continue;
 		}
 
+		b_get_port_stats = IS_PF(cdev) && IS_LEAD_HWFN(p_hwfn);
 		__qed_get_vport_stats(p_hwfn, p_ptt, stats, fw_vport,
-				      IS_PF(cdev) ? true : false);
+				      b_get_port_stats);
 
 out:
 		if (IS_PF(cdev) && p_ptt)
drivers/net/ethernet/qlogic/qed/qed_mcp.h +0 -4
index 2799e67..261c1a3 100644
@@ -691,10 +691,6 @@ int qed_mcp_bist_nvm_get_image_att(struct qed_hwfn *p_hwfn,
 					    rel_pfid)
 #define MCP_PF_ID(p_hwfn) MCP_PF_ID_BY_REL(p_hwfn, (p_hwfn)->rel_pf_id)
 
-#define MFW_PORT(_p_hwfn)       ((_p_hwfn)->abs_pf_id %			  \
-				 ((_p_hwfn)->cdev->num_ports_in_engine * \
-				  qed_device_num_engines((_p_hwfn)->cdev)))
-
 struct qed_mcp_info {
 	/* List for mailbox commands which were sent and wait for a response */
 	struct list_head			cmd_list;
drivers/net/ethernet/qlogic/qed/qed_ptp.c +1 -1
index 5a90d69..1302b30 100644
@@ -47,7 +47,7 @@
 
 static enum qed_resc_lock qed_ptcdev_to_resc(struct qed_hwfn *p_hwfn)
 {
-	switch (qed_device_get_port_id(p_hwfn->cdev)) {
+	switch (MFW_PORT(p_hwfn)) {
 	case 0:
 		return QED_RESC_LOCK_PTP_PORT0;
 	case 1:
Signature · 1 line
1.8.3.1