Skip to content

Commit

Permalink
be2net: Stats for Lancer
Browse files Browse the repository at this point in the history
Added Lancer stats implementation.

Signed-off-by: Selvin Xavier <selvin.xavier@emulex.com>
Signed-off-by: Padmanabh Ratnakar <padmanabh.ratnakar@emulex.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Selvin Xavier authored and David S. Miller committed May 16, 2011
1 parent 89a88ab commit 005d569
Show file tree
Hide file tree
Showing 4 changed files with 367 additions and 50 deletions.
74 changes: 37 additions & 37 deletions drivers/net/benet/be.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,43 +244,43 @@ struct be_rx_obj {

struct be_drv_stats {
u8 be_on_die_temperature;
u32 be_tx_events;
u32 eth_red_drops;
u32 rx_drops_no_pbuf;
u32 rx_drops_no_txpb;
u32 rx_drops_no_erx_descr;
u32 rx_drops_no_tpre_descr;
u32 rx_drops_too_many_frags;
u32 rx_drops_invalid_ring;
u32 forwarded_packets;
u32 rx_drops_mtu;
u32 rx_crc_errors;
u32 rx_alignment_symbol_errors;
u32 rx_pause_frames;
u32 rx_priority_pause_frames;
u32 rx_control_frames;
u32 rx_in_range_errors;
u32 rx_out_range_errors;
u32 rx_frame_too_long;
u32 rx_address_match_errors;
u32 rx_dropped_too_small;
u32 rx_dropped_too_short;
u32 rx_dropped_header_too_small;
u32 rx_dropped_tcp_length;
u32 rx_dropped_runt;
u32 rx_ip_checksum_errs;
u32 rx_tcp_checksum_errs;
u32 rx_udp_checksum_errs;
u32 rx_switched_unicast_packets;
u32 rx_switched_multicast_packets;
u32 rx_switched_broadcast_packets;
u32 tx_pauseframes;
u32 tx_priority_pauseframes;
u32 tx_controlframes;
u32 rxpp_fifo_overflow_drop;
u32 rx_input_fifo_overflow_drop;
u32 pmem_fifo_overflow_drop;
u32 jabber_events;
u64 be_tx_events;
u64 eth_red_drops;
u64 rx_drops_no_pbuf;
u64 rx_drops_no_txpb;
u64 rx_drops_no_erx_descr;
u64 rx_drops_no_tpre_descr;
u64 rx_drops_too_many_frags;
u64 rx_drops_invalid_ring;
u64 forwarded_packets;
u64 rx_drops_mtu;
u64 rx_crc_errors;
u64 rx_alignment_symbol_errors;
u64 rx_pause_frames;
u64 rx_priority_pause_frames;
u64 rx_control_frames;
u64 rx_in_range_errors;
u64 rx_out_range_errors;
u64 rx_frame_too_long;
u64 rx_address_match_errors;
u64 rx_dropped_too_small;
u64 rx_dropped_too_short;
u64 rx_dropped_header_too_small;
u64 rx_dropped_tcp_length;
u64 rx_dropped_runt;
u64 rx_ip_checksum_errs;
u64 rx_tcp_checksum_errs;
u64 rx_udp_checksum_errs;
u64 rx_switched_unicast_packets;
u64 rx_switched_multicast_packets;
u64 rx_switched_broadcast_packets;
u64 tx_pauseframes;
u64 tx_priority_pauseframes;
u64 tx_controlframes;
u64 rxpp_fifo_overflow_drop;
u64 rx_input_fifo_overflow_drop;
u64 pmem_fifo_overflow_drop;
u64 jabber_events;
};

struct be_vf_cfg {
Expand Down
55 changes: 53 additions & 2 deletions drivers/net/benet/be_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,22 @@ static int be_mcc_compl_process(struct be_adapter *adapter,
}

if (compl_status == MCC_STATUS_SUCCESS) {
if ((compl->tag0 == OPCODE_ETH_GET_STATISTICS) &&
if (((compl->tag0 == OPCODE_ETH_GET_STATISTICS) ||
(compl->tag0 == OPCODE_ETH_GET_PPORT_STATS)) &&
(compl->tag1 == CMD_SUBSYSTEM_ETH)) {
if (adapter->generation == BE_GEN3) {
struct be_cmd_resp_get_stats_v1 *resp =
if (lancer_chip(adapter)) {
struct lancer_cmd_resp_pport_stats
*resp = adapter->stats_cmd.va;
be_dws_le_to_cpu(&resp->pport_stats,
sizeof(resp->pport_stats));
} else {
struct be_cmd_resp_get_stats_v1 *resp =
adapter->stats_cmd.va;

be_dws_le_to_cpu(&resp->hw_stats,
sizeof(resp->hw_stats));
}
} else {
struct be_cmd_resp_get_stats_v0 *resp =
adapter->stats_cmd.va;
Expand Down Expand Up @@ -1124,6 +1132,49 @@ int be_cmd_get_stats(struct be_adapter *adapter, struct be_dma_mem *nonemb_cmd)
return status;
}

/* Lancer Stats */
int lancer_cmd_get_pport_stats(struct be_adapter *adapter,
struct be_dma_mem *nonemb_cmd)
{

struct be_mcc_wrb *wrb;
struct lancer_cmd_req_pport_stats *req;
struct be_sge *sge;
int status = 0;

spin_lock_bh(&adapter->mcc_lock);

wrb = wrb_from_mccq(adapter);
if (!wrb) {
status = -EBUSY;
goto err;
}
req = nonemb_cmd->va;
sge = nonembedded_sgl(wrb);

be_wrb_hdr_prepare(wrb, nonemb_cmd->size, false, 1,
OPCODE_ETH_GET_PPORT_STATS);

be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ETH,
OPCODE_ETH_GET_PPORT_STATS, nonemb_cmd->size);


req->cmd_params.params.pport_num = cpu_to_le16(adapter->port_num);
req->cmd_params.params.reset_stats = 0;

wrb->tag1 = CMD_SUBSYSTEM_ETH;
sge->pa_hi = cpu_to_le32(upper_32_bits(nonemb_cmd->dma));
sge->pa_lo = cpu_to_le32(nonemb_cmd->dma & 0xFFFFFFFF);
sge->len = cpu_to_le32(nonemb_cmd->size);

be_mcc_notify(adapter);
adapter->stats_cmd_sent = true;

err:
spin_unlock_bh(&adapter->mcc_lock);
return status;
}

/* Uses synchronous mcc */
int be_cmd_link_status_query(struct be_adapter *adapter,
bool *link_up, u8 *mac_speed, u16 *link_speed, u32 dom)
Expand Down
197 changes: 197 additions & 0 deletions drivers/net/benet/be_cmds.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ struct be_mcc_mailbox {
#define OPCODE_ETH_TX_DESTROY 9
#define OPCODE_ETH_RX_DESTROY 10
#define OPCODE_ETH_ACPI_WOL_MAGIC_CONFIG 12
#define OPCODE_ETH_GET_PPORT_STATS 18

#define OPCODE_LOWLEVEL_HOST_DDR_DMA 17
#define OPCODE_LOWLEVEL_LOOPBACK_TEST 18
Expand Down Expand Up @@ -688,6 +689,200 @@ struct be_cmd_resp_get_stats_v0 {
struct be_hw_stats_v0 hw_stats;
};

#define make_64bit_val(hi_32, lo_32) (((u64)hi_32<<32) | lo_32)
struct lancer_cmd_pport_stats {
u32 tx_packets_lo;
u32 tx_packets_hi;
u32 tx_unicast_packets_lo;
u32 tx_unicast_packets_hi;
u32 tx_multicast_packets_lo;
u32 tx_multicast_packets_hi;
u32 tx_broadcast_packets_lo;
u32 tx_broadcast_packets_hi;
u32 tx_bytes_lo;
u32 tx_bytes_hi;
u32 tx_unicast_bytes_lo;
u32 tx_unicast_bytes_hi;
u32 tx_multicast_bytes_lo;
u32 tx_multicast_bytes_hi;
u32 tx_broadcast_bytes_lo;
u32 tx_broadcast_bytes_hi;
u32 tx_discards_lo;
u32 tx_discards_hi;
u32 tx_errors_lo;
u32 tx_errors_hi;
u32 tx_pause_frames_lo;
u32 tx_pause_frames_hi;
u32 tx_pause_on_frames_lo;
u32 tx_pause_on_frames_hi;
u32 tx_pause_off_frames_lo;
u32 tx_pause_off_frames_hi;
u32 tx_internal_mac_errors_lo;
u32 tx_internal_mac_errors_hi;
u32 tx_control_frames_lo;
u32 tx_control_frames_hi;
u32 tx_packets_64_bytes_lo;
u32 tx_packets_64_bytes_hi;
u32 tx_packets_65_to_127_bytes_lo;
u32 tx_packets_65_to_127_bytes_hi;
u32 tx_packets_128_to_255_bytes_lo;
u32 tx_packets_128_to_255_bytes_hi;
u32 tx_packets_256_to_511_bytes_lo;
u32 tx_packets_256_to_511_bytes_hi;
u32 tx_packets_512_to_1023_bytes_lo;
u32 tx_packets_512_to_1023_bytes_hi;
u32 tx_packets_1024_to_1518_bytes_lo;
u32 tx_packets_1024_to_1518_bytes_hi;
u32 tx_packets_1519_to_2047_bytes_lo;
u32 tx_packets_1519_to_2047_bytes_hi;
u32 tx_packets_2048_to_4095_bytes_lo;
u32 tx_packets_2048_to_4095_bytes_hi;
u32 tx_packets_4096_to_8191_bytes_lo;
u32 tx_packets_4096_to_8191_bytes_hi;
u32 tx_packets_8192_to_9216_bytes_lo;
u32 tx_packets_8192_to_9216_bytes_hi;
u32 tx_lso_packets_lo;
u32 tx_lso_packets_hi;
u32 rx_packets_lo;
u32 rx_packets_hi;
u32 rx_unicast_packets_lo;
u32 rx_unicast_packets_hi;
u32 rx_multicast_packets_lo;
u32 rx_multicast_packets_hi;
u32 rx_broadcast_packets_lo;
u32 rx_broadcast_packets_hi;
u32 rx_bytes_lo;
u32 rx_bytes_hi;
u32 rx_unicast_bytes_lo;
u32 rx_unicast_bytes_hi;
u32 rx_multicast_bytes_lo;
u32 rx_multicast_bytes_hi;
u32 rx_broadcast_bytes_lo;
u32 rx_broadcast_bytes_hi;
u32 rx_unknown_protos;
u32 rsvd_69; /* Word 69 is reserved */
u32 rx_discards_lo;
u32 rx_discards_hi;
u32 rx_errors_lo;
u32 rx_errors_hi;
u32 rx_crc_errors_lo;
u32 rx_crc_errors_hi;
u32 rx_alignment_errors_lo;
u32 rx_alignment_errors_hi;
u32 rx_symbol_errors_lo;
u32 rx_symbol_errors_hi;
u32 rx_pause_frames_lo;
u32 rx_pause_frames_hi;
u32 rx_pause_on_frames_lo;
u32 rx_pause_on_frames_hi;
u32 rx_pause_off_frames_lo;
u32 rx_pause_off_frames_hi;
u32 rx_frames_too_long_lo;
u32 rx_frames_too_long_hi;
u32 rx_internal_mac_errors_lo;
u32 rx_internal_mac_errors_hi;
u32 rx_undersize_packets;
u32 rx_oversize_packets;
u32 rx_fragment_packets;
u32 rx_jabbers;
u32 rx_control_frames_lo;
u32 rx_control_frames_hi;
u32 rx_control_frames_unknown_opcode_lo;
u32 rx_control_frames_unknown_opcode_hi;
u32 rx_in_range_errors;
u32 rx_out_of_range_errors;
u32 rx_address_match_errors;
u32 rx_vlan_mismatch_errors;
u32 rx_dropped_too_small;
u32 rx_dropped_too_short;
u32 rx_dropped_header_too_small;
u32 rx_dropped_invalid_tcp_length;
u32 rx_dropped_runt;
u32 rx_ip_checksum_errors;
u32 rx_tcp_checksum_errors;
u32 rx_udp_checksum_errors;
u32 rx_non_rss_packets;
u32 rsvd_111;
u32 rx_ipv4_packets_lo;
u32 rx_ipv4_packets_hi;
u32 rx_ipv6_packets_lo;
u32 rx_ipv6_packets_hi;
u32 rx_ipv4_bytes_lo;
u32 rx_ipv4_bytes_hi;
u32 rx_ipv6_bytes_lo;
u32 rx_ipv6_bytes_hi;
u32 rx_nic_packets_lo;
u32 rx_nic_packets_hi;
u32 rx_tcp_packets_lo;
u32 rx_tcp_packets_hi;
u32 rx_iscsi_packets_lo;
u32 rx_iscsi_packets_hi;
u32 rx_management_packets_lo;
u32 rx_management_packets_hi;
u32 rx_switched_unicast_packets_lo;
u32 rx_switched_unicast_packets_hi;
u32 rx_switched_multicast_packets_lo;
u32 rx_switched_multicast_packets_hi;
u32 rx_switched_broadcast_packets_lo;
u32 rx_switched_broadcast_packets_hi;
u32 num_forwards_lo;
u32 num_forwards_hi;
u32 rx_fifo_overflow;
u32 rx_input_fifo_overflow;
u32 rx_drops_too_many_frags_lo;
u32 rx_drops_too_many_frags_hi;
u32 rx_drops_invalid_queue;
u32 rsvd_141;
u32 rx_drops_mtu_lo;
u32 rx_drops_mtu_hi;
u32 rx_packets_64_bytes_lo;
u32 rx_packets_64_bytes_hi;
u32 rx_packets_65_to_127_bytes_lo;
u32 rx_packets_65_to_127_bytes_hi;
u32 rx_packets_128_to_255_bytes_lo;
u32 rx_packets_128_to_255_bytes_hi;
u32 rx_packets_256_to_511_bytes_lo;
u32 rx_packets_256_to_511_bytes_hi;
u32 rx_packets_512_to_1023_bytes_lo;
u32 rx_packets_512_to_1023_bytes_hi;
u32 rx_packets_1024_to_1518_bytes_lo;
u32 rx_packets_1024_to_1518_bytes_hi;
u32 rx_packets_1519_to_2047_bytes_lo;
u32 rx_packets_1519_to_2047_bytes_hi;
u32 rx_packets_2048_to_4095_bytes_lo;
u32 rx_packets_2048_to_4095_bytes_hi;
u32 rx_packets_4096_to_8191_bytes_lo;
u32 rx_packets_4096_to_8191_bytes_hi;
u32 rx_packets_8192_to_9216_bytes_lo;
u32 rx_packets_8192_to_9216_bytes_hi;
};

struct pport_stats_params {
u16 pport_num;
u8 rsvd;
u8 reset_stats;
};

struct lancer_cmd_req_pport_stats {
struct be_cmd_req_hdr hdr;
union {
struct pport_stats_params params;
u8 rsvd[sizeof(struct lancer_cmd_pport_stats)];
} cmd_params;
};

struct lancer_cmd_resp_pport_stats {
struct be_cmd_resp_hdr hdr;
struct lancer_cmd_pport_stats pport_stats;
};

static inline struct lancer_cmd_pport_stats*
pport_stats_from_cmd(struct be_adapter *adapter)
{
struct lancer_cmd_resp_pport_stats *cmd = adapter->stats_cmd.va;
return &cmd->pport_stats;
}

struct be_cmd_req_get_cntl_addnl_attribs {
struct be_cmd_req_hdr hdr;
u8 rsvd[8];
Expand Down Expand Up @@ -1258,6 +1453,8 @@ extern int be_cmd_link_status_query(struct be_adapter *adapter,
extern int be_cmd_reset(struct be_adapter *adapter);
extern int be_cmd_get_stats(struct be_adapter *adapter,
struct be_dma_mem *nonemb_cmd);
extern int lancer_cmd_get_pport_stats(struct be_adapter *adapter,
struct be_dma_mem *nonemb_cmd);
extern int be_cmd_get_fw_ver(struct be_adapter *adapter, char *fw_ver);

extern int be_cmd_modify_eqd(struct be_adapter *adapter, u32 eq_id, u32 eqd);
Expand Down
Loading

0 comments on commit 005d569

Please sign in to comment.