Skip to content

Commit 50f0a56

Browse files
Barak Witkowskidavem330
authored andcommitted
bnx2x: add fcoe statistics
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> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 0e898dd commit 50f0a56

File tree

4 files changed

+120
-23
lines changed

4 files changed

+120
-23
lines changed

drivers/net/ethernet/broadcom/bnx2x/bnx2x.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1128,18 +1128,21 @@ enum {
11281128
enum {
11291129
BNX2X_PORT_QUERY_IDX,
11301130
BNX2X_PF_QUERY_IDX,
1131+
BNX2X_FCOE_QUERY_IDX,
11311132
BNX2X_FIRST_QUEUE_QUERY_IDX,
11321133
};
11331134

11341135
struct bnx2x_fw_stats_req {
11351136
struct stats_query_header hdr;
1136-
struct stats_query_entry query[STATS_QUERY_CMD_COUNT];
1137+
struct stats_query_entry query[FP_SB_MAX_E1x+
1138+
BNX2X_FIRST_QUEUE_QUERY_IDX];
11371139
};
11381140

11391141
struct bnx2x_fw_stats_data {
11401142
struct stats_counter storm_counters;
11411143
struct per_port_stats port;
11421144
struct per_pf_stats pf;
1145+
struct fcoe_statistics_params fcoe;
11431146
struct per_queue_stats queue_stats[1];
11441147
};
11451148

drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4166,8 +4166,62 @@ struct ustorm_eth_rx_producers {
41664166

41674167

41684168
/*
4169-
* cfc delete event data
4169+
* FCoE RX statistics parameters section#0
4170+
*/
4171+
struct fcoe_rx_stat_params_section0 {
4172+
__le32 fcoe_rx_pkt_cnt;
4173+
__le32 fcoe_rx_byte_cnt;
4174+
};
4175+
4176+
4177+
/*
4178+
* FCoE RX statistics parameters section#1
4179+
*/
4180+
struct fcoe_rx_stat_params_section1 {
4181+
__le32 fcoe_ver_cnt;
4182+
__le32 fcoe_rx_drop_pkt_cnt;
4183+
};
4184+
4185+
4186+
/*
4187+
* FCoE RX statistics parameters section#2
41704188
*/
4189+
struct fcoe_rx_stat_params_section2 {
4190+
__le32 fc_crc_cnt;
4191+
__le32 eofa_del_cnt;
4192+
__le32 miss_frame_cnt;
4193+
__le32 seq_timeout_cnt;
4194+
__le32 drop_seq_cnt;
4195+
__le32 fcoe_rx_drop_pkt_cnt;
4196+
__le32 fcp_rx_pkt_cnt;
4197+
__le32 reserved0;
4198+
};
4199+
4200+
4201+
/*
4202+
* FCoE TX statistics parameters
4203+
*/
4204+
struct fcoe_tx_stat_params {
4205+
__le32 fcoe_tx_pkt_cnt;
4206+
__le32 fcoe_tx_byte_cnt;
4207+
__le32 fcp_tx_pkt_cnt;
4208+
__le32 reserved0;
4209+
};
4210+
4211+
/*
4212+
* FCoE statistics parameters
4213+
*/
4214+
struct fcoe_statistics_params {
4215+
struct fcoe_tx_stat_params tx_stat;
4216+
struct fcoe_rx_stat_params_section0 rx_stat0;
4217+
struct fcoe_rx_stat_params_section1 rx_stat1;
4218+
struct fcoe_rx_stat_params_section2 rx_stat2;
4219+
};
4220+
4221+
4222+
/*
4223+
* cfc delete event data
4224+
*/
41714225
struct cfc_del_event_data {
41724226
u32 cid;
41734227
u32 reserved0;

drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2624,15 +2624,6 @@ u32 bnx2x_fw_command(struct bnx2x *bp, u32 command, u32 param)
26242624
return rc;
26252625
}
26262626

2627-
static u8 stat_counter_valid(struct bnx2x *bp, struct bnx2x_fastpath *fp)
2628-
{
2629-
#ifdef BCM_CNIC
2630-
/* Statistics are not supported for CNIC Clients at the moment */
2631-
if (IS_FCOE_FP(fp))
2632-
return false;
2633-
#endif
2634-
return true;
2635-
}
26362627

26372628
void bnx2x_func_init(struct bnx2x *bp, struct bnx2x_func_init_params *p)
26382629
{
@@ -2676,11 +2667,11 @@ static inline unsigned long bnx2x_get_common_flags(struct bnx2x *bp,
26762667
* parent connection). The statistics are zeroed when the parent
26772668
* connection is initialized.
26782669
*/
2679-
if (stat_counter_valid(bp, fp)) {
2680-
__set_bit(BNX2X_Q_FLG_STATS, &flags);
2681-
if (zero_stats)
2682-
__set_bit(BNX2X_Q_FLG_ZERO_STATS, &flags);
2683-
}
2670+
2671+
__set_bit(BNX2X_Q_FLG_STATS, &flags);
2672+
if (zero_stats)
2673+
__set_bit(BNX2X_Q_FLG_ZERO_STATS, &flags);
2674+
26842675

26852676
return flags;
26862677
}
@@ -6848,22 +6839,25 @@ void bnx2x_free_mem(struct bnx2x *bp)
68486839
static inline int bnx2x_alloc_fw_stats_mem(struct bnx2x *bp)
68496840
{
68506841
int num_groups;
6842+
int is_fcoe_stats = NO_FCOE(bp) ? 0 : 1;
68516843

6852-
/* number of eth_queues */
6853-
u8 num_queue_stats = BNX2X_NUM_ETH_QUEUES(bp);
6844+
/* number of queues for statistics is number of eth queues + FCoE */
6845+
u8 num_queue_stats = BNX2X_NUM_ETH_QUEUES(bp) + is_fcoe_stats;
68546846

68556847
/* Total number of FW statistics requests =
6856-
* 1 for port stats + 1 for PF stats + num_eth_queues */
6857-
bp->fw_stats_num = 2 + num_queue_stats;
6848+
* 1 for port stats + 1 for PF stats + potential 1 for FCoE stats +
6849+
* num of queues
6850+
*/
6851+
bp->fw_stats_num = 2 + is_fcoe_stats + num_queue_stats;
68586852

68596853

68606854
/* Request is built from stats_query_header and an array of
68616855
* stats_query_cmd_group each of which contains
68626856
* STATS_QUERY_CMD_COUNT rules. The real number or requests is
68636857
* configured in the stats_query_header.
68646858
*/
6865-
num_groups = (2 + num_queue_stats) / STATS_QUERY_CMD_COUNT +
6866-
(((2 + num_queue_stats) % STATS_QUERY_CMD_COUNT) ? 1 : 0);
6859+
num_groups = ((bp->fw_stats_num) / STATS_QUERY_CMD_COUNT) +
6860+
(((bp->fw_stats_num) % STATS_QUERY_CMD_COUNT) ? 1 : 0);
68676861

68686862
bp->fw_stats_req_sz = sizeof(struct stats_query_header) +
68696863
num_groups * sizeof(struct stats_query_cmd_group);
@@ -6872,9 +6866,13 @@ static inline int bnx2x_alloc_fw_stats_mem(struct bnx2x *bp)
68726866
*
68736867
* stats_counter holds per-STORM counters that are incremented
68746868
* when STORM has finished with the current request.
6869+
*
6870+
* memory for FCoE offloaded statistics are counted anyway,
6871+
* even if they will not be sent.
68756872
*/
68766873
bp->fw_stats_data_sz = sizeof(struct per_port_stats) +
68776874
sizeof(struct per_pf_stats) +
6875+
sizeof(struct fcoe_statistics_params) +
68786876
sizeof(struct per_queue_stats) * num_queue_stats +
68796877
sizeof(struct stats_counter);
68806878

drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1501,6 +1501,7 @@ static void bnx2x_func_stats_base_update(struct bnx2x *bp)
15011501
static inline void bnx2x_prep_fw_stats_req(struct bnx2x *bp)
15021502
{
15031503
int i;
1504+
int first_queue_query_index;
15041505
struct stats_query_header *stats_hdr = &bp->fw_stats_req->hdr;
15051506

15061507
dma_addr_t cur_data_offset;
@@ -1556,14 +1557,40 @@ static inline void bnx2x_prep_fw_stats_req(struct bnx2x *bp)
15561557
cur_query_entry->address.hi = cpu_to_le32(U64_HI(cur_data_offset));
15571558
cur_query_entry->address.lo = cpu_to_le32(U64_LO(cur_data_offset));
15581559

1560+
/**** FCoE FW statistics data ****/
1561+
if (!NO_FCOE(bp)) {
1562+
cur_data_offset = bp->fw_stats_data_mapping +
1563+
offsetof(struct bnx2x_fw_stats_data, fcoe);
1564+
1565+
cur_query_entry =
1566+
&bp->fw_stats_req->query[BNX2X_FCOE_QUERY_IDX];
1567+
1568+
cur_query_entry->kind = STATS_TYPE_FCOE;
1569+
/* For FCoE query index is a DONT CARE */
1570+
cur_query_entry->index = BP_PORT(bp);
1571+
cur_query_entry->funcID = cpu_to_le16(BP_FUNC(bp));
1572+
cur_query_entry->address.hi =
1573+
cpu_to_le32(U64_HI(cur_data_offset));
1574+
cur_query_entry->address.lo =
1575+
cpu_to_le32(U64_LO(cur_data_offset));
1576+
}
1577+
15591578
/**** Clients' queries ****/
15601579
cur_data_offset = bp->fw_stats_data_mapping +
15611580
offsetof(struct bnx2x_fw_stats_data, queue_stats);
15621581

1582+
/* first queue query index depends whether FCoE offloaded request will
1583+
* be included in the ramrod
1584+
*/
1585+
if (!NO_FCOE(bp))
1586+
first_queue_query_index = BNX2X_FIRST_QUEUE_QUERY_IDX;
1587+
else
1588+
first_queue_query_index = BNX2X_FIRST_QUEUE_QUERY_IDX - 1;
1589+
15631590
for_each_eth_queue(bp, i) {
15641591
cur_query_entry =
15651592
&bp->fw_stats_req->
1566-
query[BNX2X_FIRST_QUEUE_QUERY_IDX + i];
1593+
query[first_queue_query_index + i];
15671594

15681595
cur_query_entry->kind = STATS_TYPE_QUEUE;
15691596
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)
15751602

15761603
cur_data_offset += sizeof(struct per_queue_stats);
15771604
}
1605+
1606+
/* add FCoE queue query if needed */
1607+
if (!NO_FCOE(bp)) {
1608+
cur_query_entry =
1609+
&bp->fw_stats_req->
1610+
query[first_queue_query_index + i];
1611+
1612+
cur_query_entry->kind = STATS_TYPE_QUEUE;
1613+
cur_query_entry->index = bnx2x_stats_id(&bp->fp[FCOE_IDX]);
1614+
cur_query_entry->funcID = cpu_to_le16(BP_FUNC(bp));
1615+
cur_query_entry->address.hi =
1616+
cpu_to_le32(U64_HI(cur_data_offset));
1617+
cur_query_entry->address.lo =
1618+
cpu_to_le32(U64_LO(cur_data_offset));
1619+
}
15781620
}
15791621

15801622
void bnx2x_stats_init(struct bnx2x *bp)

0 commit comments

Comments
 (0)