netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 1/4] bnx2x: add PFC statistics
@ 2011-12-06  5:44 Michael Chan
  2011-12-06  5:44 ` [PATCH net-next 2/4] bnx2x: add fcoe statistics Michael Chan
  0 siblings, 1 reply; 8+ messages in thread
From: Michael Chan @ 2011-12-06  5:44 UTC (permalink / raw)
  To: davem; +Cc: netdev, barak, eilong

From: Barak Witkowski <barak@broadcom.com>

Add Priority flow control counters for ethtool -S.

Signed-off-by: Barak Witkowski <barak@broadcom.com>
Signed-off-by: Eilon Greenstein <eilong@broadcom.com>
Signed-off-by: Michael Chan <mchan@broadcom.com>
---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x.h        |    1 +
 .../net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c    |    4 ++
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h    |    9 +++-
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c   |    2 +
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c  |   44 +++++++++++++++++++-
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.h  |    6 +++
 6 files changed, 63 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
index 6c7bd63..32af052 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
@@ -1266,6 +1266,7 @@ struct bnx2x {
 #define NO_ISCSI_OOO_FLAG		(1 << 13)
 #define NO_ISCSI_FLAG			(1 << 14)
 #define NO_FCOE_FLAG			(1 << 15)
+#define BC_SUPPORTS_PFC_STATS		(1 << 17)
 
 #define NO_ISCSI(bp)		((bp)->flags & NO_ISCSI_FLAG)
 #define NO_ISCSI_OOO(bp)	((bp)->flags & NO_ISCSI_OOO_FLAG)
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
index c679ed9..e64bdf6 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
@@ -107,6 +107,10 @@ static const struct {
 				4, STATS_FLAGS_PORT, "rx_filtered_packets" },
 	{ STATS_OFFSET32(mf_tag_discard),
 				4, STATS_FLAGS_PORT, "rx_mf_tag_discard" },
+	{ STATS_OFFSET32(pfc_frames_received_hi),
+				8, STATS_FLAGS_PORT, "pfc_frames_received" },
+	{ STATS_OFFSET32(pfc_frames_sent_hi),
+				8, STATS_FLAGS_PORT, "pfc_frames_sent" },
 	{ STATS_OFFSET32(brb_drop_hi),
 				8, STATS_FLAGS_PORT, "rx_brb_discard" },
 	{ STATS_OFFSET32(brb_truncate_hi),
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h
index fc754cb..79b6e43 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h
@@ -1247,6 +1247,7 @@ struct drv_func_mb {
 	#define DRV_MSG_CODE_VRFY_SPECIFIC_PHY_OPT_MDL  0xa1000000
 	#define REQ_BC_VER_4_VRFY_SPECIFIC_PHY_OPT_MDL  0x00050234
 	#define REQ_BC_VER_4_SFP_TX_DISABLE_SUPPORTED   0x00070014
+	#define REQ_BC_VER_4_PFC_STATS_SUPPORTED        0x00070201
 
 	#define DRV_MSG_CODE_DCBX_ADMIN_PMF_MSG         0xb0000000
 	#define DRV_MSG_CODE_DCBX_PMF_DRV_OK            0xb2000000
@@ -2501,14 +2502,18 @@ struct mac_stx {
 #define MAC_STX_IDX_MAX                     2
 
 struct host_port_stats {
-	u32            host_port_stats_start;
+	u32            host_port_stats_counter;
 
 	struct mac_stx mac_stx[MAC_STX_IDX_MAX];
 
 	u32            brb_drop_hi;
 	u32            brb_drop_lo;
 
-	u32            host_port_stats_end;
+	u32            not_used; /* obsolete */
+	u32            pfc_frames_tx_hi;
+	u32            pfc_frames_tx_lo;
+	u32            pfc_frames_rx_hi;
+	u32            pfc_frames_rx_lo;
 };
 
 
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index 2213e0b..052ab99 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -8827,6 +8827,8 @@ static void __devinit bnx2x_get_common_hwinfo(struct bnx2x *bp)
 	bp->link_params.feature_config_flags |=
 		(val >= REQ_BC_VER_4_SFP_TX_DISABLE_SUPPORTED) ?
 		FEATURE_CONFIG_BC_SUPPORTS_SFP_TX_DISABLED : 0;
+	bp->flags |= (val >= REQ_BC_VER_4_PFC_STATS_SUPPORTED) ?
+			BC_SUPPORTS_PFC_STATS : 0;
 
 	pci_read_config_word(bp->pdev, bp->pm_cap + PCI_PM_PMC, &pmc);
 	bp->flags |= (pmc & PCI_PM_CAP_PME_D3cold) ? 0 : NO_WOL_FLAG;
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c
index 3034f0e..c943545 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c
@@ -540,6 +540,25 @@ static void bnx2x_bmac_stats_update(struct bnx2x *bp)
 		UPDATE_STAT64(tx_stat_gterr,
 				tx_stat_dot3statsinternalmactransmiterrors);
 		UPDATE_STAT64(tx_stat_gtufl, tx_stat_mac_ufl);
+
+		/* collect PFC stats */
+		DIFF_64(diff.hi, new->tx_stat_gtpp_hi,
+			pstats->pfc_frames_tx_hi,
+			diff.lo, new->tx_stat_gtpp_lo,
+			pstats->pfc_frames_tx_lo);
+		pstats->pfc_frames_tx_hi = new->tx_stat_gtpp_hi;
+		pstats->pfc_frames_tx_lo = new->tx_stat_gtpp_lo;
+		ADD_64(pstats->pfc_frames_tx_hi, diff.hi,
+			pstats->pfc_frames_tx_lo, diff.lo);
+
+		DIFF_64(diff.hi, new->rx_stat_grpp_hi,
+			pstats->pfc_frames_rx_hi,
+			diff.lo, new->rx_stat_grpp_lo,
+			pstats->pfc_frames_rx_lo);
+		pstats->pfc_frames_rx_hi = new->rx_stat_grpp_hi;
+		pstats->pfc_frames_rx_lo = new->rx_stat_grpp_lo;
+		ADD_64(pstats->pfc_frames_rx_hi, diff.hi,
+			pstats->pfc_frames_rx_lo, diff.lo);
 	}
 
 	estats->pause_frames_received_hi =
@@ -551,6 +570,15 @@ static void bnx2x_bmac_stats_update(struct bnx2x *bp)
 				pstats->mac_stx[1].tx_stat_outxoffsent_hi;
 	estats->pause_frames_sent_lo =
 				pstats->mac_stx[1].tx_stat_outxoffsent_lo;
+
+	estats->pfc_frames_received_hi =
+				pstats->pfc_frames_rx_hi;
+	estats->pfc_frames_received_lo =
+				pstats->pfc_frames_rx_lo;
+	estats->pfc_frames_sent_hi =
+				pstats->pfc_frames_tx_hi;
+	estats->pfc_frames_sent_lo =
+				pstats->pfc_frames_tx_lo;
 }
 
 static void bnx2x_mstat_stats_update(struct bnx2x *bp)
@@ -571,6 +599,11 @@ static void bnx2x_mstat_stats_update(struct bnx2x *bp)
 	ADD_STAT64(stats_tx.tx_gtxpf, tx_stat_outxoffsent);
 	ADD_STAT64(stats_tx.tx_gtxpf, tx_stat_flowcontroldone);
 
+	/* collect pfc stats */
+	ADD_64(pstats->pfc_frames_tx_hi, new->stats_tx.tx_gtxpp_hi,
+		pstats->pfc_frames_tx_lo, new->stats_tx.tx_gtxpp_lo);
+	ADD_64(pstats->pfc_frames_rx_hi, new->stats_rx.rx_grxpp_hi,
+		pstats->pfc_frames_rx_lo, new->stats_rx.rx_grxpp_lo);
 
 	ADD_STAT64(stats_tx.tx_gt64, tx_stat_etherstatspkts64octets);
 	ADD_STAT64(stats_tx.tx_gt127,
@@ -628,6 +661,15 @@ static void bnx2x_mstat_stats_update(struct bnx2x *bp)
 				pstats->mac_stx[1].tx_stat_outxoffsent_hi;
 	estats->pause_frames_sent_lo =
 				pstats->mac_stx[1].tx_stat_outxoffsent_lo;
+
+	estats->pfc_frames_received_hi =
+				pstats->pfc_frames_rx_hi;
+	estats->pfc_frames_received_lo =
+				pstats->pfc_frames_rx_lo;
+	estats->pfc_frames_sent_hi =
+				pstats->pfc_frames_tx_hi;
+	estats->pfc_frames_sent_lo =
+				pstats->pfc_frames_tx_lo;
 }
 
 static void bnx2x_emac_stats_update(struct bnx2x *bp)
@@ -740,7 +782,7 @@ static int bnx2x_hw_stats_update(struct bnx2x *bp)
 	estats->brb_drop_hi = pstats->brb_drop_hi;
 	estats->brb_drop_lo = pstats->brb_drop_lo;
 
-	pstats->host_port_stats_start = ++pstats->host_port_stats_end;
+	pstats->host_port_stats_counter++;
 
 	if (!BP_NOMCP(bp)) {
 		u32 nig_timer_max =
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.h
index 5d8ce2f..683deb0 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.h
@@ -193,6 +193,12 @@ struct bnx2x_eth_stats {
 	u32 total_tpa_aggregated_frames_lo;
 	u32 total_tpa_bytes_hi;
 	u32 total_tpa_bytes_lo;
+
+	/* PFC */
+	u32 pfc_frames_received_hi;
+	u32 pfc_frames_received_lo;
+	u32 pfc_frames_sent_hi;
+	u32 pfc_frames_sent_lo;
 };
 
 
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH net-next 2/4] bnx2x: add fcoe statistics
  2011-12-06  5:44 [PATCH net-next 1/4] bnx2x: add PFC statistics Michael Chan
@ 2011-12-06  5:44 ` Michael Chan
  2011-12-06  5:44   ` [PATCH net-next 3/4] bnx2x: support classification config query Michael Chan
  0 siblings, 1 reply; 8+ messages in thread
From: Michael Chan @ 2011-12-06  5:44 UTC (permalink / raw)
  To: davem; +Cc: netdev, barak, eilong

From: Barak Witkowski <barak@broadcom.com>

Add FCoE statistics support for FCoE capable devices.

Signed-off-by: Barak Witkowski <barak@broadcom.com>
Signed-off-by: Eilon Greenstein <eilong@broadcom.com>
Signed-off-by: Michael Chan <mchan@broadcom.com>
---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x.h       |    5 ++-
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h   |   56 ++++++++++++++++++++-
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c  |   38 +++++++-------
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c |   44 ++++++++++++++++-
 4 files changed, 120 insertions(+), 23 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
index 32af052..40cfce0 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
@@ -1128,18 +1128,21 @@ enum {
 enum {
 	BNX2X_PORT_QUERY_IDX,
 	BNX2X_PF_QUERY_IDX,
+	BNX2X_FCOE_QUERY_IDX,
 	BNX2X_FIRST_QUEUE_QUERY_IDX,
 };
 
 struct bnx2x_fw_stats_req {
 	struct stats_query_header hdr;
-	struct stats_query_entry query[STATS_QUERY_CMD_COUNT];
+	struct stats_query_entry query[FP_SB_MAX_E1x+
+		BNX2X_FIRST_QUEUE_QUERY_IDX];
 };
 
 struct bnx2x_fw_stats_data {
 	struct stats_counter	storm_counters;
 	struct per_port_stats	port;
 	struct per_pf_stats	pf;
+	struct fcoe_statistics_params	fcoe;
 	struct per_queue_stats  queue_stats[1];
 };
 
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h
index 79b6e43..d9f07cb 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h
@@ -4166,8 +4166,62 @@ struct ustorm_eth_rx_producers {
 
 
 /*
- * cfc delete event data
+ * FCoE RX statistics parameters section#0
+ */
+struct fcoe_rx_stat_params_section0 {
+	__le32 fcoe_rx_pkt_cnt;
+	__le32 fcoe_rx_byte_cnt;
+};
+
+
+/*
+ * FCoE RX statistics parameters section#1
+ */
+struct fcoe_rx_stat_params_section1 {
+	__le32 fcoe_ver_cnt;
+	__le32 fcoe_rx_drop_pkt_cnt;
+};
+
+
+/*
+ * FCoE RX statistics parameters section#2
  */
+struct fcoe_rx_stat_params_section2 {
+	__le32 fc_crc_cnt;
+	__le32 eofa_del_cnt;
+	__le32 miss_frame_cnt;
+	__le32 seq_timeout_cnt;
+	__le32 drop_seq_cnt;
+	__le32 fcoe_rx_drop_pkt_cnt;
+	__le32 fcp_rx_pkt_cnt;
+	__le32 reserved0;
+};
+
+
+/*
+ * FCoE TX statistics parameters
+ */
+struct fcoe_tx_stat_params {
+	__le32 fcoe_tx_pkt_cnt;
+	__le32 fcoe_tx_byte_cnt;
+	__le32 fcp_tx_pkt_cnt;
+	__le32 reserved0;
+};
+
+/*
+ * FCoE statistics parameters
+ */
+struct fcoe_statistics_params {
+	struct fcoe_tx_stat_params tx_stat;
+	struct fcoe_rx_stat_params_section0 rx_stat0;
+	struct fcoe_rx_stat_params_section1 rx_stat1;
+	struct fcoe_rx_stat_params_section2 rx_stat2;
+};
+
+
+/*
+ * cfc delete event data
+*/
 struct cfc_del_event_data {
 	u32 cid;
 	u32 reserved0;
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index 052ab99..552c564 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -2624,15 +2624,6 @@ u32 bnx2x_fw_command(struct bnx2x *bp, u32 command, u32 param)
 	return rc;
 }
 
-static u8 stat_counter_valid(struct bnx2x *bp, struct bnx2x_fastpath *fp)
-{
-#ifdef BCM_CNIC
-	/* Statistics are not supported for CNIC Clients at the moment */
-	if (IS_FCOE_FP(fp))
-		return false;
-#endif
-	return true;
-}
 
 void bnx2x_func_init(struct bnx2x *bp, struct bnx2x_func_init_params *p)
 {
@@ -2676,11 +2667,11 @@ static inline unsigned long bnx2x_get_common_flags(struct bnx2x *bp,
 	 *  parent connection). The statistics are zeroed when the parent
 	 *  connection is initialized.
 	 */
-	if (stat_counter_valid(bp, fp)) {
-		__set_bit(BNX2X_Q_FLG_STATS, &flags);
-		if (zero_stats)
-			__set_bit(BNX2X_Q_FLG_ZERO_STATS, &flags);
-	}
+
+	__set_bit(BNX2X_Q_FLG_STATS, &flags);
+	if (zero_stats)
+		__set_bit(BNX2X_Q_FLG_ZERO_STATS, &flags);
+
 
 	return flags;
 }
@@ -6848,13 +6839,16 @@ void bnx2x_free_mem(struct bnx2x *bp)
 static inline int bnx2x_alloc_fw_stats_mem(struct bnx2x *bp)
 {
 	int num_groups;
+	int is_fcoe_stats = NO_FCOE(bp) ? 0 : 1;
 
-	/* number of eth_queues */
-	u8 num_queue_stats = BNX2X_NUM_ETH_QUEUES(bp);
+	/* number of queues for statistics is number of eth queues + FCoE */
+	u8 num_queue_stats = BNX2X_NUM_ETH_QUEUES(bp) + is_fcoe_stats;
 
 	/* Total number of FW statistics requests =
-	 * 1 for port stats + 1 for PF stats + num_eth_queues */
-	bp->fw_stats_num = 2 + num_queue_stats;
+	 * 1 for port stats + 1 for PF stats + potential 1 for FCoE stats +
+	 * num of queues
+	 */
+	bp->fw_stats_num = 2 + is_fcoe_stats + num_queue_stats;
 
 
 	/* Request is built from stats_query_header and an array of
@@ -6862,8 +6856,8 @@ static inline int bnx2x_alloc_fw_stats_mem(struct bnx2x *bp)
 	 * STATS_QUERY_CMD_COUNT rules. The real number or requests is
 	 * configured in the stats_query_header.
 	 */
-	num_groups = (2 + num_queue_stats) / STATS_QUERY_CMD_COUNT +
-		(((2 + num_queue_stats) % STATS_QUERY_CMD_COUNT) ? 1 : 0);
+	num_groups = ((bp->fw_stats_num) / STATS_QUERY_CMD_COUNT) +
+		     (((bp->fw_stats_num) % STATS_QUERY_CMD_COUNT) ? 1 : 0);
 
 	bp->fw_stats_req_sz = sizeof(struct stats_query_header) +
 			num_groups * sizeof(struct stats_query_cmd_group);
@@ -6872,9 +6866,13 @@ static inline int bnx2x_alloc_fw_stats_mem(struct bnx2x *bp)
 	 *
 	 * stats_counter holds per-STORM counters that are incremented
 	 * when STORM has finished with the current request.
+	 *
+	 * memory for FCoE offloaded statistics are counted anyway,
+	 * even if they will not be sent.
 	 */
 	bp->fw_stats_data_sz = sizeof(struct per_port_stats) +
 		sizeof(struct per_pf_stats) +
+		sizeof(struct fcoe_statistics_params) +
 		sizeof(struct per_queue_stats) * num_queue_stats +
 		sizeof(struct stats_counter);
 
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c
index c943545..41a33ce 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c
@@ -1501,6 +1501,7 @@ static void bnx2x_func_stats_base_update(struct bnx2x *bp)
 static inline void bnx2x_prep_fw_stats_req(struct bnx2x *bp)
 {
 	int i;
+	int first_queue_query_index;
 	struct stats_query_header *stats_hdr = &bp->fw_stats_req->hdr;
 
 	dma_addr_t cur_data_offset;
@@ -1556,14 +1557,40 @@ static inline void bnx2x_prep_fw_stats_req(struct bnx2x *bp)
 	cur_query_entry->address.hi = cpu_to_le32(U64_HI(cur_data_offset));
 	cur_query_entry->address.lo = cpu_to_le32(U64_LO(cur_data_offset));
 
+	/**** FCoE FW statistics data ****/
+	if (!NO_FCOE(bp)) {
+		cur_data_offset = bp->fw_stats_data_mapping +
+			offsetof(struct bnx2x_fw_stats_data, fcoe);
+
+		cur_query_entry =
+			&bp->fw_stats_req->query[BNX2X_FCOE_QUERY_IDX];
+
+		cur_query_entry->kind = STATS_TYPE_FCOE;
+		/* For FCoE query index is a DONT CARE */
+		cur_query_entry->index = BP_PORT(bp);
+		cur_query_entry->funcID = cpu_to_le16(BP_FUNC(bp));
+		cur_query_entry->address.hi =
+			cpu_to_le32(U64_HI(cur_data_offset));
+		cur_query_entry->address.lo =
+			cpu_to_le32(U64_LO(cur_data_offset));
+	}
+
 	/**** Clients' queries ****/
 	cur_data_offset = bp->fw_stats_data_mapping +
 		offsetof(struct bnx2x_fw_stats_data, queue_stats);
 
+	/* first queue query index depends whether FCoE offloaded request will
+	 * be included in the ramrod
+	 */
+	if (!NO_FCOE(bp))
+		first_queue_query_index = BNX2X_FIRST_QUEUE_QUERY_IDX;
+	else
+		first_queue_query_index = BNX2X_FIRST_QUEUE_QUERY_IDX - 1;
+
 	for_each_eth_queue(bp, i) {
 		cur_query_entry =
 			&bp->fw_stats_req->
-					query[BNX2X_FIRST_QUEUE_QUERY_IDX + i];
+					query[first_queue_query_index + i];
 
 		cur_query_entry->kind = STATS_TYPE_QUEUE;
 		cur_query_entry->index = bnx2x_stats_id(&bp->fp[i]);
@@ -1575,6 +1602,21 @@ static inline void bnx2x_prep_fw_stats_req(struct bnx2x *bp)
 
 		cur_data_offset += sizeof(struct per_queue_stats);
 	}
+
+	/* add FCoE queue query if needed */
+	if (!NO_FCOE(bp)) {
+		cur_query_entry =
+			&bp->fw_stats_req->
+					query[first_queue_query_index + i];
+
+		cur_query_entry->kind = STATS_TYPE_QUEUE;
+		cur_query_entry->index = bnx2x_stats_id(&bp->fp[FCOE_IDX]);
+		cur_query_entry->funcID = cpu_to_le16(BP_FUNC(bp));
+		cur_query_entry->address.hi =
+			cpu_to_le32(U64_HI(cur_data_offset));
+		cur_query_entry->address.lo =
+			cpu_to_le32(U64_LO(cur_data_offset));
+	}
 }
 
 void bnx2x_stats_init(struct bnx2x *bp)
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH net-next 3/4] bnx2x: support classification config query
  2011-12-06  5:44 ` [PATCH net-next 2/4] bnx2x: add fcoe statistics Michael Chan
