Skip to content

Commit 48398b6

Browse files
Govindarajulu Varadarajandavem330
authored andcommitted
enic: set UDP rss flag
New hardware needs UDP flag set to enable UDP L4 rss hash. Add ethtool get option to display supported rss flow hash. Signed-off-by: Govindarajulu Varadarajan <gvaradar@cisco.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 7e24c64 commit 48398b6

File tree

5 files changed

+58
-1
lines changed

5 files changed

+58
-1
lines changed

drivers/net/ethernet/cisco/enic/enic_ethtool.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,39 @@ static int enic_grxclsrule(struct enic *enic, struct ethtool_rxnfc *cmd)
474474
return 0;
475475
}
476476

477+
static int enic_get_rx_flow_hash(struct enic *enic, struct ethtool_rxnfc *cmd)
478+
{
479+
cmd->data = 0;
480+
481+
switch (cmd->flow_type) {
482+
case TCP_V6_FLOW:
483+
case TCP_V4_FLOW:
484+
cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
485+
/* Fall through */
486+
case UDP_V6_FLOW:
487+
case UDP_V4_FLOW:
488+
if (vnic_dev_capable_udp_rss(enic->vdev))
489+
cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
490+
/* Fall through */
491+
case SCTP_V4_FLOW:
492+
case AH_ESP_V4_FLOW:
493+
case AH_V4_FLOW:
494+
case ESP_V4_FLOW:
495+
case SCTP_V6_FLOW:
496+
case AH_ESP_V6_FLOW:
497+
case AH_V6_FLOW:
498+
case ESP_V6_FLOW:
499+
case IPV4_FLOW:
500+
case IPV6_FLOW:
501+
cmd->data |= RXH_IP_SRC | RXH_IP_DST;
502+
break;
503+
default:
504+
return -EINVAL;
505+
}
506+
507+
return 0;
508+
}
509+
477510
static int enic_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd,
478511
u32 *rule_locs)
479512
{
@@ -500,6 +533,9 @@ static int enic_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd,
500533
ret = enic_grxclsrule(enic, cmd);
501534
spin_unlock_bh(&enic->rfs_h.lock);
502535
break;
536+
case ETHTOOL_GRXFH:
537+
ret = enic_get_rx_flow_hash(enic, cmd);
538+
break;
503539
default:
504540
ret = -EOPNOTSUPP;
505541
break;

drivers/net/ethernet/cisco/enic/enic_main.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2316,14 +2316,16 @@ static int enic_set_rss_nic_cfg(struct enic *enic)
23162316
{
23172317
struct device *dev = enic_get_dev(enic);
23182318
const u8 rss_default_cpu = 0;
2319-
const u8 rss_hash_type = NIC_CFG_RSS_HASH_TYPE_IPV4 |
2319+
u8 rss_hash_type = NIC_CFG_RSS_HASH_TYPE_IPV4 |
23202320
NIC_CFG_RSS_HASH_TYPE_TCP_IPV4 |
23212321
NIC_CFG_RSS_HASH_TYPE_IPV6 |
23222322
NIC_CFG_RSS_HASH_TYPE_TCP_IPV6;
23232323
const u8 rss_hash_bits = 7;
23242324
const u8 rss_base_cpu = 0;
23252325
u8 rss_enable = ENIC_SETTING(enic, RSS) && (enic->rq_count > 1);
23262326

2327+
if (vnic_dev_capable_udp_rss(enic->vdev))
2328+
rss_hash_type |= NIC_CFG_RSS_HASH_TYPE_UDP;
23272329
if (rss_enable) {
23282330
if (!enic_set_rsskey(enic)) {
23292331
if (enic_set_rsscpu(enic, rss_hash_bits)) {

drivers/net/ethernet/cisco/enic/vnic_dev.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,3 +1281,20 @@ int vnic_dev_get_supported_feature_ver(struct vnic_dev *vdev, u8 feature,
12811281

12821282
return ret;
12831283
}
1284+
1285+
bool vnic_dev_capable_udp_rss(struct vnic_dev *vdev)
1286+
{
1287+
u64 a0 = CMD_NIC_CFG, a1 = 0;
1288+
u64 rss_hash_type;
1289+
int wait = 1000;
1290+
int err;
1291+
1292+
err = vnic_dev_cmd(vdev, CMD_CAPABILITY, &a0, &a1, wait);
1293+
if (err || !a0)
1294+
return 0;
1295+
1296+
rss_hash_type = (a1 >> NIC_CFG_RSS_HASH_TYPE_SHIFT) &
1297+
NIC_CFG_RSS_HASH_TYPE_MASK_FIELD;
1298+
1299+
return (rss_hash_type & NIC_CFG_RSS_HASH_TYPE_UDP);
1300+
}

drivers/net/ethernet/cisco/enic/vnic_dev.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,5 +184,6 @@ int vnic_dev_overlay_offload_cfg(struct vnic_dev *vdev, u8 overlay,
184184
u16 vxlan_udp_port_number);
185185
int vnic_dev_get_supported_feature_ver(struct vnic_dev *vdev, u8 feature,
186186
u64 *supported_versions, u64 *a1);
187+
bool vnic_dev_capable_udp_rss(struct vnic_dev *vdev);
187188

188189
#endif /* _VNIC_DEV_H_ */

drivers/net/ethernet/cisco/enic/vnic_nic.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
#define NIC_CFG_RSS_HASH_TYPE_TCP_IPV6 (1 << 4)
4848
#define NIC_CFG_RSS_HASH_TYPE_IPV6_EX (1 << 5)
4949
#define NIC_CFG_RSS_HASH_TYPE_TCP_IPV6_EX (1 << 6)
50+
#define NIC_CFG_RSS_HASH_TYPE_UDP (1 << 7)
5051

5152
static inline void vnic_set_nic_cfg(u32 *nic_cfg,
5253
u8 rss_default_cpu, u8 rss_hash_type,

0 commit comments

Comments
 (0)