Skip to content

Commit 82192cb

Browse files
committed
Merge branch 'ena-capabilities-field-and-cosmetic-changes'
Arthur Kiyanovski says: ==================== ENA: capabilities field and cosmetic changes Add a new capabilities bitmask field to get indication of capabilities supported by the device. Use the capabilities field to query the device for ENI stats support. Other patches are cosmetic changes like fixing readme mistakes, removing unused variables etc... ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents bf44077 + 9fe890c commit 82192cb

File tree

7 files changed

+95
-102
lines changed

7 files changed

+95
-102
lines changed

Documentation/networking/device_drivers/ethernet/amazon/ena.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ The ENA driver supports two Queue Operation modes for Tx SQs:
135135

136136
- **Low Latency Queue (LLQ) mode or "push-mode":**
137137
In this mode the driver pushes the transmit descriptors and the
138-
first 128 bytes of the packet directly to the ENA device memory
138+
first 96 bytes of the packet directly to the ENA device memory
139139
space. The rest of the packet payload is fetched by the
140140
device. For this operation mode, the driver uses a dedicated PCI
141141
device memory BAR, which is mapped with write-combine capability.

drivers/net/ethernet/amazon/ena/ena_admin_defs.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ enum ena_admin_aq_feature_id {
4848
ENA_ADMIN_FEATURES_OPCODE_NUM = 32,
4949
};
5050