@ 2011-12-06  5:44   ` Michael Chan
  2011-12-06  5:44     ` [PATCH net-next 4/4] bnx2x, cnic: support DRV_INFO upon FW request Michael Chan
  2011-12-06  5:46     ` [PATCH net-next 3/4] bnx2x: support classification config query David Miller
  0 siblings, 2 replies; 8+ messages in thread
From: Michael Chan @ 2011-12-06  5:44 UTC (permalink / raw)
  To: davem; +Cc: netdev, barak, eilong

From: Ariel Elior <ariele@broadcom.com>

To support copying MAC addresses to firmware info structure in the proper
format.

Signed-off-by: Ariel Elior <ariele@broadcom.com>
Signed-off-by: Barak Witkowski <barak@broadcom.com>
Signed-off-by: Eilon Greenstein <eilong@broadcom.com>
Signed-off-by: Michael Chan <mchan@broadcom.com>
---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c |   39 ++++++++++++++++++++++++
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h |   17 ++++++++++
 2 files changed, 56 insertions(+), 0 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
index a34362e..da377d1 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
@@ -30,6 +30,8 @@
 
 #define BNX2X_MAX_EMUL_MULTI		16
 
+#define MAC_LEADING_ZERO_CNT (ALIGN(ETH_ALEN, sizeof(u32)) - ETH_ALEN)
+
 /**** Exe Queue interfaces ****/
 
 /**
@@ -441,6 +443,42 @@ static bool bnx2x_put_credit_vlan_mac(struct bnx2x_vlan_mac_obj *o)
 	return true;
 }
 
+static int bnx2x_get_n_elements(struct bnx2x *bp,
+			 struct bnx2x_vlan_mac_obj *o,
+			 int n,
+			 u8 *buf)
+{
+	struct bnx2x_vlan_mac_registry_elem *pos;
+	u8 *next = buf;
+	int counter = 0;
+
+	/* traverse list */
+	list_for_each_entry(pos, &o->head, link)
+	{
+		if ((counter < n)) {
+
+			/* place leading zeroes in buffer */
+			memset(next, 0, MAC_LEADING_ZERO_CNT);
+
+			/* place mac after leading zeroes*/
+			memcpy(next + MAC_LEADING_ZERO_CNT,
+				  pos->u.mac.mac, ETH_ALEN);
+
+			/* calculate address of next element and
+			 * advance counter
+			 */
+			counter++;
+			next = buf + counter * ALIGN(ETH_ALEN,
+							   sizeof(u32));
+
+			DP(BNX2X_MSG_SP, "copied element number "
+				   "%d to address %p element was "
+				   "%pM\n", counter, next, pos->u.mac.mac);
+		}
+	}
+	return counter * ETH_ALEN;
+}
+
 /* check_add() callbacks */
 static int bnx2x_check_mac_add(struct bnx2x_vlan_mac_obj *o,
 			       union bnx2x_classification_ramrod_data *data)
@@ -1886,6 +1924,7 @@ void bnx2x_init_mac_obj(struct bnx2x *bp,
 		mac_obj->check_move        = bnx2x_check_move;
 		mac_obj->ramrod_cmd        =
 			RAMROD_CMD_ID_ETH_CLASSIFICATION_RULES;
+		mac_obj->get_n_elements    = bnx2x_get_n_elements;
 
 		/* Exe Queue */
 		bnx2x_exe_queue_init(bp,
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
index 9a517c2..bf898fb 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
@@ -286,6 +286,23 @@ struct bnx2x_vlan_mac_obj {
 	int				ramrod_cmd;
 
 	/**
+	 * copy first n elements onto preallocated buffer
+	 *
+	 * @param n number of elements to get
+	 * @param buf buffer preallocated by caller into which elements
+	 *            will be copied. Note elements are 4-byte aligned
+	 *            so buffer size must be able to accomodate the
+	 *            aligned elements.
+	 *
+	 * @return number of copied bytes
+	 *  */
+
+	int (*get_n_elements)(struct bnx2x *bp,
+			 struct bnx2x_vlan_mac_obj *o,
+			 int n,
+			 u8 *buf);
+
+	/**
 	 * Checks if ADD-ramrod with the given params may be performed.
 	 *
 	 * @return zero if the element may be added
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH net-next 4/4] bnx2x, cnic: support DRV_INFO upon FW request
  2011-12-06  5:44   ` [PATCH net-next 3/4] bnx2x: support classification config query Michael Chan
