Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 424eb834 authored by Salil Mehta's avatar Salil Mehta Committed by David S. Miller
Browse files

net: hns3: Unified HNS3 {VF|PF} Ethernet Driver for hip08 SoC



Most of the NAPI handling interface, skb buffer management,
management of the RX/TX descriptors, ethool interface etc.
has quite a bit of code which is common to VF and PF driver.

This patch makes the exisitng PF's HNS3 ENET driver as the
common ENET driver for both Virtual & Physical Function. This
will help in reduction of redundancy and better management of
code.

Signed-off-by: default avatarSalil Mehta <salil.mehta@huawei.com>
Signed-off-by: default avatarlipeng <lipeng321@huawei.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e963cb78
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -7,3 +7,8 @@ obj-$(CONFIG_HNS3) += hns3pf/
obj-$(CONFIG_HNS3) += hns3vf/

obj-$(CONFIG_HNS3) += hnae3.o

obj-$(CONFIG_HNS3_ENET) += hns3.o
hns3-objs = hns3_enet.o hns3_ethtool.o

hns3-$(CONFIG_HNS3_DCB) += hns3_dcbnl.o
+12 −2
Original line number Diff line number Diff line
@@ -196,9 +196,18 @@ int hnae3_register_ae_dev(struct hnae3_ae_dev *ae_dev)
	const struct pci_device_id *id;
	struct hnae3_ae_algo *ae_algo;
	struct hnae3_client *client;
	int ret = 0;
	int ret = 0, lock_acquired;

	/* we can get deadlocked if SRIOV is being enabled in context to probe
	 * and probe gets called again in same context. This can happen when
	 * pci_enable_sriov() is called to create VFs from PF probes context.
	 * Therefore, for simplicity uniformly defering further probing in all
	 * cases where we detect contention.
	 */
	lock_acquired = mutex_trylock(&hnae3_common_lock);
	if (!lock_acquired)
		return -EPROBE_DEFER;

	mutex_lock(&hnae3_common_lock);
	list_add_tail(&ae_dev->node, &hnae3_ae_dev_list);

	/* Check if there are matched ae_algo */
@@ -211,6 +220,7 @@ int hnae3_register_ae_dev(struct hnae3_ae_dev *ae_dev)

		if (!ae_dev->ops) {
			dev_err(&ae_dev->pdev->dev, "ae_dev ops are null\n");
			ret = -EOPNOTSUPP;
			goto out_err;
		}

+4 −3
Original line number Diff line number Diff line
@@ -452,9 +452,10 @@ struct hnae3_unic_private_info {
	struct hnae3_queue **tqp;  /* array base of all TQPs of this instance */
};

#define HNAE3_SUPPORT_MAC_LOOPBACK    1
#define HNAE3_SUPPORT_PHY_LOOPBACK    2
#define HNAE3_SUPPORT_SERDES_LOOPBACK 4
#define HNAE3_SUPPORT_MAC_LOOPBACK    BIT(0)
#define HNAE3_SUPPORT_PHY_LOOPBACK    BIT(1)
#define HNAE3_SUPPORT_SERDES_LOOPBACK BIT(2)
#define HNAE3_SUPPORT_VF	      BIT(3)

struct hnae3_handle {
	struct hnae3_client *client;
+1 −1
Original line number Diff line number Diff line
@@ -93,7 +93,7 @@ void hns3_dcbnl_setup(struct hnae3_handle *handle)
{
	struct net_device *dev = handle->kinfo.netdev;

	if (!handle->kinfo.dcb_ops)
	if ((!handle->kinfo.dcb_ops) || (handle->flags & HNAE3_SUPPORT_VF))
		return;

	dev->dcbnl_ops = &hns3_dcbnl_ops;
+2 −0
Original line number Diff line number Diff line
@@ -52,6 +52,8 @@ static const struct pci_device_id hns3_pci_tbl[] = {
	 HNAE3_DEV_SUPPORT_ROCE_DCB_BITS},
	{PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_100G_RDMA_MACSEC),
	 HNAE3_DEV_SUPPORT_ROCE_DCB_BITS},
	{PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_100G_VF), 0},
	{PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_100G_RDMA_DCB_PFC_VF), 0},
	/* required last entry */
	{0, }
};
Loading