Commit 737ec46e authored by Fengyan Mu's avatar Fengyan Mu Committed by Fengyan
Browse files

UNIC: Adds the process of UNIC driver initializing

driver inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I850RQ


CVE: NA

----------------------------------------------------------

Add UB mode to NIC driver, and when the driver runs in UB mode, change
the features that UB supports in initializing state.

This patch creates new files to host the function interfaces of the UB.

Signed-off-by: default avatarFengyan Mu <mufengyan@hisilicon.com>
Signed-off-by: default avatarJunxin Chen <chenjunxin1@huawei.com>
parent b9e23b82
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@
#

ccflags-y += -I$(srctree)/$(src)
ccflags-y += -I$(srctree)/drivers/net/ub/dev
ccflags-y += -I$(srctree)/drivers/net/ethernet/hisilicon/hns3/hns3pf
ccflags-y += -I$(srctree)/drivers/net/ethernet/hisilicon/hns3/hns3vf
ccflags-y += -I$(srctree)/drivers/net/ethernet/hisilicon/hns3/hns3_common
@@ -15,6 +16,7 @@ hns3-objs = hns3_enet.o hns3_ethtool.o hns3_debugfs.o
hns3-objs += hns3_ext.o

hns3-$(CONFIG_HNS3_DCB) += hns3_dcbnl.o
hns3-$(CONFIG_HNS3_UBL) += hns3_unic.o

obj-$(CONFIG_HNS3_HCLGEVF) += hclgevf.o

+16 −0
Original line number Diff line number Diff line
@@ -115,6 +115,15 @@ static const struct dcbnl_rtnl_ops hns3_dcbnl_ops = {
	.setdcbx	= hns3_dcbnl_setdcbx,
};

static const struct dcbnl_rtnl_ops hns3_unic_dcbnl_ops = {
	.ieee_getets	= hns3_dcbnl_ieee_getets,
	.ieee_setets	= hns3_dcbnl_ieee_setets,
	.ieee_setapp	= hns3_dcbnl_ieee_setapp,
	.ieee_delapp	= hns3_dcbnl_ieee_delapp,
	.getdcbx	= hns3_dcbnl_getdcbx,
	.setdcbx	= hns3_dcbnl_setdcbx,
};