@ 2011-12-06  5:44     ` Michael Chan
  2011-12-06  5:56       ` Joe Perches
  2011-12-06  5:46     ` [PATCH net-next 3/4] bnx2x: support classification config query David Miller
  1 sibling, 1 reply; 8+ messages in thread
From: Michael Chan @ 2011-12-06  5:44 UTC (permalink / raw)
  To: davem; +Cc: netdev, barak, eilong

From: Barak Witkowski <barak@broadcom.com>

Add support to send driver capabilities, settings and statistics to
management firmware.

Signed-off-by: Barak Witkowski <barak@broadcom.com>
Signed-off-by: Eilon Greenstein <eilong@broadcom.com>
Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
Signed-off-by: Michael Chan <mchan@broadcom.com>
---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x.h       |    4 +
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h   |  151 ++++++++++++-
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c  |  251 ++++++++++++++++++++-
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c |   20 ++-
 drivers/net/ethernet/broadcom/cnic.c              |   47 ++++
 drivers/net/ethernet/broadcom/cnic_if.h           |    9 +
 6 files changed, 474 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
index 40cfce0..8c73d34 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
@@ -887,6 +887,8 @@ struct bnx2x_common {
 #define CHIP_PORT_MODE_NONE			0x2
 #define CHIP_MODE(bp)			(bp->common.chip_port_mode)
 #define CHIP_MODE_IS_4_PORT(bp) (CHIP_MODE(bp) == CHIP_4_PORT_MODE)
+
+	u32			boot_mode;
 };
 
 /* IGU MSIX STATISTICS on 57712: 64 for VFs; 4 for PFs; 4 for Attentions */
@@ -1048,6 +1050,8 @@ struct bnx2x_slowpath {
 
 	u32				wb_comp;
 	u32				wb_data[4];
+
+	union drv_info_to_mcp		drv_info_to_mcp;
 };
 
 #define bnx2x_sp(bp, var)		(&bp->slowpath->var)
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h
index d9f07cb..996b57c 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h
@@ -1253,6 +1253,8 @@ struct drv_func_mb {
 	#define DRV_MSG_CODE_DCBX_PMF_DRV_OK            0xb2000000
 
 	#define DRV_MSG_CODE_VF_DISABLED_DONE           0xc0000000
+	#define DRV_MSG_CODE_DRV_INFO_ACK               0xd8000000
+	#define DRV_MSG_CODE_DRV_INFO_NACK              0xd9000000
 
 	#define DRV_MSG_CODE_SET_MF_BW                  0xe0000000
 	#define REQ_BC_VER_4_SET_MF_BW                  0x00060202
@@ -1305,6 +1307,8 @@ struct drv_func_mb {
 	#define FW_MSG_CODE_VRFY_OPT_MDL_INVLD_IMG      0xa0200000
 	#define FW_MSG_CODE_VRFY_OPT_MDL_UNAPPROVED     0xa0300000
 	#define FW_MSG_CODE_VF_DISABLED_DONE            0xb0000000
+	#define FW_MSG_CODE_DRV_INFO_ACK                0xd8100000
+	#define FW_MSG_CODE_DRV_INFO_NACK               0xd9100000
 
 	#define FW_MSG_CODE_SET_MF_BW_SENT              0xe0000000
 	#define FW_MSG_CODE_SET_MF_BW_DONE              0xe1000000
@@ -1361,6 +1365,7 @@ struct drv_func_mb {
 
 	#define DRV_STATUS_DCBX_EVENT_MASK              0x000f0000
 	#define DRV_STATUS_DCBX_NEGOTIATION_RESULTS     0x00010000
+	#define DRV_STATUS_DRV_INFO_REQ                 0x04000000
 
 	u32 virt_mac_upper;
 	#define VIRT_MAC_SIGN_MASK                      0xffff0000
@@ -1965,9 +1970,38 @@ struct shmem2_region {
 	u32 extended_dev_info_shared_addr;
 	u32 ncsi_oem_data_addr;
 
-	u32 ocsd_host_addr;
-	u32 ocbb_host_addr;
-	u32 ocsd_req_update_interval;
+	u32 ocsd_host_addr; /* initialized by option ROM */
+	u32 ocbb_host_addr; /* initialized by option ROM */
+	u32 ocsd_req_update_interval; /* initialized by option ROM */
+	u32 temperature_in_half_celsius;
+	u32 glob_struct_in_host;
+
+	u32 dcbx_neg_res_ext_offset;
+	#define SHMEM_DCBX_NEG_RES_EXT_NONE			0x00000000
+
+	u32 drv_capabilities_flag[E2_FUNC_MAX];
+	#define DRV_FLAGS_CAPABALITIES_LOADED_SUPPORTED 0x00000001
+	#define DRV_FLAGS_CAPABILITIES_LOADED_L2        0x00000002
+	#define DRV_FLAGS_CAPABILITIES_LOADED_FCOE      0x00000004
+	#define DRV_FLAGS_CAPABILITIES_LOADED_ISCSI     0x00000008
+
+	u32 extended_dev_info_shared_cfg_size;
+
+	u32 dcbx_en[PORT_MAX];
+
+	/* The offset points to the multi threaded meta structure */
+	u32 multi_thread_data_offset;
+
+	/* address of DMAable host address holding values from the drivers */
+	u32 drv_info_host_addr_lo;
+	u32 drv_info_host_addr_hi;
+
+	/* general values written by the MFW (such as current version) */
+	u32 drv_info_control;
+	#define DRV_INFO_CONTROL_VER_MASK          0x000000ff
+	#define DRV_INFO_CONTROL_VER_SHIFT         0
+	#define DRV_INFO_CONTROL_OP_CODE_MASK      0x0000ff00
+	#define DRV_INFO_CONTROL_OP_CODE_SHIFT     8
 };
 
 
@@ -2553,6 +2587,117 @@ struct host_func_stats {
 /* VIC definitions */
 #define VICSTATST_UIF_INDEX 2
 
+/* current drv_info version */
+#define DRV_INFO_CUR_VER 1
+
+/* drv_info op codes supported */
+enum drv_info_opcode {
+	ETH_STATS_OPCODE,
+	FCOE_STATS_OPCODE,
+	ISCSI_STATS_OPCODE
+};
+
+#define ETH_STAT_INFO_VERSION_LEN	12
+/*  Per PCI Function Ethernet Statistics required from the driver */
+struct eth_stats_info {
+	/* Function's Driver Version. padded to 12 */
+	u8 version[ETH_STAT_INFO_VERSION_LEN];
+	/* Locally Admin Addr. BigEndian EIU48. Actual size is 6 bytes */
+	u8 mac_local[8];
+	u8 mac_add1[8];		/* Additional Programmed MAC Addr 1. */
+	u8 mac_add2[8];		/* Additional Programmed MAC Addr 2. */
+	u32 mtu_size;		/* MTU Size. Note   : Negotiated MTU */
+	u32 feature_flags;	/* Feature_Flags. */
+	#define FEATURE_ETH_CHKSUM_OFFLOAD_MASK		0x01
+	#define FEATURE_ETH_LSO_MASK			0x02
+	#define FEATURE_ETH_BOOTMODE_MASK		0x1C
+	#define FEATURE_ETH_BOOTMODE_SHIFT		2
+	#define FEATURE_ETH_BOOTMODE_NONE		(0x0 << 2)
+	#define FEATURE_ETH_BOOTMODE_PXE		(0x1 << 2)
+	#define FEATURE_ETH_BOOTMODE_ISCSI		(0x2 << 2)
+	#define FEATURE_ETH_BOOTMODE_FCOE		(0x3 << 2)
+	#define FEATURE_ETH_TOE_MASK			0x20
+	u32 lso_max_size;	/* LSO MaxOffloadSize. */
+	u32 lso_min_seg_cnt;	/* LSO MinSegmentCount. */
+	/* Num Offloaded Connections TCP_IPv4. */
+	u32 ipv4_ofld_cnt;
+	/* Num Offloaded Connections TCP_IPv6. */
+	u32 ipv6_ofld_cnt;
+	u32 promiscuous_mode;	/* Promiscuous Mode. non-zero true */
+	u32 txq_size;		/* TX Descriptors Queue Size */
+	u32 rxq_size;		/* RX Descriptors Queue Size */
+	/* TX Descriptor Queue Avg Depth. % Avg Queue Depth since last poll */
+	u32 txq_avg_depth;
+	/* RX Descriptors Queue Avg Depth. % Avg Queue Depth since last poll */
+	u32 rxq_avg_depth;
+	/* IOV_Offload. 0=none; 1=MultiQueue, 2=VEB 3= VEPA*/
+	u32 iov_offload;
+	/* Number of NetQueue/VMQ Config'd. */
+	u32 netq_cnt;
+	u32 vf_cnt;		/* Num VF assigned to this PF. */
+};
+
+/*  Per PCI Function FCOE Statistics required from the driver */
+struct fcoe_stats_info {
+	u8 version[12];		/* Function's Driver Version. */
+	u8 mac_local[8];	/* Locally Admin Addr. */
+	u8 mac_add1[8];		/* Additional Programmed MAC Addr 1. */
+	u8 mac_add2[8];		/* Additional Programmed MAC Addr 2. */
+	/* QoS Priority (per 802.1p). 0-7255 */
+	u32 qos_priority;
+	u32 txq_size;		/* FCoE TX Descriptors Queue Size. */
+	u32 rxq_size;		/* FCoE RX Descriptors Queue Size. */
+	/* FCoE TX Descriptor Queue Avg Depth. */
+	u32 txq_avg_depth;
+	/* FCoE RX Descriptors Queue Avg Depth. */
+	u32 rxq_avg_depth;
+	u32 rx_frames_lo;	/* FCoE RX Frames received. */
+	u32 rx_frames_hi;	/* FCoE RX Frames received. */
+	u32 rx_bytes_lo;	/* FCoE RX Bytes received. */
+	u32 rx_bytes_hi;	/* FCoE RX Bytes received. */
+	u32 tx_frames_lo;	/* FCoE TX Frames sent. */
+	u32 tx_frames_hi;	/* FCoE TX Frames sent. */
+	u32 tx_bytes_lo;	/* FCoE TX Bytes sent. */
+	u32 tx_bytes_hi;	/* FCoE TX Bytes sent. */
+};
+
+/* Per PCI  Function iSCSI Statistics required from the driver*/
+struct iscsi_stats_info {
+	u8 version[12];		/* Function's Driver Version. */
+	u8 mac_local[8];	/* Locally Admin iSCSI MAC Addr. */
+	u8 mac_add1[8];		/* Additional Programmed MAC Addr 1. */
+	/* QoS Priority (per 802.1p). 0-7255 */
+	u32 qos_priority;
+	u8 initiator_name[64];	/* iSCSI Boot Initiator Node name. */
+	u8 ww_port_name[64];	/* iSCSI World wide port name */
+	u8 boot_target_name[64];/* iSCSI Boot Target Name. */
+	u8 boot_target_ip[16];	/* iSCSI Boot Target IP. */
+	u32 boot_target_portal;	/* iSCSI Boot Target Portal. */
+	u8 boot_init_ip[16];	/* iSCSI Boot Initiator IP Address. */
+	u32 max_frame_size;	/* Max Frame Size. bytes */
+	u32 txq_size;		/* PDU TX Descriptors Queue Size. */
+	u32 rxq_size;		/* PDU RX Descriptors Queue Size. */
+	u32 txq_avg_depth;	/*PDU TX Descriptor Queue Avg Depth. */
+	u32 rxq_avg_depth;	/*PDU RX Descriptors Queue Avg Depth. */
+	u32 rx_pdus_lo;		/* iSCSI PDUs received. */
+	u32 rx_pdus_hi;		/* iSCSI PDUs received. */
+	u32 rx_bytes_lo;	/* iSCSI RX Bytes received. */
+	u32 rx_bytes_hi;	/* iSCSI RX Bytes received. */
+	u32 tx_pdus_lo;		/* iSCSI PDUs sent. */
+	u32 tx_pdus_hi;		/* iSCSI PDUs sent. */
+	u32 tx_bytes_lo;	/* iSCSI PDU TX Bytes sent. */
+	u32 tx_bytes_hi;	/* iSCSI PDU TX Bytes sent. */
+	u32 pcp_prior_map_tbl;	/*C-PCP to S-PCP Priority MapTable.
+				9 nibbles, the position of each nibble
+				represents the C-PCP value, the value
+				of the nibble = S-PCP value.*/
+};
+
+union drv_info_to_mcp {
+	struct eth_stats_info	ether_stat;
+	struct fcoe_stats_info	fcoe_stat;
+	struct iscsi_stats_info	iscsi_stat;
+};
 #define BCM_5710_FW_MAJOR_VERSION			7
 #define BCM_5710_FW_MINOR_VERSION			0
 #define BCM_5710_FW_REVISION_VERSION		29
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index 552c564..35d2256 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -2912,6 +2912,159 @@ static void bnx2x_e1h_enable(struct bnx2x *bp)
 	 */
 }
 
+#define DRV_INFO_ETH_STAT_NUM_MACS_REQUIRED 3
+
+static inline void bnx2x_drv_info_ether_stat(struct bnx2x *bp)
+{
+	/* leave last char as NULL */
+	memcpy(bp->slowpath->drv_info_to_mcp.ether_stat.version,
+		DRV_MODULE_VERSION, ETH_STAT_INFO_VERSION_LEN - 1);
+
+	bp->fp[0].mac_obj.get_n_elements(bp, &bp->fp[0].mac_obj,
+					 DRV_INFO_ETH_STAT_NUM_MACS_REQUIRED,
+			bp->slowpath->drv_info_to_mcp.ether_stat.mac_local);
+
+	bp->slowpath->drv_info_to_mcp.ether_stat.mtu_size = bp->dev->mtu;
+
+	if (bp->dev->features & NETIF_F_RXCSUM)
+		bp->slowpath->drv_info_to_mcp.ether_stat.feature_flags |=
+		FEATURE_ETH_CHKSUM_OFFLOAD_MASK;
+	if (bp->dev->features & NETIF_F_TSO)
+		bp->slowpath->drv_info_to_mcp.ether_stat.feature_flags |=
+		FEATURE_ETH_LSO_MASK;
+	bp->slowpath->drv_info_to_mcp.ether_stat.feature_flags |=
+		bp->common.boot_mode;
+
+	bp->slowpath->drv_info_to_mcp.ether_stat.promiscuous_mode =
+		((bp->dev->flags & IFF_PROMISC) ? 1 : 0);
+
+	bp->slowpath->drv_info_to_mcp.ether_stat.txq_size = bp->tx_ring_size;
+	bp->slowpath->drv_info_to_mcp.ether_stat.rxq_size = bp->rx_ring_size;
+}
+
+static inline void bnx2x_drv_info_fcoe_stat(struct bnx2x *bp)
+{
+	struct bnx2x_dcbx_app_params *app = &bp->dcbx_port_params.app;
+
+	memcpy(bp->slowpath->drv_info_to_mcp.fcoe_stat.mac_local,
+		bp->fip_mac, ETH_ALEN);
+
+	bp->slowpath->drv_info_to_mcp.fcoe_stat.qos_priority =
+		app->traffic_type_priority[LLFC_TRAFFIC_TYPE_FCOE];
+
+	/* insert FCoE stats from ramrod response */
+	if (!NO_FCOE(bp)) {
+		struct tstorm_per_queue_stats *fcoe_q_tstorm_stats =
+			&bp->fw_stats_data->queue_stats[FCOE_IDX].
+			tstorm_queue_statistics;
+
+		struct xstorm_per_queue_stats *fcoe_q_xstorm_stats =
+			&bp->fw_stats_data->queue_stats[FCOE_IDX].
+			xstorm_queue_statistics;
+
+		ADD_64(bp->slowpath->drv_info_to_mcp.fcoe_stat.rx_bytes_hi,
+			0,
+			bp->slowpath->drv_info_to_mcp.fcoe_stat.rx_bytes_lo,
+			bp->fw_stats_data->fcoe.rx_stat0.fcoe_rx_byte_cnt);
+
+		ADD_64(bp->slowpath->drv_info_to_mcp.fcoe_stat.rx_bytes_hi,
+			fcoe_q_tstorm_stats->rcv_ucast_bytes.hi,
+			bp->slowpath->drv_info_to_mcp.fcoe_stat.rx_bytes_lo,
+			fcoe_q_tstorm_stats->rcv_ucast_bytes.lo);
+
+		ADD_64(bp->slowpath->drv_info_to_mcp.fcoe_stat.rx_bytes_hi,
+			fcoe_q_tstorm_stats->rcv_bcast_bytes.hi,
+			bp->slowpath->drv_info_to_mcp.fcoe_stat.rx_bytes_lo,
+			fcoe_q_tstorm_stats->rcv_bcast_bytes.lo);
+
+		ADD_64(bp->slowpath->drv_info_to_mcp.fcoe_stat.rx_bytes_hi,
+			fcoe_q_tstorm_stats->rcv_mcast_bytes.hi,
+			bp->slowpath->drv_info_to_mcp.fcoe_stat.rx_bytes_lo,
+			fcoe_q_tstorm_stats->rcv_mcast_bytes.lo);
+
+		ADD_64(bp->slowpath->drv_info_to_mcp.fcoe_stat.rx_frames_hi,
+			0,
+			bp->slowpath->drv_info_to_mcp.fcoe_stat.rx_frames_lo,
+			bp->fw_stats_data->fcoe.rx_stat0.fcoe_rx_pkt_cnt);
+
+		ADD_64(bp->slowpath->drv_info_to_mcp.fcoe_stat.rx_frames_hi,
+			0,
+			bp->slowpath->drv_info_to_mcp.fcoe_stat.rx_frames_lo,
+			fcoe_q_tstorm_stats->rcv_ucast_pkts);
+
+		ADD_64(bp->slowpath->drv_info_to_mcp.fcoe_stat.rx_frames_hi,
+			0,
+			bp->slowpath->drv_info_to_mcp.fcoe_stat.rx_frames_lo,
+			fcoe_q_tstorm_stats->rcv_bcast_pkts);
+
+		ADD_64(bp->slowpath->drv_info_to_mcp.fcoe_stat.rx_frames_hi,
+			0,
+			bp->slowpath->drv_info_to_mcp.fcoe_stat.rx_frames_lo,
+			fcoe_q_tstorm_stats->rcv_ucast_pkts);
+
+		ADD_64(bp->slowpath->drv_info_to_mcp.fcoe_stat.tx_bytes_hi,
+			0,
+			bp->slowpath->drv_info_to_mcp.fcoe_stat.tx_bytes_lo,
+			bp->fw_stats_data->fcoe.tx_stat.fcoe_tx_byte_cnt);
+
+		ADD_64(bp->slowpath->drv_info_to_mcp.fcoe_stat.tx_bytes_hi,
+			fcoe_q_xstorm_stats->ucast_bytes_sent.hi,
+			bp->slowpath->drv_info_to_mcp.fcoe_stat.tx_bytes_lo,
+			fcoe_q_xstorm_stats->ucast_bytes_sent.lo);
+
+		ADD_64(bp->slowpath->drv_info_to_mcp.fcoe_stat.tx_bytes_hi,
+			fcoe_q_xstorm_stats->bcast_bytes_sent.hi,
+			bp->slowpath->drv_info_to_mcp.fcoe_stat.tx_bytes_lo,
+			fcoe_q_xstorm_stats->bcast_bytes_sent.lo);
+
+		ADD_64(bp->slowpath->drv_info_to_mcp.fcoe_stat.tx_bytes_hi,
+			fcoe_q_xstorm_stats->mcast_bytes_sent.hi,
+			bp->slowpath->drv_info_to_mcp.fcoe_stat.tx_bytes_lo,
+			fcoe_q_xstorm_stats->mcast_bytes_sent.lo);
+
+		ADD_64(bp->slowpath->drv_info_to_mcp.fcoe_stat.tx_frames_hi,
+			0,
+			bp->slowpath->drv_info_to_mcp.fcoe_stat.tx_frames_lo,
+			bp->fw_stats_data->fcoe.tx_stat.fcoe_tx_pkt_cnt);
+
+		ADD_64(bp->slowpath->drv_info_to_mcp.fcoe_stat.tx_frames_hi,
+			0,
+			bp->slowpath->drv_info_to_mcp.fcoe_stat.tx_frames_lo,
+			fcoe_q_xstorm_stats->ucast_pkts_sent);
+
+		ADD_64(bp->slowpath->drv_info_to_mcp.fcoe_stat.tx_frames_hi,
+			0,
+			bp->slowpath->drv_info_to_mcp.fcoe_stat.tx_frames_lo,
+			fcoe_q_xstorm_stats->bcast_pkts_sent);
+
+		ADD_64(bp->slowpath->drv_info_to_mcp.fcoe_stat.tx_frames_hi,
+			0,
+			bp->slowpath->drv_info_to_mcp.fcoe_stat.tx_frames_lo,
+			fcoe_q_xstorm_stats->mcast_pkts_sent);
+	}
+
+#ifdef BCM_CNIC
+	/* ask L5 driver to add data to the struct */
+	bnx2x_cnic_notify(bp, CNIC_CTL_FCOE_STATS_GET_CMD);
+#endif
+}
+
+static inline void bnx2x_drv_info_iscsi_stat(struct bnx2x *bp)
+{
+	struct bnx2x_dcbx_app_params *app = &bp->dcbx_port_params.app;
+
+	memcpy(bp->slowpath->drv_info_to_mcp.iscsi_stat.mac_local,
+		bp->cnic_eth_dev.iscsi_mac, ETH_ALEN);
+
+	bp->slowpath->drv_info_to_mcp.fcoe_stat.qos_priority =
+		app->traffic_type_priority[LLFC_TRAFFIC_TYPE_ISCSI];
+
+#ifdef BCM_CNIC
+	/* ask L5 driver to add data to the struct */
+	bnx2x_cnic_notify(bp, CNIC_CTL_ISCSI_STATS_GET_CMD);
+#endif
+}
+
 /* called due to MCP event (on pmf):
  *	reread new bandwidth configuration
  *	configure FW
@@ -2932,6 +3085,50 @@ static inline void bnx2x_set_mf_bw(struct bnx2x *bp)
 	bnx2x_fw_command(bp, DRV_MSG_CODE_SET_MF_BW_ACK, 0);
 }
 
+static inline void bnx2x_handle_drv_info_req(struct bnx2x *bp)
+{
+	enum drv_info_opcode op_code;
+	u32 drv_info_ctl = SHMEM2_RD(bp, drv_info_control);
+
+	/* if drv_info version supported by MFW doesn't match - send NACK */
+	if ((drv_info_ctl & DRV_INFO_CONTROL_VER_MASK) != DRV_INFO_CUR_VER) {
+		bnx2x_fw_command(bp, DRV_MSG_CODE_DRV_INFO_NACK, 0);
+		return;
+	}
+
+	op_code = (drv_info_ctl & DRV_INFO_CONTROL_OP_CODE_MASK) >>
+		DRV_INFO_CONTROL_OP_CODE_SHIFT;
+
+	memset(&bp->slowpath->drv_info_to_mcp, 0,
+		sizeof(union drv_info_to_mcp));
+
+	switch (op_code) {
+	case ETH_STATS_OPCODE:
+		bnx2x_drv_info_ether_stat(bp);
+		break;
+	case FCOE_STATS_OPCODE:
+		bnx2x_drv_info_fcoe_stat(bp);
+		break;
+	case ISCSI_STATS_OPCODE:
+		bnx2x_drv_info_iscsi_stat(bp);
+		break;
+	default:
+		/* if op code isn't supported - send NACK */
+		bnx2x_fw_command(bp, DRV_MSG_CODE_DRV_INFO_NACK, 0);
+		return;
+	}
+
+	/* if we got drv_info attn from MFW then these fields are defined in
+	 * shmem2 for sure
+	 */
+	SHMEM2_WR(bp, drv_info_host_addr_lo,
+		U64_LO(bnx2x_sp_mapping(bp, drv_info_to_mcp)));
+	SHMEM2_WR(bp, drv_info_host_addr_hi,
+		U64_HI(bnx2x_sp_mapping(bp, drv_info_to_mcp)));
+
+	bnx2x_fw_command(bp, DRV_MSG_CODE_DRV_INFO_ACK, 0);
+}
+
 static void bnx2x_dcc_event(struct bnx2x *bp, u32 dcc_event)
 {
 	DP(BNX2X_MSG_MCP, "dcc_event 0x%x\n", dcc_event);
@@ -3439,6 +3636,8 @@ static inline void bnx2x_attn_int_deasserted3(struct bnx2x *bp, u32 attn)
 			if (val & DRV_STATUS_SET_MF_BW)
 				bnx2x_set_mf_bw(bp);
 
+			if (val & DRV_STATUS_DRV_INFO_REQ)
+				bnx2x_handle_drv_info_req(bp);
 			if ((bp->port.pmf == 0) && (val & DRV_STATUS_PMF))
 				bnx2x_pmf_update(bp);
 
@@ -8716,7 +8915,7 @@ static void __devinit bnx2x_undi_unload(struct bnx2x *bp)
 
 static void __devinit bnx2x_get_common_hwinfo(struct bnx2x *bp)
 {
-	u32 val, val2, val3, val4, id;
+	u32 val, val2, val3, val4, id, boot_mode;
 	u16 pmc;
 
 	/* Get the chip revision id and number. */
@@ -8828,6 +9027,24 @@ static void __devinit bnx2x_get_common_hwinfo(struct bnx2x *bp)
 	bp->flags |= (val >= REQ_BC_VER_4_PFC_STATS_SUPPORTED) ?
 			BC_SUPPORTS_PFC_STATS : 0;
 
+	boot_mode = SHMEM_RD(bp,
+			dev_info.port_feature_config[BP_PORT(bp)].mba_config) &
+			PORT_FEATURE_MBA_BOOT_AGENT_TYPE_MASK;
+	switch (boot_mode) {
+	case PORT_FEATURE_MBA_BOOT_AGENT_TYPE_PXE:
+		bp->common.boot_mode = FEATURE_ETH_BOOTMODE_PXE;
+		break;
+	case PORT_FEATURE_MBA_BOOT_AGENT_TYPE_ISCSIB:
+		bp->common.boot_mode = FEATURE_ETH_BOOTMODE_ISCSI;
+		break;
+	case PORT_FEATURE_MBA_BOOT_AGENT_TYPE_FCOE_BOOT:
+		bp->common.boot_mode = FEATURE_ETH_BOOTMODE_FCOE;
+		break;
+	case PORT_FEATURE_MBA_BOOT_AGENT_TYPE_NONE:
+		bp->common.boot_mode = FEATURE_ETH_BOOTMODE_NONE;
+		break;
+	}
+
 	pci_read_config_word(bp->pdev, bp->pm_cap + PCI_PM_PMC, &pmc);
 	bp->flags |= (pmc & PCI_PM_CAP_PME_D3cold) ? 0 : NO_WOL_FLAG;
 
@@ -11550,6 +11767,38 @@ static int bnx2x_drv_ctl(struct net_device *dev, struct drv_ctl_info *ctl)
 		smp_mb__after_atomic_inc();
 		break;
 	}
+	case DRV_CTL_ULP_REGISTER_CMD: {
+		int ulp_type = ctl->data.ulp_type;
+
+		if (CHIP_IS_E3(bp)) {
+			int idx = BP_FW_MB_IDX(bp);
+			u32 cap;
+
+			cap = SHMEM2_RD(bp, drv_capabilities_flag[idx]);
+			if (ulp_type == CNIC_ULP_ISCSI)
+				cap |= DRV_FLAGS_CAPABILITIES_LOADED_ISCSI;
+			else if (ulp_type == CNIC_ULP_FCOE)
+				cap |= DRV_FLAGS_CAPABILITIES_LOADED_FCOE;
+			SHMEM2_WR(bp, drv_capabilities_flag[idx], cap);
+		}
+		break;
+	}
+	case DRV_CTL_ULP_UNREGISTER_CMD: {
+		int ulp_type = ctl->data.ulp_type;
+
+		if (CHIP_IS_E3(bp)) {
+			int idx = BP_FW_MB_IDX(bp);
+			u32 cap;
+
+			cap = SHMEM2_RD(bp, drv_capabilities_flag[idx]);
+			if (ulp_type == CNIC_ULP_ISCSI)
+				cap &= ~DRV_FLAGS_CAPABILITIES_LOADED_ISCSI;
+			else if (ulp_type == CNIC_ULP_FCOE)
+				cap &= ~DRV_FLAGS_CAPABILITIES_LOADED_FCOE;
+			SHMEM2_WR(bp, drv_capabilities_flag[idx], cap);
+		}
+		break;
+	}
 
 	default:
 		BNX2X_ERR("unknown command %x\n", ctl->cmd);
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c
index 41a33ce..c40e6b3 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c
@@ -39,6 +39,17 @@ static inline long bnx2x_hilo(u32 *hiref)
 #endif
 }
 
+static inline u16 bnx2x_get_port_stats_dma_len(struct bnx2x *bp)
+{
+	u16 res = sizeof(struct host_port_stats) >> 2;
+
+	/* if PFC stats are not supported by the MFW, don't DMA them */
+	if (!(bp->flags &  BC_SUPPORTS_PFC_STATS))
+		res -= (sizeof(u32)*4) >> 2;
+
+	return res;
+}
+
 /*
  * Init service functions
  */
@@ -178,7 +189,8 @@ static void bnx2x_stats_pmf_update(struct bnx2x *bp)
 				   DMAE_LEN32_RD_MAX * 4);
 	dmae->dst_addr_hi = U64_HI(bnx2x_sp_mapping(bp, port_stats) +
 				   DMAE_LEN32_RD_MAX * 4);
-	dmae->len = (sizeof(struct host_port_stats) >> 2) - DMAE_LEN32_RD_MAX;
+	dmae->len = bnx2x_get_port_stats_dma_len(bp) - DMAE_LEN32_RD_MAX;
+
 	dmae->comp_addr_lo = U64_LO(bnx2x_sp_mapping(bp, stats_comp));
 	dmae->comp_addr_hi = U64_HI(bnx2x_sp_mapping(bp, stats_comp));
 	dmae->comp_val = DMAE_COMP_VAL;
@@ -217,7 +229,7 @@ static void bnx2x_port_stats_init(struct bnx2x *bp)
 		dmae->src_addr_hi = U64_HI(bnx2x_sp_mapping(bp, port_stats));
 		dmae->dst_addr_lo = bp->port.port_stx >> 2;
 		dmae->dst_addr_hi = 0;
-		dmae->len = sizeof(struct host_port_stats) >> 2;
+		dmae->len = bnx2x_get_port_stats_dma_len(bp);
 		dmae->comp_addr_lo = dmae_reg_go_c[loader_idx] >> 2;
 		dmae->comp_addr_hi = 0;
 		dmae->comp_val = 1;
@@ -1307,7 +1319,7 @@ static void bnx2x_port_stats_stop(struct bnx2x *bp)
 		dmae->src_addr_hi = U64_HI(bnx2x_sp_mapping(bp, port_stats));
 		dmae->dst_addr_lo = bp->port.port_stx >> 2;
 		dmae->dst_addr_hi = 0;
-		dmae->len = sizeof(struct host_port_stats) >> 2;
+		dmae->len = bnx2x_get_port_stats_dma_len(bp);
 		if (bp->func_stx) {
 			dmae->comp_addr_lo = dmae_reg_go_c[loader_idx] >> 2;
 			dmae->comp_addr_hi = 0;
@@ -1424,7 +1436,7 @@ static void bnx2x_port_stats_base_init(struct bnx2x *bp)
 	dmae->src_addr_hi = U64_HI(bnx2x_sp_mapping(bp, port_stats));
 	dmae->dst_addr_lo = bp->port.port_stx >> 2;
 	dmae->dst_addr_hi = 0;
-	dmae->len = sizeof(struct host_port_stats) >> 2;
+	dmae->len = bnx2x_get_port_stats_dma_len(bp);
 	dmae->comp_addr_lo = U64_LO(bnx2x_sp_mapping(bp, stats_comp));
 	dmae->comp_addr_hi = U64_HI(bnx2x_sp_mapping(bp, stats_comp));
 	dmae->comp_val = DMAE_COMP_VAL;
diff --git a/drivers/net/ethernet/broadcom/cnic.c b/drivers/net/ethernet/broadcom/cnic.c
index b336e55..ea96420 100644
--- a/drivers/net/ethernet/broadcom/cnic.c
+++ b/drivers/net/ethernet/broadcom/cnic.c
@@ -250,6 +250,21 @@ static u32 cnic_reg_rd_ind(struct cnic_dev *dev, u32 off)
 	return io->data;
 }
 
+static void cnic_ulp_ctl(struct cnic_dev *dev, int ulp_type, bool reg)
+{
+	struct cnic_local *cp = dev->cnic_priv;
+	struct cnic_eth_dev *ethdev = cp->ethdev;
+	struct drv_ctl_info info;
+
+	if (reg)
+		info.cmd = DRV_CTL_ULP_REGISTER_CMD;
+	else
+		info.cmd = DRV_CTL_ULP_UNREGISTER_CMD;
+
+	info.data.ulp_type = ulp_type;
+	ethdev->drv_ctl(dev->netdev, &info);
+}
+
 static int cnic_in_use(struct cnic_sock *csk)
 {
 	return test_bit(SK_F_INUSE, &csk->flags);
@@ -563,6 +578,8 @@ static int cnic_register_device(struct cnic_dev *dev, int ulp_type,
 
 	mutex_unlock(&cnic_lock);
 
+	cnic_ulp_ctl(dev, ulp_type, true);
+
 	return 0;
 
 }
@@ -602,6 +619,8 @@ static int cnic_unregister_device(struct cnic_dev *dev, int ulp_type)
 	if (test_bit(ULP_F_CALL_PENDING, &cp->ulp_flags[ulp_type]))
 		netdev_warn(dev->netdev, "Failed waiting for ULP up call to complete\n");
 
+	cnic_ulp_ctl(dev, ulp_type, false);
+
 	return 0;
 }
 EXPORT_SYMBOL(cnic_unregister_driver);
@@ -3052,9 +3071,26 @@ static void cnic_ulp_start(struct cnic_dev *dev)
 	}
 }
 
+static int cnic_copy_ulp_stats(struct cnic_dev *dev, int ulp_type)
+{
+	struct cnic_local *cp = dev->cnic_priv;
+	struct cnic_ulp_ops *ulp_ops;
+	int rc;
+
+	mutex_lock(&cnic_lock);
+	ulp_ops = cnic_ulp_tbl_prot(ulp_type);
+	if (ulp_ops && ulp_ops->cnic_get_stats)
+		rc = ulp_ops->cnic_get_stats(cp->ulp_handle[ulp_type]);
+	else
+		rc = -ENODEV;
+	mutex_unlock(&cnic_lock);
+	return rc;
+}
+
 static int cnic_ctl(void *data, struct cnic_ctl_info *info)
 {
 	struct cnic_dev *dev = data;
+	int ulp_type = CNIC_ULP_ISCSI;
 
 	switch (info->cmd) {
 	case CNIC_CTL_STOP_CMD:
@@ -3100,6 +3136,15 @@ static int cnic_ctl(void *data, struct cnic_ctl_info *info)
 		}
 		break;
 	}
+	case CNIC_CTL_FCOE_STATS_GET_CMD:
+		ulp_type = CNIC_ULP_FCOE;
+		/* fall through */
+	case CNIC_CTL_ISCSI_STATS_GET_CMD:
+		cnic_hold(dev);
+		cnic_copy_ulp_stats(dev, ulp_type);
+		cnic_put(dev);
+		break;
+
 	default:
 		return -EINVAL;
 	}
@@ -5288,6 +5333,8 @@ static struct cnic_dev *init_bnx2x_cnic(struct net_device *dev)
 	cdev->pcidev = pdev;
 	cp->chip_id = ethdev->chip_id;
 
+	cdev->stats_addr = ethdev->addr_drv_info_to_mcp;
+
 	if (!(ethdev->drv_state & CNIC_DRV_STATE_NO_ISCSI))
 		cdev->max_iscsi_conn = ethdev->max_iscsi_conn;
 	if (BNX2X_CHIP_IS_E2_PLUS(cp->chip_id) &&
diff --git a/drivers/net/ethernet/broadcom/cnic_if.h b/drivers/net/ethernet/broadcom/cnic_if.h
index 79443e0..d1f6456 100644
--- a/drivers/net/ethernet/broadcom/cnic_if.h
+++ b/drivers/net/ethernet/broadcom/cnic_if.h
@@ -86,6 +86,8 @@ struct kcqe {
 #define CNIC_CTL_START_CMD		2
 #define CNIC_CTL_COMPLETION_CMD		3
 #define CNIC_CTL_STOP_ISCSI_CMD		4
+#define CNIC_CTL_FCOE_STATS_GET_CMD	5
+#define CNIC_CTL_ISCSI_STATS_GET_CMD	6
 
 #define DRV_CTL_IO_WR_CMD		0x101
 #define DRV_CTL_IO_RD_CMD		0x102
@@ -96,6 +98,8 @@ struct kcqe {
 #define DRV_CTL_STOP_L2_CMD		0x107
 #define DRV_CTL_RET_L2_SPQ_CREDIT_CMD	0x10c
 #define DRV_CTL_ISCSI_STOPPED_CMD	0x10d
+#define DRV_CTL_ULP_REGISTER_CMD	0x10e
+#define DRV_CTL_ULP_UNREGISTER_CMD	0x10f
 
 struct cnic_ctl_completion {
 	u32	cid;
@@ -133,6 +137,7 @@ struct drv_ctl_info {
 		struct drv_ctl_spq_credit credit;
 		struct drv_ctl_io io;
 		struct drv_ctl_l2_ring ring;
+		int ulp_type;
 		char bytes[MAX_DRV_CTL_DATA];
 	} data;
 };
@@ -201,6 +206,7 @@ struct cnic_eth_dev {
 					       struct kwqe_16 *[], u32);
 	int		(*drv_ctl)(struct net_device *, struct drv_ctl_info *);
 	unsigned long	reserved1[2];
+	union drv_info_to_mcp	*addr_drv_info_to_mcp;
 };
 
 struct cnic_sockaddr {
@@ -297,6 +303,8 @@ struct cnic_dev {
 	int		max_fcoe_conn;
 	int		max_rdma_conn;
 
+	union drv_info_to_mcp	*stats_addr;
+
 	void		*cnic_priv;
 };
 
@@ -326,6 +334,7 @@ struct cnic_ulp_ops {
 	void (*cm_remote_abort)(struct cnic_sock *);
 	int (*iscsi_nl_send_msg)(void *ulp_ctx, u32 msg_type,
 				  char *data, u16 data_size);
+	int (*cnic_get_stats)(void *ulp_ctx);
 	struct module *owner;
 	atomic_t ref_count;
 };
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH net-next 3/4] bnx2x: support classification config query
  2011-12-06  5:44   ` [PATCH net-next 3/4] bnx2x: support classification config query Michael Chan
  2011-12-06  5:44     ` [PATCH net-next 4/4] bnx2x, cnic: support DRV_INFO upon FW request Michael Chan
@ 2011-12-06  5:46     ` David Miller
  2011-12-06  5:57       ` Michael Chan
  2011-12-06  5:59       ` Joe Perches
  1 sibling, 2 replies; 8+ messages in thread
From: David Miller @ 2011-12-06  5:46 UTC (permalink / raw)
  To: mchan; +Cc: netdev, barak, eilong

From: "Michael Chan" <mchan@broadcom.com>
Date: Mon, 5 Dec 2011 21:44:47 -0800

> +	/* traverse list */
> +	list_for_each_entry(pos, &o->head, link)
> +	{

Put openning "{" at end of list_for_each_entry(), rather than
on a new line.

> +		if ((counter < n)) {

Excessive parenthesis, remove.

> +			memcpy(next + MAC_LEADING_ZERO_CNT,
> +				  pos->u.mac.mac, ETH_ALEN);

Paremeters on subsequent lines don't line up properly.

> +			next = buf + counter * ALIGN(ETH_ALEN,
> +							   sizeof(u32));

Likewise.

> +			DP(BNX2X_MSG_SP, "copied element number "
> +				   "%d to address %p element was "
> +				   "%pM\n", counter, next, pos->u.mac.mac);

Likewise.

> +	int (*get_n_elements)(struct bnx2x *bp,
> +			 struct bnx2x_vlan_mac_obj *o,
> +			 int n,
> +			 u8 *buf);
> +

Likewise.

Sigh.

Definitely a new-comer wrote this code, but I know more experienced hands
reviewed it, therefore I am disappointed.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH net-next 4/4] bnx2x, cnic: support DRV_INFO upon FW request
  2011-12-06  5:44     ` [PATCH net-next 4/4] bnx2x, cnic: support DRV_INFO upon FW request Michael Chan
@ 2011-12-06  5:56       ` Joe Perches
  0 siblings, 0 replies; 8+ messages in thread
From: Joe Perches @ 2011-12-06  5:56 UTC (permalink / raw)
  To: Michael Chan; +Cc: davem, netdev, barak, eilong

On Mon, 2011-12-05 at 21:44 -0800, Michael Chan wrote:
> From: Barak Witkowski <barak@broadcom.com>
> Add support to send driver capabilities, settings and statistics to
> management firmware.
[]
> diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
[]
> @@ -2912,6 +2912,159 @@ static void bnx2x_e1h_enable(struct bnx2x *bp)
>  	 */
>  }
>  
> +#define DRV_INFO_ETH_STAT_NUM_MACS_REQUIRED 3
> +
> +static inline void bnx2x_drv_info_ether_stat(struct bnx2x *bp)

