Commit 3c9e154d authored by David S. Miller's avatar David S. Miller

Merge branch 'Enhance-current-features-in-ena-driver'

Sameeh Jubran says:

====================
Enhance current features in ena driver

This series adds the following:
* Exposes new device stats using ethtool.
* Adds and exposes the stats of xdp TX queues through ethtool.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents e5484658 4cd28b21
...@@ -117,6 +117,8 @@ enum ena_admin_completion_policy_type { ...@@ -117,6 +117,8 @@ enum ena_admin_completion_policy_type {
enum ena_admin_get_stats_type { enum ena_admin_get_stats_type {
ENA_ADMIN_GET_STATS_TYPE_BASIC = 0, ENA_ADMIN_GET_STATS_TYPE_BASIC = 0,
ENA_ADMIN_GET_STATS_TYPE_EXTENDED = 1, ENA_ADMIN_GET_STATS_TYPE_EXTENDED = 1,
/* extra HW stats for specific network interface */
ENA_ADMIN_GET_STATS_TYPE_ENI = 2,
}; };
enum ena_admin_get_stats_scope { enum ena_admin_get_stats_scope {
...@@ -410,10 +412,43 @@ struct ena_admin_basic_stats { ...@@ -410,10 +412,43 @@ struct ena_admin_basic_stats {
u32 tx_drops_high; u32 tx_drops_high;
}; };
/* ENI Statistics Command. */
struct ena_admin_eni_stats {
/* The number of packets shaped due to inbound aggregate BW
* allowance being exceeded
*/
u64 bw_in_allowance_exceeded;
/* The number of packets shaped due to outbound aggregate BW
* allowance being exceeded
*/
u64 bw_out_allowance_exceeded;
/* The number of packets shaped due to PPS allowance being exceeded */
u64 pps_allowance_exceeded;
/* The number of packets shaped due to connection tracking
* allowance being exceeded and leading to failure in establishment
* of new connections
*/
u64 conntrack_allowance_exceeded;
/* The number of packets shaped due to linklocal packet rate
* allowance being exceeded
*/
u64 linklocal_allowance_exceeded;
};
struct ena_admin_acq_get_stats_resp { struct ena_admin_acq_get_stats_resp {
struct ena_admin_acq_common_desc acq_common_desc; struct ena_admin_acq_common_desc acq_common_desc;
struct ena_admin_basic_stats basic_stats; union {
u64 raw[7];
struct ena_admin_basic_stats basic_stats;
struct ena_admin_eni_stats eni_stats;
} u;
}; };
struct ena_admin_get_set_feature_common_desc { struct ena_admin_get_set_feature_common_desc {
......
...@@ -2167,6 +2167,21 @@ static int ena_get_dev_stats(struct ena_com_dev *ena_dev, ...@@ -2167,6 +2167,21 @@ static int ena_get_dev_stats(struct ena_com_dev *ena_dev,
return ret; return ret;
} }
int ena_com_get_eni_stats(struct ena_com_dev *ena_dev,
struct ena_admin_eni_stats *stats)
{
struct ena_com_stats_ctx ctx;
int ret;
memset(&ctx, 0x0, sizeof(ctx));
ret = ena_get_dev_stats(ena_dev, &ctx, ENA_ADMIN_GET_STATS_TYPE_ENI);
if (likely(ret == 0))
memcpy(stats, &ctx.get_resp.u.eni_stats,
sizeof(ctx.get_resp.u.eni_stats));
return ret;
}
int ena_com_get_dev_basic_stats(struct ena_com_dev *ena_dev, int ena_com_get_dev_basic_stats(struct ena_com_dev *ena_dev,
struct ena_admin_basic_stats *stats) struct ena_admin_basic_stats *stats)
{ {
...@@ -2176,8 +2191,8 @@ int ena_com_get_dev_basic_stats(struct ena_com_dev *ena_dev, ...@@ -2176,8 +2191,8 @@ int ena_com_get_dev_basic_stats(struct ena_com_dev *ena_dev,
memset(&ctx, 0x0, sizeof(ctx)); memset(&ctx, 0x0, sizeof(ctx));
ret = ena_get_dev_stats(ena_dev, &ctx, ENA_ADMIN_GET_STATS_TYPE_BASIC); ret = ena_get_dev_stats(ena_dev, &ctx, ENA_ADMIN_GET_STATS_TYPE_BASIC);
if (likely(ret == 0)) if (likely(ret == 0))
memcpy(stats, &ctx.get_resp.basic_stats, memcpy(stats, &ctx.get_resp.u.basic_stats,
sizeof(ctx.get_resp.basic_stats)); sizeof(ctx.get_resp.u.basic_stats));
return ret; return ret;
} }
......
...@@ -616,6 +616,15 @@ int ena_com_get_dev_attr_feat(struct ena_com_dev *ena_dev, ...@@ -616,6 +616,15 @@ int ena_com_get_dev_attr_feat(struct ena_com_dev *ena_dev,
int ena_com_get_dev_basic_stats(struct ena_com_dev *ena_dev, int ena_com_get_dev_basic_stats(struct ena_com_dev *ena_dev,
struct ena_admin_basic_stats *stats); struct ena_admin_basic_stats *stats);
/* ena_com_get_eni_stats - Get extended network interface statistics
* @ena_dev: ENA communication layer struct
* @stats: stats return value
*
* @return: 0 on Success and negative value otherwise.
*/
int ena_com_get_eni_stats(struct ena_com_dev *ena_dev,
struct ena_admin_eni_stats *stats);
/* ena_com_set_dev_mtu - Configure the device mtu. /* ena_com_set_dev_mtu - Configure the device mtu.
* @ena_dev: ENA communication layer struct * @ena_dev: ENA communication layer struct
* @mtu: mtu value * @mtu: mtu value
......
...@@ -365,6 +365,7 @@ static int ena_xdp_execute(struct ena_ring *rx_ring, ...@@ -365,6 +365,7 @@ static int ena_xdp_execute(struct ena_ring *rx_ring,
{ {
struct bpf_prog *xdp_prog; struct bpf_prog *xdp_prog;
u32 verdict = XDP_PASS; u32 verdict = XDP_PASS;
u64 *xdp_stat;
rcu_read_lock(); rcu_read_lock();
xdp_prog = READ_ONCE(rx_ring->xdp_bpf_prog); xdp_prog = READ_ONCE(rx_ring->xdp_bpf_prog);
...@@ -374,17 +375,31 @@ static int ena_xdp_execute(struct ena_ring *rx_ring, ...@@ -374,17 +375,31 @@ static int ena_xdp_execute(struct ena_ring *rx_ring,
verdict = bpf_prog_run_xdp(xdp_prog, xdp); verdict = bpf_prog_run_xdp(xdp_prog, xdp);
if (verdict == XDP_TX) if (verdict == XDP_TX) {
ena_xdp_xmit_buff(rx_ring->netdev, ena_xdp_xmit_buff(rx_ring->netdev,
xdp, xdp,
rx_ring->qid + rx_ring->adapter->num_io_queues, rx_ring->qid + rx_ring->adapter->num_io_queues,
rx_info); rx_info);
else if (unlikely(verdict == XDP_ABORTED))
xdp_stat = &rx_ring->rx_stats.xdp_tx;
} else if (unlikely(verdict == XDP_ABORTED)) {
trace_xdp_exception(rx_ring->netdev, xdp_prog, verdict); trace_xdp_exception(rx_ring->netdev, xdp_prog, verdict);
else if (unlikely(verdict > XDP_TX)) xdp_stat = &rx_ring->rx_stats.xdp_aborted;
} else if (unlikely(verdict == XDP_DROP)) {
xdp_stat = &rx_ring->rx_stats.xdp_drop;
} else if (unlikely(verdict == XDP_PASS)) {
xdp_stat = &rx_ring->rx_stats.xdp_pass;
} else {
bpf_warn_invalid_xdp_action(verdict); bpf_warn_invalid_xdp_action(verdict);
xdp_stat = &rx_ring->rx_stats.xdp_invalid;
}
u64_stats_update_begin(&rx_ring->syncp);
(*xdp_stat)++;
u64_stats_update_end(&rx_ring->syncp);
out: out:
rcu_read_unlock(); rcu_read_unlock();
return verdict; return verdict;
} }
...@@ -3178,6 +3193,19 @@ static void ena_config_debug_area(struct ena_adapter *adapter) ...@@ -3178,6 +3193,19 @@ static void ena_config_debug_area(struct ena_adapter *adapter)
ena_com_delete_debug_area(adapter->ena_dev); ena_com_delete_debug_area(adapter->ena_dev);
} }
int ena_update_hw_stats(struct ena_adapter *adapter)
{
int rc = 0;
rc = ena_com_get_eni_stats(adapter->ena_dev, &adapter->eni_stats);
if (rc) {
dev_info_once(&adapter->pdev->dev, "Failed to get ENI stats\n");
return rc;
}
return 0;
}
static void ena_get_stats64(struct net_device *netdev, static void ena_get_stats64(struct net_device *netdev,
struct rtnl_link_stats64 *stats) struct rtnl_link_stats64 *stats)
{ {
...@@ -4296,6 +4324,11 @@ static int ena_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -4296,6 +4324,11 @@ static int ena_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
ena_config_debug_area(adapter); ena_config_debug_area(adapter);
if (!ena_update_hw_stats(adapter))
adapter->eni_stats_supported = true;
else
adapter->eni_stats_supported = false;
memcpy(adapter->netdev->perm_addr, adapter->mac_addr, netdev->addr_len); memcpy(adapter->netdev->perm_addr, adapter->mac_addr, netdev->addr_len);
netif_carrier_off(netdev); netif_carrier_off(netdev);
......
...@@ -261,6 +261,11 @@ struct ena_stats_rx { ...@@ -261,6 +261,11 @@ struct ena_stats_rx {
u64 bad_req_id; u64 bad_req_id;
u64 empty_rx_ring; u64 empty_rx_ring;
u64 csum_unchecked; u64 csum_unchecked;
u64 xdp_aborted;
u64 xdp_drop;
u64 xdp_pass;
u64 xdp_tx;
u64 xdp_invalid;
}; };
struct ena_ring { struct ena_ring {
...@@ -405,6 +410,8 @@ struct ena_adapter { ...@@ -405,6 +410,8 @@ struct ena_adapter {
struct u64_stats_sync syncp; struct u64_stats_sync syncp;
struct ena_stats_dev dev_stats; struct ena_stats_dev dev_stats;
struct ena_admin_eni_stats eni_stats;
bool eni_stats_supported;
/* last queue index that was checked for uncompleted tx packets */ /* last queue index that was checked for uncompleted tx packets */
u32 last_monitored_tx_qid; u32 last_monitored_tx_qid;
...@@ -422,6 +429,8 @@ void ena_dump_stats_to_dmesg(struct ena_adapter *adapter); ...@@ -422,6 +429,8 @@ void ena_dump_stats_to_dmesg(struct ena_adapter *adapter);
void ena_dump_stats_to_buf(struct ena_adapter *adapter, u8 *buf); void ena_dump_stats_to_buf(struct ena_adapter *adapter, u8 *buf);
int ena_update_hw_stats(struct ena_adapter *adapter);
int ena_update_queue_sizes(struct ena_adapter *adapter, int ena_update_queue_sizes(struct ena_adapter *adapter,
u32 new_tx_size, u32 new_tx_size,
u32 new_rx_size); u32 new_rx_size);
......
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