Skip to content

Commit c22c0d5

Browse files
committed
Merge branch 'net-hns3-updates-for-next'
Huazhong Tan says: ==================== net: hns3: updates for -next There are some updates for the HNS3 ethernet driver. promiscuous configuration more flexible, #2 adds ethtool private flags to control whether enable tx unicast promisc. previous version: https://patchwork.kernel.org/project/netdevbpf/cover/[email protected]/ ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents bdc40a3 + 592b017 commit c22c0d5

File tree

9 files changed

+223
-66
lines changed

9 files changed

+223
-66
lines changed

drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ struct hclge_vf_to_pf_msg {
110110
u8 en_bc;
111111
u8 en_uc;
112112
u8 en_mc;
113+
u8 en_limit_promisc;
113114
};
114115
struct {
115116
u8 vector_id;

drivers/net/ethernet/hisilicon/hns3/hnae3.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,11 @@ struct hnae3_roce_private_info {
719719
#define HNAE3_UPE (HNAE3_USER_UPE | HNAE3_OVERFLOW_UPE)
720720
#define HNAE3_MPE (HNAE3_USER_MPE | HNAE3_OVERFLOW_MPE)
721721

722+
enum hnae3_pflag {
723+
HNAE3_PFLAG_LIMIT_PROMISC,
724+
HNAE3_PFLAG_MAX
725+
};
726+
722727
struct hnae3_handle {
723728
struct hnae3_client *client;
724729
struct pci_dev *pdev;
@@ -741,6 +746,9 @@ struct hnae3_handle {
741746

742747
/* Network interface message level enabled bits */
743748
u32 msg_enable;
749+
750+
unsigned long supported_pflags;
751+
unsigned long priv_flags;
744752
};
745753

746754
#define hnae3_set_field(origin, mask, shift, val) \

drivers/net/ethernet/hisilicon/hns3/hns3_enet.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,17 +1006,21 @@ static int hns3_handle_vtags(struct hns3_enet_ring *tx_ring,
10061006
struct sk_buff *skb)
10071007
{
10081008
struct hnae3_handle *handle = tx_ring->tqp->handle;
1009+
struct hnae3_ae_dev *ae_dev;
10091010
struct vlan_ethhdr *vhdr;
10101011
int rc;
10111012

10121013
if (!(skb->protocol == htons(ETH_P_8021Q) ||
10131014
skb_vlan_tag_present(skb)))
10141015
return 0;
10151016

1016-
/* Since HW limitation, if port based insert VLAN enabled, only one VLAN
1017-
* header is allowed in skb, otherwise it will cause RAS error.
1017+
/* For HW limitation on HNAE3_DEVICE_VERSION_V2, if port based insert
1018+
* VLAN enabled, only one VLAN header is allowed in skb, otherwise it
1019+
* will cause RAS error.
10181020
*/
1021+
ae_dev = pci_get_drvdata(handle->pdev);
10191022
if (unlikely(skb_vlan_tagged_multi(skb) &&
1023+
ae_dev->dev_version <= HNAE3_DEVICE_VERSION_V2 &&
10201024
handle->port_base_vlan_state ==
10211025
HNAE3_PORT_BASE_VLAN_ENABLE))
10221026
return -EINVAL;
@@ -4226,6 +4230,9 @@ static int hns3_client_init(struct hnae3_handle *handle)
42264230

42274231
set_bit(HNS3_NIC_STATE_INITED, &priv->state);
42284232

4233+
if (ae_dev->dev_version >= HNAE3_DEVICE_VERSION_V3)
4234+
set_bit(HNAE3_PFLAG_LIMIT_PROMISC, &handle->supported_pflags);
4235+
42294236
if (netif_msg_drv(handle))
42304237
hns3_info_show(priv);
42314238

drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ struct hns3_sfp_type {
1818
u8 ext_type;
1919
};
2020

21+
struct hns3_pflag_desc {
22+
char name[ETH_GSTRING_LEN];
23+
void (*handler)(struct net_device *netdev, bool enable);
24+
};
25+
2126
/* tqp related stats */
2227
#define HNS3_TQP_STAT(_string, _member) { \
2328
.stats_string = _string, \
@@ -60,6 +65,8 @@ static const struct hns3_stats hns3_rxq_stats[] = {
6065
HNS3_TQP_STAT("non_reuse_pg", non_reuse_pg),
6166
};
6267

68+
#define HNS3_PRIV_FLAGS_LEN ARRAY_SIZE(hns3_priv_flags)
69+
6370
#define HNS3_RXQ_STATS_COUNT ARRAY_SIZE(hns3_rxq_stats)
6471

6572
#define HNS3_TQP_STATS_COUNT (HNS3_TXQ_STATS_COUNT + HNS3_RXQ_STATS_COUNT)
@@ -395,6 +402,23 @@ static void hns3_self_test(struct net_device *ndev,
395402
netif_dbg(h, drv, ndev, "self test end\n");
396403
}
397404

405+
static void hns3_update_limit_promisc_mode(struct net_device *netdev,
406+
bool enable)
407+
{
408+
struct hnae3_handle *handle = hns3_get_handle(netdev);
409+
410+
if (enable)
411+
set_bit(HNAE3_PFLAG_LIMIT_PROMISC, &handle->priv_flags);
412+
else
413+
clear_bit(HNAE3_PFLAG_LIMIT_PROMISC, &handle->priv_flags);
414+
415+
hns3_request_update_promisc_mode(handle);
416+
}
417+
418+
static const struct hns3_pflag_desc hns3_priv_flags[HNAE3_PFLAG_MAX] = {
419+
{ "limit_promisc", hns3_update_limit_promisc_mode }
420+
};
421+
398422
static int hns3_get_sset_count(struct net_device *netdev, int stringset)
399423
{
400424
struct hnae3_handle *h = hns3_get_handle(netdev);
@@ -411,6 +435,9 @@ static int hns3_get_sset_count(struct net_device *netdev, int stringset)
411435
case ETH_SS_TEST:
412436
return ops->get_sset_count(h, stringset);
413437

438+
case ETH_SS_PRIV_FLAGS:
439+
return HNAE3_PFLAG_MAX;
440+
414441
default:
415442
return -EOPNOTSUPP;
416443
}
@@ -464,6 +491,7 @@ static void hns3_get_strings(struct net_device *netdev, u32 stringset, u8 *data)
464491
struct hnae3_handle *h = hns3_get_handle(netdev);
465492
const struct hnae3_ae_ops *ops = h->ae_algo->ops;
466493
char *buff = (char *)data;
494+
int i;
467495

468496
if (!ops->get_strings)
469497
return;
@@ -476,6 +504,13 @@ static void hns3_get_strings(struct net_device *netdev, u32 stringset, u8 *data)
476504
case ETH_SS_TEST:
477505
ops->get_strings(h, stringset, data);
478506
break;
507+
case ETH_SS_PRIV_FLAGS:
508+
for (i = 0; i < HNS3_PRIV_FLAGS_LEN; i++) {
509+
snprintf(buff, ETH_GSTRING_LEN, "%s",
510+
hns3_priv_flags[i].name);
511+
buff += ETH_GSTRING_LEN;
512+
}
513+
break;
479514
default:
480515
break;
481516
}
@@ -1517,6 +1552,53 @@ static int hns3_get_module_eeprom(struct net_device *netdev,
15171552
return ops->get_module_eeprom(handle, ee->offset, ee->len, data);
15181553
}
15191554

1555+
static u32 hns3_get_priv_flags(struct net_device *netdev)
1556+
{
1557+
struct hnae3_handle *handle = hns3_get_handle(netdev);
1558+
1559+
return handle->priv_flags;
1560+
}
1561+
1562+
static int hns3_check_priv_flags(struct hnae3_handle *h, u32 changed)
1563+
{
1564+
u32 i;
1565+
1566+
for (i = 0; i < HNAE3_PFLAG_MAX; i++)
1567+
if ((changed & BIT(i)) && !test_bit(i, &h->supported_pflags)) {
1568+
netdev_err(h->netdev, "%s is unsupported\n",
1569+
hns3_priv_flags[i].name);
1570+
return -EOPNOTSUPP;
1571+
}
1572+
1573+
return 0;
1574+
}
1575+
1576+
static int hns3_set_priv_flags(struct net_device *netdev, u32 pflags)
1577+
{
1578+
struct hnae3_handle *handle = hns3_get_handle(netdev);
1579+
u32 changed = pflags ^ handle->priv_flags;
1580+
int ret;
1581+
u32 i;
1582+
1583+
ret = hns3_check_priv_flags(handle, changed);
1584+
if (ret)
1585+
return ret;
1586+
1587+
for (i = 0; i < HNAE3_PFLAG_MAX; i++) {
1588+
if (changed & BIT(i)) {
1589+
bool enable = !(handle->priv_flags & BIT(i));
1590+
1591+
if (enable)
1592+
handle->priv_flags |= BIT(i);
1593+
else
1594+
handle->priv_flags &= ~BIT(i);
1595+
hns3_priv_flags[i].handler(netdev, enable);
1596+
}
1597+
}
1598+
1599+
return 0;
1600+
}
1601+
15201602
#define HNS3_ETHTOOL_COALESCE (ETHTOOL_COALESCE_USECS | \
15211603
ETHTOOL_COALESCE_USE_ADAPTIVE | \
15221604
ETHTOOL_COALESCE_RX_USECS_HIGH | \
@@ -1547,6 +1629,8 @@ static const struct ethtool_ops hns3vf_ethtool_ops = {
15471629
.get_link = hns3_get_link,
15481630
.get_msglevel = hns3_get_msglevel,
15491631
.set_msglevel = hns3_set_msglevel,
1632+
.get_priv_flags = hns3_get_priv_flags,
1633+
.set_priv_flags = hns3_set_priv_flags,
15501634
};
15511635

15521636
static const struct ethtool_ops hns3_ethtool_ops = {
@@ -1583,6 +1667,8 @@ static const struct ethtool_ops hns3_ethtool_ops = {
15831667
.set_fecparam = hns3_set_fecparam,
15841668
.get_module_info = hns3_get_module_info,
15851669
.get_module_eeprom = hns3_get_module_eeprom,
1670+
.get_priv_flags = hns3_get_priv_flags,
1671+
.set_priv_flags = hns3_set_priv_flags,
15861672
};
15871673

15881674
void hns3_ethtool_set_ops(struct net_device *netdev)

drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -583,23 +583,26 @@ struct hclge_link_status_cmd {
583583
u8 rsv[23];
584584
};
585585

586-
struct hclge_promisc_param {
587-
u8 vf_id;
588-
u8 enable;
589-
};
586+
/* for DEVICE_VERSION_V1/2, reference to promisc cmd byte8 */
587+
#define HCLGE_PROMISC_EN_UC 1
588+
#define HCLGE_PROMISC_EN_MC 2
589+
#define HCLGE_PROMISC_EN_BC 3
590+
#define HCLGE_PROMISC_TX_EN 4
591+
#define HCLGE_PROMISC_RX_EN 5
592+
593+
/* for DEVICE_VERSION_V3, reference to promisc cmd byte10 */
594+
#define HCLGE_PROMISC_UC_RX_EN 2
595+
#define HCLGE_PROMISC_MC_RX_EN 3
596+
#define HCLGE_PROMISC_BC_RX_EN 4
597+
#define HCLGE_PROMISC_UC_TX_EN 5
598+
#define HCLGE_PROMISC_MC_TX_EN 6
599+
#define HCLGE_PROMISC_BC_TX_EN 7
590600

591-
#define HCLGE_PROMISC_TX_EN_B BIT(4)
592-
#define HCLGE_PROMISC_RX_EN_B BIT(5)
593-
#define HCLGE_PROMISC_EN_B 1
594-
#define HCLGE_PROMISC_EN_ALL 0x7
595-
#define HCLGE_PROMISC_EN_UC 0x1
596-
#define HCLGE_PROMISC_EN_MC 0x2
597-
#define HCLGE_PROMISC_EN_BC 0x4
598601
struct hclge_promisc_cfg_cmd {
599-
u8 flag;
602+
u8 promisc;
600603
u8 vf_id;
601-
__le16 rsv0;
602-
u8 rsv1[20];
604+
u8 extend_promisc;
605+
u8 rsv0[21];
603606
};
604607

605608
enum hclge_promisc_type {
@@ -822,6 +825,7 @@ enum hclge_mac_vlan_cfg_sel {
822825
#define HCLGE_CFG_NIC_ROCE_SEL_B 4
823826
#define HCLGE_ACCEPT_TAG2_B 5
824827
#define HCLGE_ACCEPT_UNTAG2_B 6
828+
#define HCLGE_TAG_SHIFT_MODE_EN_B 7
825829
#define HCLGE_VF_NUM_PER_BYTE 8
826830

827831
struct hclge_vport_vtag_tx_cfg_cmd {
@@ -838,6 +842,8 @@ struct hclge_vport_vtag_tx_cfg_cmd {
838842
#define HCLGE_REM_TAG2_EN_B 1
839843
#define HCLGE_SHOW_TAG1_EN_B 2
840844
#define HCLGE_SHOW_TAG2_EN_B 3
845+
#define HCLGE_DISCARD_TAG1_EN_B 5
846+
#define HCLGE_DISCARD_TAG2_EN_B 6
841847
struct hclge_vport_vtag_rx_cfg_cmd {
842848
u8 vport_vlan_cfg;
843849
u8 vf_offset;

0 commit comments

Comments
 (0)