Most likely this should not be inline

> +{
> +	/* leave last char as NULL */
> +	memcpy(bp->slowpath->drv_info_to_mcp.ether_stat.version,
> +		DRV_MODULE_VERSION, ETH_STAT_INFO_VERSION_LEN - 1);

This would read and perform a lot better with temporaries.
Many (all?) gcc versions don't optimize out the repeated indirections.

	whatever_type *dev = bp->dev;
	whatever_type *ether_stats = &bp->slowpath->drv_info_to_mp.etherstat;

> +
> +	bp->fp[0].mac_obj.get_n_elements(bp, &bp->fp[0].mac_obj,
> +					 DRV_INFO_ETH_STAT_NUM_MACS_REQUIRED,
> +			bp->slowpath->drv_info_to_mcp.ether_stat.mac_local);
> +
> +	bp->slowpath->drv_info_to_mcp.ether_stat.mtu_size = bp->dev->mtu;

	ether_stats->mtu_size = dev->mtu;
> +
> +	if (bp->dev->features & NETIF_F_RXCSUM)
> +		bp->slowpath->drv_info_to_mcp.ether_stat.feature_flags |=
> +		FEATURE_ETH_CHKSUM_OFFLOAD_MASK;

	if (dev->features & NETIF_F_RXCSUM)
		ether_stats->feature_flags |= FEATURE_ETH_CHKSUM_OFFLOAD_MASK;

> +	if (bp->dev->features & NETIF_F_TSO)
> +		bp->slowpath->drv_info_to_mcp.ether_stat.feature_flags |=
> +		FEATURE_ETH_LSO_MASK;

	if (dev->features & NETIF_F_TSO)
		ether_stats->feature_flags |= FEATURE_ETH_LSO_MASK;

> +	bp->slowpath->drv_info_to_mcp.ether_stat.feature_flags |=
> +		bp->common.boot_mode;

etc.,

> +static inline void bnx2x_drv_info_fcoe_stat(struct bnx2x *bp)
> +{
> +	struct bnx2x_dcbx_app_params *app = &bp->dcbx_port_params.app;
> +
> +	memcpy(bp->slowpath->drv_info_to_mcp.fcoe_stat.mac_local,
> +		bp->fip_mac, ETH_ALEN);

Same temporary use.

> +
> +	bp->slowpath->drv_info_to_mcp.fcoe_stat.qos_priority =
> +		app->traffic_type_priority[LLFC_TRAFFIC_TYPE_FCOE];
> +
> +	/* insert FCoE stats from ramrod response */
> +	if (!NO_FCOE(bp)) {
> +		struct tstorm_per_queue_stats *fcoe_q_tstorm_stats =
> +			&bp->fw_stats_data->queue_stats[FCOE_IDX].
> +			tstorm_queue_statistics;
> +
> +		struct xstorm_per_queue_stats *fcoe_q_xstorm_stats =
> +			&bp->fw_stats_data->queue_stats[FCOE_IDX].
> +			xstorm_queue_statistics;
> +
> +		ADD_64(bp->slowpath->drv_info_to_mcp.fcoe_stat.rx_bytes_hi,
> +			0,
> +			bp->slowpath->drv_info_to_mcp.fcoe_stat.rx_bytes_lo,
> +			bp->fw_stats_data->fcoe.rx_stat0.fcoe_rx_byte_cnt);

temporaries for bp->slowpath->drv_info_to_mcp.fcoe_stat
and bp->fw_stats_data->fcoe.rx_stat0 too.

> +
> +		ADD_64(bp->slowpath->drv_info_to_mcp.fcoe_stat.rx_bytes_hi,
> +			fcoe_q_tstorm_stats->rcv_ucast_bytes.hi,
> +			bp->slowpath->drv_info_to_mcp.fcoe_stat.rx_bytes_lo,
> +			fcoe_q_tstorm_stats->rcv_ucast_bytes.lo);
> +
> +		ADD_64(bp->slowpath->drv_info_to_mcp.fcoe_stat.rx_bytes_hi,
> +			fcoe_q_tstorm_stats->rcv_bcast_bytes.hi,
> +			bp->slowpath->drv_info_to_mcp.fcoe_stat.rx_bytes_lo,
> +			fcoe_q_tstorm_stats->rcv_bcast_bytes.lo);
> +
> +		ADD_64(bp->slowpath->drv_info_to_mcp.fcoe_stat.rx_bytes_hi,
> +			fcoe_q_tstorm_stats->rcv_mcast_bytes.hi,
> +			bp->slowpath->drv_info_to_mcp.fcoe_stat.rx_bytes_lo,
> +			fcoe_q_tstorm_stats->rcv_mcast_bytes.lo);
> +
> +		ADD_64(bp->slowpath->drv_info_to_mcp.fcoe_stat.rx_frames_hi,
> +			0,
> +			bp->slowpath->drv_info_to_mcp.fcoe_stat.rx_frames_lo,
> +			bp->fw_stats_data->fcoe.rx_stat0.fcoe_rx_pkt_cnt);
> +
> +		ADD_64(bp->slowpath->drv_info_to_mcp.fcoe_stat.rx_frames_hi,
> +			0,
> +			bp->slowpath->drv_info_to_mcp.fcoe_stat.rx_frames_lo,
> +			fcoe_q_tstorm_stats->rcv_ucast_pkts);
> +
> +		ADD_64(bp->slowpath->drv_info_to_mcp.fcoe_stat.rx_frames_hi,
> +			0,
> +			bp->slowpath->drv_info_to_mcp.fcoe_stat.rx_frames_lo,
> +			fcoe_q_tstorm_stats->rcv_bcast_pkts);
> +
> +		ADD_64(bp->slowpath->drv_info_to_mcp.fcoe_stat.rx_frames_hi,
> +			0,
> +			bp->slowpath->drv_info_to_mcp.fcoe_stat.rx_frames_lo,
> +			fcoe_q_tstorm_stats->rcv_ucast_pkts);
> +
> +		ADD_64(bp->slowpath->drv_info_to_mcp.fcoe_stat.tx_bytes_hi,
> +			0,
> +			bp->slowpath->drv_info_to_mcp.fcoe_stat.tx_bytes_lo,
> +			bp->fw_stats_data->fcoe.tx_stat.fcoe_tx_byte_cnt);
> +
> +		ADD_64(bp->slowpath->drv_info_to_mcp.fcoe_stat.tx_bytes_hi,
> +			fcoe_q_xstorm_stats->ucast_bytes_sent.hi,
> +			bp->slowpath->drv_info_to_mcp.fcoe_stat.tx_bytes_lo,
> +			fcoe_q_xstorm_stats->ucast_bytes_sent.lo);
> +
> +		ADD_64(bp->slowpath->drv_info_to_mcp.fcoe_stat.tx_bytes_hi,
> +			fcoe_q_xstorm_stats->bcast_bytes_sent.hi,
> +			bp->slowpath->drv_info_to_mcp.fcoe_stat.tx_bytes_lo,
> +			fcoe_q_xstorm_stats->bcast_bytes_sent.lo);
> +
> +		ADD_64(bp->slowpath->drv_info_to_mcp.fcoe_stat.tx_bytes_hi,
> +			fcoe_q_xstorm_stats->mcast_bytes_sent.hi,
> +			bp->slowpath->drv_info_to_mcp.fcoe_stat.tx_bytes_lo,
> +			fcoe_q_xstorm_stats->mcast_bytes_sent.lo);
> +
> +		ADD_64(bp->slowpath->drv_info_to_mcp.fcoe_stat.tx_frames_hi,
> +			0,
> +			bp->slowpath->drv_info_to_mcp.fcoe_stat.tx_frames_lo,
> +			bp->fw_stats_data->fcoe.tx_stat.fcoe_tx_pkt_cnt);
> +
> +		ADD_64(bp->slowpath->drv_info_to_mcp.fcoe_stat.tx_frames_hi,
> +			0,
> +			bp->slowpath->drv_info_to_mcp.fcoe_stat.tx_frames_lo,
> +			fcoe_q_xstorm_stats->ucast_pkts_sent);
> +
> +		ADD_64(bp->slowpath->drv_info_to_mcp.fcoe_stat.tx_frames_hi,
> +			0,
> +			bp->slowpath->drv_info_to_mcp.fcoe_stat.tx_frames_lo,
> +			fcoe_q_xstorm_stats->bcast_pkts_sent);
> +
> +		ADD_64(bp->slowpath->drv_info_to_mcp.fcoe_stat.tx_frames_hi,
> +			0,
> +			bp->slowpath->drv_info_to_mcp.fcoe_stat.tx_frames_lo,
> +			fcoe_q_xstorm_stats->mcast_pkts_sent);
> +	}
> +

cheers, Joe

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH net-next 3/4] bnx2x: support classification config query
  2011-12-06  5:46     ` [PATCH net-next 3/4] bnx2x: support classification config query David Miller
@ 2011-12-06  5:57       ` Michael Chan
  2011-12-06  5:59       ` Joe Perches
  1 sibling, 0 replies; 8+ messages in thread
From: Michael Chan @ 2011-12-06  5:57 UTC (permalink / raw)
  To: 'David Miller'
  Cc: 'netdev@vger.kernel.org', Barak Witkowski,
	Eilon Greenstein

David Miller wrote:

> 
> Sigh.
> 
> Definitely a new-comer wrote this code, but I know more experienced
> hands
> reviewed it, therefore I am disappointed.

Sorry, I'll fix everything up and re-send.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH net-next 3/4] bnx2x: support classification config query
  2011-12-06  5:46     ` [PATCH net-next 3/4] bnx2x: support classification config query David Miller
  2011-12-06  5:57       ` Michael Chan
@ 2011-12-06  5:59       ` Joe Perches
  1 sibling, 0 replies; 8+ messages in thread
From: Joe Perches @ 2011-12-06  5:59 UTC (permalink / raw)
  To: David Miller; +Cc: mchan, netdev, barak, eilong

On Tue, 2011-12-06 at 00:46 -0500, David Miller wrote:
> > +			DP(BNX2X_MSG_SP, "copied element number "
> > +				   "%d to address %p element was "
> > +				   "%pM\n", counter, next, pos->u.mac.mac);
> 
> Likewise.

Ideally, the format should be coalesced as well.

			DP(BNX2X_MSG_SP, "copied element number %d to address %p - element was %pM\n",
			   counter, next, pos->u.mac.mac);

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2011-12-06  5:59 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-06  5:44 [PATCH net-next 1/4] bnx2x: add PFC statistics Michael Chan
2011-12-06  5:44 ` [PATCH net-next 2/4] bnx2x: add fcoe statistics Michael Chan
2011-12-06  5:44   ` [PATCH net-next 3/4] bnx2x: support classification config query Michael Chan
2011-12-06  5:44     ` [PATCH net-next 4/4] bnx2x, cnic: support DRV_INFO upon FW request Michael Chan
2011-12-06  5:56       ` Joe Perches
2011-12-06  5:46     ` [PATCH net-next 3/4] bnx2x: support classification config query David Miller
2011-12-06  5:57       ` Michael Chan
2011-12-06  5:59       ` Joe Perches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).