51+
/* device capabilities */
52+
enum ena_admin_aq_caps_id {
53+
ENA_ADMIN_ENI_STATS = 0,
54+
};
55+
5156
enum ena_admin_placement_policy_type {
5257
/* descriptors and headers are in host memory */
5358
ENA_ADMIN_PLACEMENT_POLICY_HOST = 1,
@@ -455,7 +460,10 @@ struct ena_admin_device_attr_feature_desc {
455460
*/
456461
u32 supported_features;
457462

458-
u32 reserved3;
463+
/* bitmap of ena_admin_aq_caps_id, which represents device
464+
* capabilities.
465+
*/
466+
u32 capabilities;
459467

460468
/* Indicates how many bits are used physical address access. */
461469
u32 phys_addr_width;

drivers/net/ethernet/amazon/ena/ena_com.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1971,6 +1971,7 @@ int ena_com_get_dev_attr_feat(struct ena_com_dev *ena_dev,
19711971
sizeof(get_resp.u.dev_attr));
19721972

19731973
ena_dev->supported_features = get_resp.u.dev_attr.supported_features;
1974+
ena_dev->capabilities = get_resp.u.dev_attr.capabilities;
19741975

19751976
if (ena_dev->supported_features & BIT(ENA_ADMIN_MAX_QUEUES_EXT)) {
19761977
rc = ena_com_get_feature(ena_dev, &get_resp,
@@ -2223,6 +2224,13 @@ int ena_com_get_eni_stats(struct ena_com_dev *ena_dev,
22232224
struct ena_com_stats_ctx ctx;
22242225
int ret;
22252226

2227+
if (!ena_com_get_cap(ena_dev, ENA_ADMIN_ENI_STATS)) {
2228+
netdev_err(ena_dev->net_device,
2229+
"Capability %d isn't supported\n",
2230+
ENA_ADMIN_ENI_STATS);
2231+
return -EOPNOTSUPP;
2232+
}
2233+
22262234
memset(&ctx, 0x0, sizeof(ctx));
22272235
ret = ena_get_dev_stats(ena_dev, &ctx, ENA_ADMIN_GET_STATS_TYPE_ENI);
22282236
if (likely(ret == 0))

drivers/net/ethernet/amazon/ena/ena_com.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ struct ena_com_dev {
314314

315315
struct ena_rss rss;
316316
u32 supported_features;
317+
u32 capabilities;
317318
u32 dma_addr_bits;
318319

319320
struct ena_host_attribute host_attr;
@@ -967,6 +968,18 @@ static inline void ena_com_disable_adaptive_moderation(struct ena_com_dev *ena_d
967968
ena_dev->adaptive_coalescing = false;
968969
}
969970

971+
/* ena_com_get_cap - query whether device supports a capability.
972+
* @ena_dev: ENA communication layer struct
973+
* @cap_id: enum value representing the capability
974+
*
975+
* @return - true if capability is supported or false otherwise
976+
*/
977+
static inline bool ena_com_get_cap(struct ena_com_dev *ena_dev,
978+
enum ena_admin_aq_caps_id cap_id)
979+
{
980+
return !!(ena_dev->capabilities & BIT(cap_id));
981+
}
982+
970983
/* ena_com_update_intr_reg - Prepare interrupt register
971984
* @intr_reg: interrupt register to update.
972985
* @rx_delay_interval: Rx interval in usecs

drivers/net/ethernet/amazon/ena/ena_ethtool.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ static const struct ena_stats ena_stats_rx_strings[] = {
8282
ENA_STAT_RX_ENTRY(rx_copybreak_pkt),
8383
ENA_STAT_RX_ENTRY(csum_good),
8484
ENA_STAT_RX_ENTRY(refil_partial),
85-
ENA_STAT_RX_ENTRY(bad_csum),
85+
ENA_STAT_RX_ENTRY(csum_bad),
8686
ENA_STAT_RX_ENTRY(page_alloc_fail),
8787
ENA_STAT_RX_ENTRY(skb_alloc_fail),
8888
ENA_STAT_RX_ENTRY(dma_mapping_err),
@@ -110,8 +110,7 @@ static const struct ena_stats ena_stats_ena_com_strings[] = {
110110
#define ENA_STATS_ARRAY_TX ARRAY_SIZE(ena_stats_tx_strings)
111111
#define ENA_STATS_ARRAY_RX ARRAY_SIZE(ena_stats_rx_strings)
112112
#define ENA_STATS_ARRAY_ENA_COM ARRAY_SIZE(ena_stats_ena_com_strings)
113-
#define ENA_STATS_ARRAY_ENI(adapter) \
114-
(ARRAY_SIZE(ena_stats_eni_strings) * (adapter)->eni_stats_supported)
113+
#define ENA_STATS_ARRAY_ENI(adapter) ARRAY_SIZE(ena_stats_eni_strings)
115114

116115
static void ena_safe_update_stat(u64 *src, u64 *dst,
117116
struct u64_stats_sync *syncp)
@@ -213,8 +212,9 @@ static void ena_get_ethtool_stats(struct net_device *netdev,
213212
u64 *data)
214213
{
215214
struct ena_adapter *adapter = netdev_priv(netdev);
215+
struct ena_com_dev *dev = adapter->ena_dev;
216216

217-
ena_get_stats(adapter, data, adapter->eni_stats_supported);
217+
ena_get_stats(adapter, data, ena_com_get_cap(dev, ENA_ADMIN_ENI_STATS));
218218
}
219219

220220
static int ena_get_sw_stats_count(struct ena_adapter *adapter)
@@ -226,7 +226,9 @@ static int ena_get_sw_stats_count(struct ena_adapter *adapter)
226226

227227
static int ena_get_hw_stats_count(struct ena_adapter *adapter)
228228
{
229-
return ENA_STATS_ARRAY_ENI(adapter);
229+
bool supported = ena_com_get_cap(adapter->ena_dev, ENA_ADMIN_ENI_STATS);
230+
231+
return ENA_STATS_ARRAY_ENI(adapter) * supported;
230232
}
231233

232234
int ena_get_sset_count(struct net_device *netdev, int sset)
@@ -316,10 +318,11 @@ static void ena_get_ethtool_strings(struct net_device *netdev,
316318
u8 *data)
317319
{
318320
struct ena_adapter *adapter = netdev_priv(netdev);
321+
struct ena_com_dev *dev = adapter->ena_dev;
319322

320323
switch (sset) {
321324
case ETH_SS_STATS:
322-
ena_get_strings(adapter, data, adapter->eni_stats_supported);
325+
ena_get_strings(adapter, data, ena_com_get_cap(dev, ENA_ADMIN_ENI_STATS));
323326
break;
324327
}
325328
}

0 commit comments

Comments
 (0)