/* hclge_dcbnl_setup - DCBNL setup
 * @handle: the corresponding vport handle
 * Set up DCBNL
@@ -126,5 +135,12 @@ void hns3_dcbnl_setup(struct hnae3_handle *handle)
	if ((!handle->kinfo.dcb_ops) || (handle->flags & HNAE3_SUPPORT_VF))
		return;

#ifdef CONFIG_HNS3_UBL
	if (hns3_ubl_supported(handle))
		dev->dcbnl_ops = &hns3_unic_dcbnl_ops;
	else
		dev->dcbnl_ops = &hns3_dcbnl_ops;
#else
	dev->dcbnl_ops = &hns3_dcbnl_ops;
#endif
}
+36 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@
#include "hnae3.h"
#include "hnae3_ext.h"
#include "hns3_enet.h"
#include "hns3_unic.h"
/* All hns3 tracepoints are defined by the include below, which
 * must be included exactly once across the whole kernel with
 * CREATE_TRACE_POINTS defined
@@ -3266,6 +3267,28 @@ static u16 hns3_nic_select_queue(struct net_device *netdev,
	return netdev_pick_tx(netdev, skb, sb_dev);
}

const struct net_device_ops hns3_unic_netdev_ops = {
	.ndo_open		= hns3_nic_net_open,
	.ndo_stop		= hns3_nic_net_stop,
	.ndo_start_xmit		= hns3_nic_net_xmit,
	.ndo_tx_timeout		= hns3_nic_net_timeout,
	.ndo_do_ioctl		= hns3_nic_do_ioctl,
	.ndo_change_mtu		= hns3_nic_change_mtu,
	.ndo_set_features	= hns3_nic_set_features,
	.ndo_features_check	= hns3_features_check,
	.ndo_get_stats64	= hns3_nic_get_stats64,
	.ndo_setup_tc		= hns3_nic_setup_tc,
	.ndo_set_rx_mode	= hns3_nic_set_rx_mode,
	.ndo_set_vf_trust	= hns3_set_vf_trust,
#ifdef CONFIG_RFS_ACCEL
	.ndo_rx_flow_steer	= hns3_rx_flow_steer,
#endif
	.ndo_get_vf_config	= hns3_nic_get_vf_config,
	.ndo_set_vf_link_state	= hns3_nic_set_vf_link_state,
	.ndo_set_vf_rate	= hns3_nic_set_vf_rate,
	.ndo_select_queue	= hns3_nic_select_queue,
};

static const struct net_device_ops hns3_nic_netdev_ops = {
	.ndo_open		= hns3_nic_net_open,
	.ndo_stop		= hns3_nic_net_stop,
@@ -5581,7 +5604,16 @@ static int hns3_client_init(struct hnae3_handle *handle)

	netdev->watchdog_timeo = HNS3_TX_TIMEOUT;
	netdev->priv_flags |= IFF_UNICAST_FLT;

#ifdef CONFIG_HNS3_UBL
	if (hns3_ubl_supported(handle))
		netdev->netdev_ops = &hns3_unic_netdev_ops;
	else
		netdev->netdev_ops = &hns3_nic_netdev_ops;
#else
	netdev->netdev_ops = &hns3_nic_netdev_ops;
#endif

	SET_NETDEV_DEV(netdev, &pdev->dev);
	hns3_ethtool_set_ops(netdev);

@@ -5649,6 +5681,10 @@ static int hns3_client_init(struct hnae3_handle *handle)
	}

	netdev->max_mtu = HNS3_MAX_MTU(ae_dev->dev_specs.max_frm_size);
#ifdef CONFIG_HNS3_UBL
	if (hns3_ubl_supported(handle))
		hns3_unic_init(netdev);
#endif

	hns3_state_init(handle);

+46 −0
Original line number Diff line number Diff line
@@ -2101,6 +2101,48 @@ static const struct ethtool_ops hns3vf_ethtool_ops = {
	.reset = hns3_set_reset,
};

static const struct ethtool_ops hns3_unic_ethtool_ops = {
	.supported_coalesce_params = HNS3_ETHTOOL_COALESCE,
	.supported_ring_params = HNS3_ETHTOOL_RING,
	.self_test = hns3_self_test,
	.get_drvinfo = hns3_get_drvinfo,
	.get_link = hns3_get_link,
	.get_ringparam = hns3_get_ringparam,
	.set_ringparam = hns3_set_ringparam,
	.get_strings = hns3_get_strings,
	.get_ethtool_stats = hns3_get_stats,
	.get_sset_count = hns3_get_sset_count,
	.get_channels = hns3_get_channels,
	.set_channels = hns3_set_channels,
	.get_rxnfc = hns3_get_rxnfc,
	.set_rxnfc = hns3_set_rxnfc,
	.get_rxfh_key_size = hns3_get_rss_key_size,
	.get_rxfh_indir_size = hns3_get_rss_indir_size,
	.get_rxfh = hns3_get_rss,
	.set_rxfh = hns3_set_rss,
	.get_link_ksettings = hns3_get_link_ksettings,
	.set_link_ksettings = hns3_set_link_ksettings,
	.nway_reset = hns3_nway_reset,
	.get_coalesce = hns3_get_coalesce,
	.set_coalesce = hns3_set_coalesce,
	.get_regs_len = hns3_get_regs_len,
	.get_regs = hns3_get_regs,
	.set_phys_id = hns3_set_phys_id,
	.get_msglevel = hns3_get_msglevel,
	.set_msglevel = hns3_set_msglevel,
	.get_fecparam = hns3_get_fecparam,
	.set_fecparam = hns3_set_fecparam,
	.get_module_info = hns3_get_module_info,
	.get_module_eeprom = hns3_get_module_eeprom,
	.get_priv_flags = hns3_get_priv_flags,
	.set_priv_flags = hns3_set_priv_flags,
	.get_ts_info = hns3_get_ts_info,
	.get_tunable = hns3_get_tunable,
	.set_tunable = hns3_set_tunable,
	.reset = hns3_set_reset,
	.get_link_ext_state = hns3_get_link_ext_state,
};

static const struct ethtool_ops hns3_ethtool_ops = {
	.supported_coalesce_params = HNS3_ETHTOOL_COALESCE,
	.supported_ring_params = HNS3_ETHTOOL_RING,
@@ -2153,6 +2195,10 @@ void hns3_ethtool_set_ops(struct net_device *netdev)

	if (h->flags & HNAE3_SUPPORT_VF)
		netdev->ethtool_ops = &hns3vf_ethtool_ops;
#ifdef CONFIG_HNS3_UBL
	else if (hns3_ubl_supported(h))
		netdev->ethtool_ops = &hns3_unic_ethtool_ops;
#endif
	else
		netdev->ethtool_ops = &hns3_ethtool_ops;
}
+34 −0
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0+
/* Hisilicon UNIC Linux driver
 * Copyright (c) 2023-2023 Hisilicon Limited.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms and conditions of the GNU General Public License,
 * version 2, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * for more details.
 *
 */

#include <linux/skbuff.h>

#include "ubl.h"
#include "hnae3.h"
#include "hns3_enet.h"
#include "hns3_unic.h"

void hns3_unic_init(struct net_device *netdev)
{
	netdev->features &= ~(NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_HW_CSUM |
		NETIF_F_RXCSUM | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
		NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_HW_VLAN_CTAG_TX);
	netdev->features |= NETIF_F_VLAN_CHALLENGED;
	netdev->hw_features &= ~(NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_HW_CSUM |
		NETIF_F_RXCSUM | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
		NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_HW_VLAN_CTAG_TX);

	netdev->flags &= ~(IFF_BROADCAST | IFF_MULTICAST);
}
Loading