Commit 3abcdeda authored by Sathya Perla's avatar Sathya Perla Committed by David S. Miller

be2net: add multiple RX queue support

This patch adds multiple RX queue support to be2net. There are
upto 4 extra rx-queues per port into which TCP/UDP traffic can be hashed into.
Some of the ethtool stats are now displayed on a per queue basis.
Signed-off-by: default avatarSathya Perla <sathya.perla@emulex.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 72829071
...@@ -78,6 +78,8 @@ static inline char *nic_name(struct pci_dev *pdev) ...@@ -78,6 +78,8 @@ static inline char *nic_name(struct pci_dev *pdev)
#define MCC_Q_LEN 128 /* total size not to exceed 8 pages */ #define MCC_Q_LEN 128 /* total size not to exceed 8 pages */
#define MCC_CQ_LEN 256 #define MCC_CQ_LEN 256
#define MAX_RSS_QS 4 /* BE limit is 4 queues/port */
#define BE_MAX_MSIX_VECTORS (MAX_RSS_QS + 1 + 1)/* RSS qs + 1 def Rx + Tx */
#define BE_NAPI_WEIGHT 64 #define BE_NAPI_WEIGHT 64
#define MAX_RX_POST BE_NAPI_WEIGHT /* Frags posted at a time */ #define MAX_RX_POST BE_NAPI_WEIGHT /* Frags posted at a time */
#define RX_FRAGS_REFILL_WM (RX_Q_LEN - MAX_RX_POST) #define RX_FRAGS_REFILL_WM (RX_Q_LEN - MAX_RX_POST)
...@@ -157,10 +159,9 @@ struct be_mcc_obj { ...@@ -157,10 +159,9 @@ struct be_mcc_obj {
bool rearm_cq; bool rearm_cq;
}; };
struct be_drvr_stats { struct be_tx_stats {
u32 be_tx_reqs; /* number of TX requests initiated */ u32 be_tx_reqs; /* number of TX requests initiated */
u32 be_tx_stops; /* number of times TX Q was stopped */ u32 be_tx_stops; /* number of times TX Q was stopped */
u32 be_fwd_reqs; /* number of send reqs through forwarding i/f */
u32 be_tx_wrbs; /* number of tx WRBs used */ u32 be_tx_wrbs; /* number of tx WRBs used */
u32 be_tx_events; /* number of tx completion events */ u32 be_tx_events; /* number of tx completion events */
u32 be_tx_compl; /* number of tx completion entries processed */ u32 be_tx_compl; /* number of tx completion entries processed */
...@@ -169,35 +170,6 @@ struct be_drvr_stats { ...@@ -169,35 +170,6 @@ struct be_drvr_stats {
u64 be_tx_bytes_prev; u64 be_tx_bytes_prev;
u64 be_tx_pkts; u64 be_tx_pkts;
u32 be_tx_rate; u32 be_tx_rate;
u32 cache_barrier[16];
u32 be_ethrx_post_fail;/* number of ethrx buffer alloc failures */
u32 be_rx_polls; /* number of times NAPI called poll function */
u32 be_rx_events; /* number of ucast rx completion events */
u32 be_rx_compl; /* number of rx completion entries processed */
ulong be_rx_jiffies;
u64 be_rx_bytes;
u64 be_rx_bytes_prev;
u64 be_rx_pkts;
u32 be_rx_rate;
u32 be_rx_mcast_pkt;
/* number of non ether type II frames dropped where
* frame len > length field of Mac Hdr */
u32 be_802_3_dropped_frames;
/* number of non ether type II frames malformed where
* in frame len < length field of Mac Hdr */
u32 be_802_3_malformed_frames;
u32 be_rxcp_err; /* Num rx completion entries w/ err set. */
ulong rx_fps_jiffies; /* jiffies at last FPS calc */
u32 be_rx_frags;
u32 be_prev_rx_frags;
u32 be_rx_fps; /* Rx frags per second */
};
struct be_stats_obj {
struct be_drvr_stats drvr_stats;
struct be_dma_mem cmd;
}; };
struct be_tx_obj { struct be_tx_obj {
...@@ -215,10 +187,34 @@ struct be_rx_page_info { ...@@ -215,10 +187,34 @@ struct be_rx_page_info {
bool last_page_user; bool last_page_user;
}; };
struct be_rx_stats {
u32 rx_post_fail;/* number of ethrx buffer alloc failures */
u32 rx_polls; /* number of times NAPI called poll function */
u32 rx_events; /* number of ucast rx completion events */
u32 rx_compl; /* number of rx completion entries processed */
ulong rx_jiffies;
u64 rx_bytes;
u64 rx_bytes_prev;
u64 rx_pkts;
u32 rx_rate;
u32 rx_mcast_pkts;
u32 rxcp_err; /* Num rx completion entries w/ err set. */
ulong rx_fps_jiffies; /* jiffies at last FPS calc */
u32 rx_frags;
u32 prev_rx_frags;
u32 rx_fps; /* Rx frags per second */
};
struct be_rx_obj { struct be_rx_obj {
struct be_adapter *adapter;
struct be_queue_info q; struct be_queue_info q;
struct be_queue_info cq; struct be_queue_info cq;
struct be_rx_page_info page_info_tbl[RX_Q_LEN]; struct be_rx_page_info page_info_tbl[RX_Q_LEN];
struct be_eq_obj rx_eq;
struct be_rx_stats stats;
u8 rss_id;
bool rx_post_starved; /* Zero rx frags have been posted to BE */
u32 cache_line_barrier[16];
}; };
struct be_vf_cfg { struct be_vf_cfg {
...@@ -229,7 +225,6 @@ struct be_vf_cfg { ...@@ -229,7 +225,6 @@ struct be_vf_cfg {
u32 vf_tx_rate; u32 vf_tx_rate;
}; };
#define BE_NUM_MSIX_VECTORS 2 /* 1 each for Tx and Rx */
#define BE_INVALID_PMAC_ID 0xffffffff #define BE_INVALID_PMAC_ID 0xffffffff
struct be_adapter { struct be_adapter {
struct pci_dev *pdev; struct pci_dev *pdev;
...@@ -249,21 +244,21 @@ struct be_adapter { ...@@ -249,21 +244,21 @@ struct be_adapter {
spinlock_t mcc_lock; /* For serializing mcc cmds to BE card */ spinlock_t mcc_lock; /* For serializing mcc cmds to BE card */
spinlock_t mcc_cq_lock; spinlock_t mcc_cq_lock;
struct msix_entry msix_entries[BE_NUM_MSIX_VECTORS]; struct msix_entry msix_entries[BE_MAX_MSIX_VECTORS];
bool msix_enabled; bool msix_enabled;
bool isr_registered; bool isr_registered;
/* TX Rings */ /* TX Rings */
struct be_eq_obj tx_eq; struct be_eq_obj tx_eq;
struct be_tx_obj tx_obj; struct be_tx_obj tx_obj;
struct be_tx_stats tx_stats;
u32 cache_line_break[8]; u32 cache_line_break[8];
/* Rx rings */ /* Rx rings */
struct be_eq_obj rx_eq; struct be_rx_obj rx_obj[MAX_RSS_QS + 1]; /* one default non-rss Q */
struct be_rx_obj rx_obj; u32 num_rx_qs;
u32 big_page_size; /* Compounded page size shared by rx wrbs */ u32 big_page_size; /* Compounded page size shared by rx wrbs */
bool rx_post_starved; /* Zero rx frags have been posted to BE */
struct vlan_group *vlan_grp; struct vlan_group *vlan_grp;
u16 vlans_added; u16 vlans_added;
...@@ -271,7 +266,7 @@ struct be_adapter { ...@@ -271,7 +266,7 @@ struct be_adapter {
u8 vlan_tag[VLAN_GROUP_ARRAY_LEN]; u8 vlan_tag[VLAN_GROUP_ARRAY_LEN];
struct be_dma_mem mc_cmd_mem; struct be_dma_mem mc_cmd_mem;
struct be_stats_obj stats; struct be_dma_mem stats_cmd;
/* Work queue used to perform periodic tasks like getting statistics */ /* Work queue used to perform periodic tasks like getting statistics */
struct delayed_work work; struct delayed_work work;
...@@ -287,6 +282,7 @@ struct be_adapter { ...@@ -287,6 +282,7 @@ struct be_adapter {
bool promiscuous; bool promiscuous;
bool wol; bool wol;
u32 function_mode; u32 function_mode;
u32 function_caps;
u32 rx_fc; /* Rx flow control */ u32 rx_fc; /* Rx flow control */
u32 tx_fc; /* Tx flow control */ u32 tx_fc; /* Tx flow control */
bool ue_detected; bool ue_detected;
...@@ -313,10 +309,20 @@ struct be_adapter { ...@@ -313,10 +309,20 @@ struct be_adapter {
extern const struct ethtool_ops be_ethtool_ops; extern const struct ethtool_ops be_ethtool_ops;
#define drvr_stats(adapter) (&adapter->stats.drvr_stats) #define tx_stats(adapter) (&adapter->tx_stats)
#define rx_stats(rxo) (&rxo->stats)
#define BE_SET_NETDEV_OPS(netdev, ops) (netdev->netdev_ops = ops) #define BE_SET_NETDEV_OPS(netdev, ops) (netdev->netdev_ops = ops)
#define for_all_rx_queues(adapter, rxo, i) \
for (i = 0, rxo = &adapter->rx_obj[i]; i < adapter->num_rx_qs; \
i++, rxo++)
/* Just skip the first default non-rss queue */
#define for_all_rss_queues(adapter, rxo, i) \
for (i = 0, rxo = &adapter->rx_obj[i+1]; i < (adapter->num_rx_qs - 1);\
i++, rxo++)
#define PAGE_SHIFT_4K 12 #define PAGE_SHIFT_4K 12
#define PAGE_SIZE_4K (1 << PAGE_SHIFT_4K) #define PAGE_SIZE_4K (1 << PAGE_SHIFT_4K)
......
...@@ -71,7 +71,7 @@ static int be_mcc_compl_process(struct be_adapter *adapter, ...@@ -71,7 +71,7 @@ static int be_mcc_compl_process(struct be_adapter *adapter,
if (compl_status == MCC_STATUS_SUCCESS) { if (compl_status == MCC_STATUS_SUCCESS) {
if (compl->tag0 == OPCODE_ETH_GET_STATISTICS) { if (compl->tag0 == OPCODE_ETH_GET_STATISTICS) {
struct be_cmd_resp_get_stats *resp = struct be_cmd_resp_get_stats *resp =
adapter->stats.cmd.va; adapter->stats_cmd.va;
be_dws_le_to_cpu(&resp->hw_stats, be_dws_le_to_cpu(&resp->hw_stats,
sizeof(resp->hw_stats)); sizeof(resp->hw_stats));
netdev_stats_update(adapter); netdev_stats_update(adapter);
...@@ -754,7 +754,7 @@ int be_cmd_txq_create(struct be_adapter *adapter, ...@@ -754,7 +754,7 @@ int be_cmd_txq_create(struct be_adapter *adapter,
/* Uses mbox */ /* Uses mbox */
int be_cmd_rxq_create(struct be_adapter *adapter, int be_cmd_rxq_create(struct be_adapter *adapter,
struct be_queue_info *rxq, u16 cq_id, u16 frag_size, struct be_queue_info *rxq, u16 cq_id, u16 frag_size,
u16 max_frame_size, u32 if_id, u32 rss) u16 max_frame_size, u32 if_id, u32 rss, u8 *rss_id)
{ {
struct be_mcc_wrb *wrb; struct be_mcc_wrb *wrb;
struct be_cmd_req_eth_rx_create *req; struct be_cmd_req_eth_rx_create *req;
...@@ -785,6 +785,7 @@ int be_cmd_rxq_create(struct be_adapter *adapter, ...@@ -785,6 +785,7 @@ int be_cmd_rxq_create(struct be_adapter *adapter,
struct be_cmd_resp_eth_rx_create *resp = embedded_payload(wrb); struct be_cmd_resp_eth_rx_create *resp = embedded_payload(wrb);
rxq->id = le16_to_cpu(resp->id); rxq->id = le16_to_cpu(resp->id);
rxq->created = true; rxq->created = true;
*rss_id = resp->rss_id;
} }
spin_unlock(&adapter->mbox_lock); spin_unlock(&adapter->mbox_lock);
...@@ -1259,7 +1260,8 @@ int be_cmd_get_flow_control(struct be_adapter *adapter, u32 *tx_fc, u32 *rx_fc) ...@@ -1259,7 +1260,8 @@ int be_cmd_get_flow_control(struct be_adapter *adapter, u32 *tx_fc, u32 *rx_fc)
} }
/* Uses mbox */ /* Uses mbox */
int be_cmd_query_fw_cfg(struct be_adapter *adapter, u32 *port_num, u32 *mode) int be_cmd_query_fw_cfg(struct be_adapter *adapter, u32 *port_num,
u32 *mode, u32 *caps)
{ {
struct be_mcc_wrb *wrb; struct be_mcc_wrb *wrb;
struct be_cmd_req_query_fw_cfg *req; struct be_cmd_req_query_fw_cfg *req;
...@@ -1281,6 +1283,7 @@ int be_cmd_query_fw_cfg(struct be_adapter *adapter, u32 *port_num, u32 *mode) ...@@ -1281,6 +1283,7 @@ int be_cmd_query_fw_cfg(struct be_adapter *adapter, u32 *port_num, u32 *mode)
struct be_cmd_resp_query_fw_cfg *resp = embedded_payload(wrb); struct be_cmd_resp_query_fw_cfg *resp = embedded_payload(wrb);
*port_num = le32_to_cpu(resp->phys_port); *port_num = le32_to_cpu(resp->phys_port);
*mode = le32_to_cpu(resp->function_mode); *mode = le32_to_cpu(resp->function_mode);
*caps = le32_to_cpu(resp->function_caps);
} }
spin_unlock(&adapter->mbox_lock); spin_unlock(&adapter->mbox_lock);
...@@ -1311,6 +1314,37 @@ int be_cmd_reset_function(struct be_adapter *adapter) ...@@ -1311,6 +1314,37 @@ int be_cmd_reset_function(struct be_adapter *adapter)
return status; return status;
} }
int be_cmd_rss_config(struct be_adapter *adapter, u8 *rsstable, u16 table_size)
{
struct be_mcc_wrb *wrb;
struct be_cmd_req_rss_config *req;
u32 myhash[10];
int status;
spin_lock(&adapter->mbox_lock);
wrb = wrb_from_mbox(adapter);
req = embedded_payload(wrb);
be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0,
OPCODE_ETH_RSS_CONFIG);
be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ETH,
OPCODE_ETH_RSS_CONFIG, sizeof(*req));
req->if_id = cpu_to_le32(adapter->if_handle);
req->enable_rss = cpu_to_le16(RSS_ENABLE_TCP_IPV4 | RSS_ENABLE_IPV4);
req->cpu_table_size_log2 = cpu_to_le16(fls(table_size) - 1);
memcpy(req->cpu_table, rsstable, table_size);
memcpy(req->hash, myhash, sizeof(myhash));
be_dws_cpu_to_le(req->hash, sizeof(req->hash));
status = be_mbox_notify_wait(adapter);
spin_unlock(&adapter->mbox_lock);
return status;
}
/* Uses sync mcc */ /* Uses sync mcc */
int be_cmd_set_beacon_state(struct be_adapter *adapter, u8 port_num, int be_cmd_set_beacon_state(struct be_adapter *adapter, u8 port_num,
u8 bcn, u8 sts, u8 state) u8 bcn, u8 sts, u8 state)
......
...@@ -147,6 +147,7 @@ struct be_mcc_mailbox { ...@@ -147,6 +147,7 @@ struct be_mcc_mailbox {
#define OPCODE_COMMON_READ_TRANSRECV_DATA 73 #define OPCODE_COMMON_READ_TRANSRECV_DATA 73
#define OPCODE_COMMON_GET_PHY_DETAILS 102 #define OPCODE_COMMON_GET_PHY_DETAILS 102
#define OPCODE_ETH_RSS_CONFIG 1
#define OPCODE_ETH_ACPI_CONFIG 2 #define OPCODE_ETH_ACPI_CONFIG 2
#define OPCODE_ETH_PROMISCUOUS 3 #define OPCODE_ETH_PROMISCUOUS 3
#define OPCODE_ETH_GET_STATISTICS 4 #define OPCODE_ETH_GET_STATISTICS 4
...@@ -409,7 +410,7 @@ struct be_cmd_req_eth_rx_create { ...@@ -409,7 +410,7 @@ struct be_cmd_req_eth_rx_create {
struct be_cmd_resp_eth_rx_create { struct be_cmd_resp_eth_rx_create {
struct be_cmd_resp_hdr hdr; struct be_cmd_resp_hdr hdr;
u16 id; u16 id;
u8 cpu_id; u8 rss_id;
u8 rsvd0; u8 rsvd0;
} __packed; } __packed;
...@@ -739,9 +740,10 @@ struct be_cmd_resp_modify_eq_delay { ...@@ -739,9 +740,10 @@ struct be_cmd_resp_modify_eq_delay {
} __packed; } __packed;
/******************** Get FW Config *******************/ /******************** Get FW Config *******************/
#define BE_FUNCTION_CAPS_RSS 0x2
struct be_cmd_req_query_fw_cfg { struct be_cmd_req_query_fw_cfg {
struct be_cmd_req_hdr hdr; struct be_cmd_req_hdr hdr;
u32 rsvd[30]; u32 rsvd[31];
}; };
struct be_cmd_resp_query_fw_cfg { struct be_cmd_resp_query_fw_cfg {
...@@ -751,6 +753,26 @@ struct be_cmd_resp_query_fw_cfg { ...@@ -751,6 +753,26 @@ struct be_cmd_resp_query_fw_cfg {
u32 phys_port; u32 phys_port;
u32 function_mode; u32 function_mode;
u32 rsvd[26]; u32 rsvd[26];
u32 function_caps;
};
/******************** RSS Config *******************/
/* RSS types */
#define RSS_ENABLE_NONE 0x0
#define RSS_ENABLE_IPV4 0x1
#define RSS_ENABLE_TCP_IPV4 0x2
#define RSS_ENABLE_IPV6 0x4
#define RSS_ENABLE_TCP_IPV6 0x8
struct be_cmd_req_rss_config {
struct be_cmd_req_hdr hdr;
u32 if_id;
u16 enable_rss;
u16 cpu_table_size_log2;
u32 hash[10];
u8 cpu_table[128];
u8 flush;
u8 rsvd0[3];
}; };
/******************** Port Beacon ***************************/ /******************** Port Beacon ***************************/
...@@ -937,7 +959,7 @@ extern int be_cmd_txq_create(struct be_adapter *adapter, ...@@ -937,7 +959,7 @@ extern int be_cmd_txq_create(struct be_adapter *adapter,
extern int be_cmd_rxq_create(struct be_adapter *adapter, extern int be_cmd_rxq_create(struct be_adapter *adapter,
struct be_queue_info *rxq, u16 cq_id, struct be_queue_info *rxq, u16 cq_id,
u16 frag_size, u16 max_frame_size, u32 if_id, u16 frag_size, u16 max_frame_size, u32 if_id,
u32 rss); u32 rss, u8 *rss_id);
extern int be_cmd_q_destroy(struct be_adapter *adapter, struct be_queue_info *q, extern int be_cmd_q_destroy(struct be_adapter *adapter, struct be_queue_info *q,
int type); int type);
extern int be_cmd_link_status_query(struct be_adapter *adapter, extern int be_cmd_link_status_query(struct be_adapter *adapter,
...@@ -960,8 +982,10 @@ extern int be_cmd_set_flow_control(struct be_adapter *adapter, ...@@ -960,8 +982,10 @@ extern int be_cmd_set_flow_control(struct be_adapter *adapter,
extern int be_cmd_get_flow_control(struct be_adapter *adapter, extern int be_cmd_get_flow_control(struct be_adapter *adapter,
u32 *tx_fc, u32 *rx_fc); u32 *tx_fc, u32 *rx_fc);
extern int be_cmd_query_fw_cfg(struct be_adapter *adapter, extern int be_cmd_query_fw_cfg(struct be_adapter *adapter,
u32 *port_num, u32 *cap); u32 *port_num, u32 *function_mode, u32 *function_caps);
extern int be_cmd_reset_function(struct be_adapter *adapter); extern int be_cmd_reset_function(struct be_adapter *adapter);
extern int be_cmd_rss_config(struct be_adapter *adapter, u8 *rsstable,
u16 table_size);
extern int be_process_mcc(struct be_adapter *adapter, int *status); extern int be_process_mcc(struct be_adapter *adapter, int *status);
extern int be_cmd_set_beacon_state(struct be_adapter *adapter, extern int be_cmd_set_beacon_state(struct be_adapter *adapter,
u8 port_num, u8 beacon, u8 status, u8 state); u8 port_num, u8 beacon, u8 status, u8 state);
......
...@@ -26,14 +26,16 @@ struct be_ethtool_stat { ...@@ -26,14 +26,16 @@ struct be_ethtool_stat {
int offset; int offset;
}; };
enum {NETSTAT, PORTSTAT, MISCSTAT, DRVSTAT, ERXSTAT}; enum {NETSTAT, PORTSTAT, MISCSTAT, DRVSTAT_TX, DRVSTAT_RX, ERXSTAT};
#define FIELDINFO(_struct, field) FIELD_SIZEOF(_struct, field), \ #define FIELDINFO(_struct, field) FIELD_SIZEOF(_struct, field), \
offsetof(_struct, field) offsetof(_struct, field)
#define NETSTAT_INFO(field) #field, NETSTAT,\ #define NETSTAT_INFO(field) #field, NETSTAT,\
FIELDINFO(struct net_device_stats,\ FIELDINFO(struct net_device_stats,\
field) field)
#define DRVSTAT_INFO(field) #field, DRVSTAT,\ #define DRVSTAT_TX_INFO(field) #field, DRVSTAT_TX,\
FIELDINFO(struct be_drvr_stats, field) FIELDINFO(struct be_tx_stats, field)
#define DRVSTAT_RX_INFO(field) #field, DRVSTAT_RX,\
FIELDINFO(struct be_rx_stats, field)
#define MISCSTAT_INFO(field) #field, MISCSTAT,\ #define MISCSTAT_INFO(field) #field, MISCSTAT,\
FIELDINFO(struct be_rxf_stats, field) FIELDINFO(struct be_rxf_stats, field)
#define PORTSTAT_INFO(field) #field, PORTSTAT,\ #define PORTSTAT_INFO(field) #field, PORTSTAT,\
...@@ -51,21 +53,12 @@ static const struct be_ethtool_stat et_stats[] = { ...@@ -51,21 +53,12 @@ static const struct be_ethtool_stat et_stats[] = {
{NETSTAT_INFO(tx_errors)}, {NETSTAT_INFO(tx_errors)},
{NETSTAT_INFO(rx_dropped)}, {NETSTAT_INFO(rx_dropped)},
{NETSTAT_INFO(tx_dropped)}, {NETSTAT_INFO(tx_dropped)},
{DRVSTAT_INFO(be_tx_reqs)}, {DRVSTAT_TX_INFO(be_tx_rate)},
{DRVSTAT_INFO(be_tx_stops)}, {DRVSTAT_TX_INFO(be_tx_reqs)},
{DRVSTAT_INFO(be_fwd_reqs)}, {DRVSTAT_TX_INFO(be_tx_wrbs)},
{DRVSTAT_INFO(be_tx_wrbs)}, {DRVSTAT_TX_INFO(be_tx_stops)},
{DRVSTAT_INFO(be_rx_polls)}, {DRVSTAT_TX_INFO(be_tx_events)},
{DRVSTAT_INFO(be_tx_events)}, {DRVSTAT_TX_INFO(be_tx_compl)},
{DRVSTAT_INFO(be_rx_events)},
{DRVSTAT_INFO(be_tx_compl)},
{DRVSTAT_INFO(be_rx_compl)},
{DRVSTAT_INFO(be_rx_mcast_pkt)},
{DRVSTAT_INFO(be_ethrx_post_fail)},
{DRVSTAT_INFO(be_802_3_dropped_frames)},
{DRVSTAT_INFO(be_802_3_malformed_frames)},
{DRVSTAT_INFO(be_tx_rate)},
{DRVSTAT_INFO(be_rx_rate)},
{PORTSTAT_INFO(rx_unicast_frames)}, {PORTSTAT_INFO(rx_unicast_frames)},
{PORTSTAT_INFO(rx_multicast_frames)}, {PORTSTAT_INFO(rx_multicast_frames)},
{PORTSTAT_INFO(rx_broadcast_frames)}, {PORTSTAT_INFO(rx_broadcast_frames)},
...@@ -106,11 +99,24 @@ static const struct be_ethtool_stat et_stats[] = { ...@@ -106,11 +99,24 @@ static const struct be_ethtool_stat et_stats[] = {
{MISCSTAT_INFO(rx_drops_too_many_frags)}, {MISCSTAT_INFO(rx_drops_too_many_frags)},
{MISCSTAT_INFO(rx_drops_invalid_ring)}, {MISCSTAT_INFO(rx_drops_invalid_ring)},
{MISCSTAT_INFO(forwarded_packets)}, {MISCSTAT_INFO(forwarded_packets)},
{MISCSTAT_INFO(rx_drops_mtu)}, {MISCSTAT_INFO(rx_drops_mtu)}
{ERXSTAT_INFO(rx_drops_no_fragments)},
}; };
#define ETHTOOL_STATS_NUM ARRAY_SIZE(et_stats) #define ETHTOOL_STATS_NUM ARRAY_SIZE(et_stats)
/* Stats related to multi RX queues */
static const struct be_ethtool_stat et_rx_stats[] = {
{DRVSTAT_RX_INFO(rx_bytes)},
{DRVSTAT_RX_INFO(rx_pkts)},
{DRVSTAT_RX_INFO(rx_rate)},
{DRVSTAT_RX_INFO(rx_polls)},
{DRVSTAT_RX_INFO(rx_events)},
{DRVSTAT_RX_INFO(rx_compl)},
{DRVSTAT_RX_INFO(rx_mcast_pkts)},
{DRVSTAT_RX_INFO(rx_post_fail)},
{ERXSTAT_INFO(rx_drops_no_fragments)}
};
#define ETHTOOL_RXSTATS_NUM (ARRAY_SIZE(et_rx_stats))
static const char et_self_tests[][ETH_GSTRING_LEN] = { static const char et_self_tests[][ETH_GSTRING_LEN] = {
"MAC Loopback test", "MAC Loopback test",
"PHY Loopback test", "PHY Loopback test",
...@@ -143,7 +149,7 @@ static int ...@@ -143,7 +149,7 @@ static int
be_get_coalesce(struct net_device *netdev, struct ethtool_coalesce *coalesce) be_get_coalesce(struct net_device *netdev, struct ethtool_coalesce *coalesce)
{ {
struct be_adapter *adapter = netdev_priv(netdev); struct be_adapter *adapter = netdev_priv(netdev);
struct be_eq_obj *rx_eq = &adapter->rx_eq; struct be_eq_obj *rx_eq = &adapter->rx_obj[0].rx_eq;
struct be_eq_obj *tx_eq = &adapter->tx_eq; struct be_eq_obj *tx_eq = &adapter->tx_eq;
coalesce->rx_coalesce_usecs = rx_eq->cur_eqd; coalesce->rx_coalesce_usecs = rx_eq->cur_eqd;
...@@ -167,25 +173,49 @@ static int ...@@ -167,25 +173,49 @@ static int
be_set_coalesce(struct net_device *netdev, struct ethtool_coalesce *coalesce) be_set_coalesce(struct net_device *netdev, struct ethtool_coalesce *coalesce)
{ {
struct be_adapter *adapter = netdev_priv(netdev); struct be_adapter *adapter = netdev_priv(netdev);
struct be_eq_obj *rx_eq = &adapter->rx_eq; struct be_rx_obj *rxo;
struct be_eq_obj *rx_eq;
struct be_eq_obj *tx_eq = &adapter->tx_eq; struct be_eq_obj *tx_eq = &adapter->tx_eq;
u32 tx_max, tx_min, tx_cur; u32 tx_max, tx_min, tx_cur;
u32 rx_max, rx_min, rx_cur; u32 rx_max, rx_min, rx_cur;
int status = 0; int status = 0, i;
if (coalesce->use_adaptive_tx_coalesce == 1) if (coalesce->use_adaptive_tx_coalesce == 1)
return -EINVAL; return -EINVAL;
/* if AIC is being turned on now, start with an EQD of 0 */ for_all_rx_queues(adapter, rxo, i) {
if (rx_eq->enable_aic == 0 && rx_eq = &rxo->rx_eq;
coalesce->use_adaptive_rx_coalesce == 1) {
rx_eq->cur_eqd = 0; if (!rx_eq->enable_aic && coalesce->use_adaptive_rx_coalesce)
rx_eq->cur_eqd = 0;
rx_eq->enable_aic = coalesce->use_adaptive_rx_coalesce;
rx_max = coalesce->rx_coalesce_usecs_high;
rx_min = coalesce->rx_coalesce_usecs_low;
rx_cur = coalesce->rx_coalesce_usecs;
if (rx_eq->enable_aic) {
if (rx_max > BE_MAX_EQD)
rx_max = BE_MAX_EQD;
if (rx_min > rx_max)
rx_min = rx_max;
rx_eq->max_eqd = rx_max;
rx_eq->min_eqd = rx_min;
if (rx_eq->cur_eqd > rx_max)
rx_eq->cur_eqd = rx_max;
if (rx_eq->cur_eqd < rx_min)
rx_eq->cur_eqd = rx_min;
} else {
if (rx_cur > BE_MAX_EQD)
rx_cur = BE_MAX_EQD;
if (rx_eq->cur_eqd != rx_cur) {
status = be_cmd_modify_eqd(adapter, rx_eq->q.id,
rx_cur);
if (!status)
rx_eq->cur_eqd = rx_cur;
}
}
} }
rx_eq->enable_aic = coalesce->use_adaptive_rx_coalesce;
rx_max = coalesce->rx_coalesce_usecs_high;
rx_min = coalesce->rx_coalesce_usecs_low;
rx_cur = coalesce->rx_coalesce_usecs;
tx_max = coalesce->tx_coalesce_usecs_high; tx_max = coalesce->tx_coalesce_usecs_high;
tx_min = coalesce->tx_coalesce_usecs_low; tx_min = coalesce->tx_coalesce_usecs_low;
...@@ -199,27 +229,6 @@ be_set_coalesce(struct net_device *netdev, struct ethtool_coalesce *coalesce) ...@@ -199,27 +229,6 @@ be_set_coalesce(struct net_device *netdev, struct ethtool_coalesce *coalesce)
tx_eq->cur_eqd = tx_cur; tx_eq->cur_eqd = tx_cur;
} }
if (rx_eq->enable_aic) {
if (rx_max > BE_MAX_EQD)
rx_max = BE_MAX_EQD;
if (rx_min > rx_max)
rx_min = rx_max;
rx_eq->max_eqd = rx_max;
rx_eq->min_eqd = rx_min;
if (rx_eq->cur_eqd > rx_max)
rx_eq->cur_eqd = rx_max;
if (rx_eq->cur_eqd < rx_min)
rx_eq->cur_eqd = rx_min;
} else {
if (rx_cur > BE_MAX_EQD)
rx_cur = BE_MAX_EQD;
if (rx_eq->cur_eqd != rx_cur) {
status = be_cmd_modify_eqd(adapter, rx_eq->q.id,
rx_cur);
if (!status)
rx_eq->cur_eqd = rx_cur;
}
}
return 0; return 0;
} }
...@@ -247,32 +256,25 @@ be_get_ethtool_stats(struct net_device *netdev, ...@@ -247,32 +256,25 @@ be_get_ethtool_stats(struct net_device *netdev,
struct ethtool_stats *stats, uint64_t *data) struct ethtool_stats *stats, uint64_t *data)
{ {
struct be_adapter *adapter = netdev_priv(netdev); struct be_adapter *adapter = netdev_priv(netdev);
struct be_drvr_stats *drvr_stats = &adapter->stats.drvr_stats; struct be_hw_stats *hw_stats = hw_stats_from_cmd(adapter->stats_cmd.va);
struct be_hw_stats *hw_stats = hw_stats_from_cmd(adapter->stats.cmd.va);
struct be_rxf_stats *rxf_stats = &hw_stats->rxf;
struct be_port_rxf_stats *port_stats =
&rxf_stats->port[adapter->port_num];
struct net_device_stats *net_stats = &netdev->stats;
struct be_erx_stats *erx_stats = &hw_stats->erx; struct be_erx_stats *erx_stats = &hw_stats->erx;
struct be_rx_obj *rxo;
void *p = NULL; void *p = NULL;
int i; int i, j;
for (i = 0; i < ETHTOOL_STATS_NUM; i++) { for (i = 0; i < ETHTOOL_STATS_NUM; i++) {
switch (et_stats[i].type) { switch (et_stats[i].type) {
case NETSTAT: case NETSTAT:
p = net_stats; p = &netdev->stats;
break; break;
case DRVSTAT: case DRVSTAT_TX:
p = drvr_stats; p = &adapter->tx_stats;
break; break;
case PORTSTAT: case PORTSTAT:
p = port_stats; p = &hw_stats->rxf.port[adapter->port_num];
break; break;
case MISCSTAT: case MISCSTAT:
p = rxf_stats; p = &hw_stats->rxf;
break;
case ERXSTAT: /* Currently only one ERX stat is provided */
p = (u32 *)erx_stats + adapter->rx_obj.q.id;
break; break;
} }
...@@ -280,19 +282,44 @@ be_get_ethtool_stats(struct net_device *netdev, ...@@ -280,19 +282,44 @@ be_get_ethtool_stats(struct net_device *netdev,
data[i] = (et_stats[i].size == sizeof(u64)) ? data[i] = (et_stats[i].size == sizeof(u64)) ?
*(u64 *)p: *(u32 *)p; *(u64 *)p: *(u32 *)p;
} }
for_all_rx_queues(adapter, rxo, j) {
for (i = 0; i < ETHTOOL_RXSTATS_NUM; i++) {
switch (et_rx_stats[i].type) {
case DRVSTAT_RX:
p = (u8 *)&rxo->stats + et_rx_stats[i].offset;
break;
case ERXSTAT:
p = (u32 *)erx_stats + rxo->q.id;
break;
}
data[ETHTOOL_STATS_NUM + j * ETHTOOL_RXSTATS_NUM + i] =
(et_rx_stats[i].size == sizeof(u64)) ?
*(u64 *)p: *(u32 *)p;
}
}
} }
static void static void
be_get_stat_strings(struct net_device *netdev, uint32_t stringset, be_get_stat_strings(struct net_device *netdev, uint32_t stringset,
uint8_t *data) uint8_t *data)
{ {
int i; struct be_adapter *adapter = netdev_priv(netdev);
int i, j;
switch (stringset) { switch (stringset) {
case ETH_SS_STATS: case ETH_SS_STATS:
for (i = 0; i < ETHTOOL_STATS_NUM; i++) { for (i = 0; i < ETHTOOL_STATS_NUM; i++) {
memcpy(data, et_stats[i].desc, ETH_GSTRING_LEN); memcpy(data, et_stats[i].desc, ETH_GSTRING_LEN);
data += ETH_GSTRING_LEN; data += ETH_GSTRING_LEN;
} }
for (i = 0; i < adapter->num_rx_qs; i++) {
for (j = 0; j < ETHTOOL_RXSTATS_NUM; j++) {
sprintf(data, "rxq%d: %s", i,
et_rx_stats[j].desc);
data += ETH_GSTRING_LEN;
}
}
break; break;
case ETH_SS_TEST: case ETH_SS_TEST:
for (i = 0; i < ETHTOOL_TESTS_NUM; i++) { for (i = 0; i < ETHTOOL_TESTS_NUM; i++) {
...@@ -305,11 +332,14 @@ be_get_stat_strings(struct net_device *netdev, uint32_t stringset, ...@@ -305,11 +332,14 @@ be_get_stat_strings(struct net_device *netdev, uint32_t stringset,
static int be_get_sset_count(struct net_device *netdev, int stringset) static int be_get_sset_count(struct net_device *netdev, int stringset)
{ {
struct be_adapter *adapter = netdev_priv(netdev);
switch (stringset) { switch (stringset) {
case ETH_SS_TEST: case ETH_SS_TEST:
return ETHTOOL_TESTS_NUM; return ETHTOOL_TESTS_NUM;
case ETH_SS_STATS: case ETH_SS_STATS:
return ETHTOOL_STATS_NUM; return ETHTOOL_STATS_NUM +
adapter->num_rx_qs * ETHTOOL_RXSTATS_NUM;
default: default:
return -EINVAL; return -EINVAL;
} }
...@@ -424,10 +454,10 @@ be_get_ringparam(struct net_device *netdev, struct ethtool_ringparam *ring) ...@@ -424,10 +454,10 @@ be_get_ringparam(struct net_device *netdev, struct ethtool_ringparam *ring)
{ {
struct be_adapter *adapter = netdev_priv(netdev); struct be_adapter *adapter = netdev_priv(netdev);
ring->rx_max_pending = adapter->rx_obj.q.len; ring->rx_max_pending = adapter->rx_obj[0].q.len;
ring->tx_max_pending = adapter->tx_obj.q.len; ring->tx_max_pending = adapter->tx_obj.q.len;
ring->rx_pending = atomic_read(&adapter->rx_obj.q.used); ring->rx_pending = atomic_read(&adapter->rx_obj[0].q.used);
ring->tx_pending = atomic_read(&adapter->tx_obj.q.used); ring->tx_pending = atomic_read(&adapter->tx_obj.q.used);
} }
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment