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

Commit 831d828b authored by Yisen.Zhuang\(Zhuangyuzeng\)'s avatar Yisen.Zhuang\(Zhuangyuzeng\) Committed by David S. Miller
Browse files

net: hns: separate debug dsaf device from service dsaf device



There are two kinds of dsaf device in hns, one is for service ports,
contains crossbar in it, can work under different mode. Another is for
debug port, only can work under "single-port" mode. The current code only
declared a dsaf device for both service ports and debug ports. This patch
separate it to three platform devices.

Here is the diagram of all port in one platform device(old):
                                        CPU
                                         |
                                         |        DSAF(one platform device)
    --------------------------------------------------------------      /
    |                           |                  |      |      |     /
    |                          PPE                PPE    PPE     |    /
    |                           |                  |      |      |   /
    |                           |                  |      |      |  /
    |                        crossbar              |      |      | /
    |                           |                  |      |      |/
    |    -----------------------------------       |      |      |
    |    |      |      |      |      |      |      |      |      |
    |    |      |      |      |      |      |      |      |      |
    |   MAC    MAC    MAC    MAC    MAC    MAC    MAC    MAC     |
    |    |      |      |      |      |      |      |      |      |
    --------------------------------------------------------------
         |      |      |      |      |      |      |      |
        PHY    PHY    PHY    PHY    PHY    PHY    PHY    PHY

Here is the diagram of separate all ports to three platform(new):
                                                         CPU
                                                          |
                                    -----------------------------------
                                    |                     |           |
    ----------------------------------------------    ---------   ---------
    |                         |                  |    |       |   |   |   |
    |                        PPE                 |    |  PPE  |   |  PPE  |
    |                         |                  |    |   |   |   |   |   |
    |                         |                  |    |   |   |   |   |   |
    |                      crossbar              |    |   |   |   |   |   |
    |                         |                  |    |   |   |   |   |   |
    |   ----------------------------------       |    |   |   |   |   |   |
    |   |     |     |      |      |      |       |    |   |   |   |   |   |
    |   |     |     |      |      |      |       |    |   |   |   |   |   |
    |  MAC   MAC   MAC    MAC    MAC    MAC      |    |  MAC  |   |  MAC  |
    |   |     |     |      |      |      |       |    |   |   |   |   |   |
    ----------------------------------------------    ---------   ---------
        |     |     |      |      |      |    \        /  |        /  |
       PHY   PHY   PHY    PHY    PHY    PHY    \      /  PHY      /  PHY
                                                \    /           /
                                                 \  /           /
                                             DSAF(three platform device)

Signed-off-by: default avatarDaode Huang <huangdaode@hisilicon.com>
Signed-off-by: default avatarYisen Zhuang <yisen.zhuang@huawei.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2e2591b1
Loading
Loading
Loading
Loading
+10 −30
Original line number Diff line number Diff line
@@ -37,50 +37,35 @@ static struct dsaf_device *hns_ae_get_dsaf_dev(struct hnae_ae_dev *dev)
static struct hns_ppe_cb *hns_get_ppe_cb(struct hnae_handle *handle)
{
	int ppe_index;
	int ppe_common_index;
	struct ppe_common_cb *ppe_comm;
	struct  hnae_vf_cb *vf_cb = hns_ae_get_vf_cb(handle);

	if (vf_cb->port_index < DSAF_SERVICE_PORT_NUM_PER_DSAF) {
	ppe_comm = vf_cb->dsaf_dev->ppe_common[0];
	ppe_index = vf_cb->port_index;
		ppe_common_index = 0;
	} else {
		ppe_index = 0;
		ppe_common_index =
			vf_cb->port_index - DSAF_SERVICE_PORT_NUM_PER_DSAF + 1;
	}
	ppe_comm = vf_cb->dsaf_dev->ppe_common[ppe_common_index];

	return &ppe_comm->ppe_cb[ppe_index];
}

static int hns_ae_get_q_num_per_vf(
	struct dsaf_device *dsaf_dev, int port)
{
	int common_idx = hns_dsaf_get_comm_idx_by_port(port);

	return dsaf_dev->rcb_common[common_idx]->max_q_per_vf;
	return dsaf_dev->rcb_common[0]->max_q_per_vf;
}

static int hns_ae_get_vf_num_per_port(
	struct dsaf_device *dsaf_dev, int port)
{
	int common_idx = hns_dsaf_get_comm_idx_by_port(port);

	return dsaf_dev->rcb_common[common_idx]->max_vfn;
	return dsaf_dev->rcb_common[0]->max_vfn;
}

static struct ring_pair_cb *hns_ae_get_base_ring_pair(
	struct dsaf_device *dsaf_dev, int port)
{
	int common_idx = hns_dsaf_get_comm_idx_by_port(port);
	struct rcb_common_cb *rcb_comm = dsaf_dev->rcb_common[common_idx];
	struct rcb_common_cb *rcb_comm = dsaf_dev->rcb_common[0];
	int q_num = rcb_comm->max_q_per_vf;
	int vf_num = rcb_comm->max_vfn;

	if (!HNS_DSAF_IS_DEBUG(dsaf_dev))
	return &rcb_comm->ring_pair_cb[port * q_num * vf_num];
	else
		return &rcb_comm->ring_pair_cb[0];
}

static struct ring_pair_cb *hns_ae_get_ring_pair(struct hnae_queue *q)
@@ -143,7 +128,7 @@ struct hnae_handle *hns_ae_get_handle(struct hnae_ae_dev *dev,

	vf_cb->dsaf_dev = dsaf_dev;
	vf_cb->port_index = port_id;
	vf_cb->mac_cb = &dsaf_dev->mac_cb[port_id];
	vf_cb->mac_cb = dsaf_dev->mac_cb[port_id];

	ae_handle->phy_if = vf_cb->mac_cb->phy_if;
	ae_handle->phy_node = vf_cb->mac_cb->phy_node;
@@ -299,11 +284,8 @@ static void hns_ae_reset(struct hnae_handle *handle)
	struct hnae_vf_cb *vf_cb = hns_ae_get_vf_cb(handle);

	if (vf_cb->mac_cb->mac_type == HNAE_PORT_DEBUG) {
		u8 ppe_common_index =
			vf_cb->port_index - DSAF_SERVICE_PORT_NUM_PER_DSAF + 1;

		hns_mac_reset(vf_cb->mac_cb);
		hns_ppe_reset_common(vf_cb->dsaf_dev, ppe_common_index);
		hns_ppe_reset_common(vf_cb->dsaf_dev, 0);
	}
}

@@ -702,7 +684,6 @@ int hns_ae_cpld_set_led_id(struct hnae_handle *handle,
void hns_ae_get_regs(struct hnae_handle *handle, void *data)
{
	u32 *p = data;
	u32 rcb_com_idx;
	int i;
	struct hnae_vf_cb *vf_cb = hns_ae_get_vf_cb(handle);
	struct hns_ppe_cb *ppe_cb = hns_get_ppe_cb(handle);
@@ -710,8 +691,7 @@ void hns_ae_get_regs(struct hnae_handle *handle, void *data)
	hns_ppe_get_regs(ppe_cb, p);
	p += hns_ppe_get_regs_count();

	rcb_com_idx = hns_dsaf_get_comm_idx_by_port(vf_cb->port_index);
	hns_rcb_get_common_regs(vf_cb->dsaf_dev->rcb_common[rcb_com_idx], p);
	hns_rcb_get_common_regs(vf_cb->dsaf_dev->rcb_common[0], p);
	p += hns_rcb_get_common_regs_count();

	for (i = 0; i < handle->q_num; i++) {
+108 −44
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/kernel.h>
#include <linux/mfd/syscon.h>
#include <linux/module.h>
#include <linux/netdevice.h>
#include <linux/of.h>
@@ -168,10 +169,9 @@ static int hns_mac_get_inner_port_num(struct hns_mac_cb *mac_cb,
				      u8 vmid, u8 *port_num)
{
	u8 tmp_port;
	u32 comm_idx;

	if (mac_cb->dsaf_dev->dsaf_mode <= DSAF_MODE_ENABLE) {
		if (mac_cb->mac_id != DSAF_MAX_PORT_NUM_PER_CHIP) {
		if (mac_cb->mac_id != DSAF_MAX_PORT_NUM) {
			dev_err(mac_cb->dev,
				"input invalid,%s mac%d vmid%d !\n",
				mac_cb->dsaf_dev->ae_dev.name,
@@ -179,7 +179,7 @@ static int hns_mac_get_inner_port_num(struct hns_mac_cb *mac_cb,
			return -EINVAL;
		}
	} else if (mac_cb->dsaf_dev->dsaf_mode < DSAF_MODE_MAX) {
		if (mac_cb->mac_id >= DSAF_MAX_PORT_NUM_PER_CHIP) {
		if (mac_cb->mac_id >= DSAF_MAX_PORT_NUM) {
			dev_err(mac_cb->dev,
				"input invalid,%s mac%d vmid%d!\n",
				mac_cb->dsaf_dev->ae_dev.name,
@@ -192,9 +192,7 @@ static int hns_mac_get_inner_port_num(struct hns_mac_cb *mac_cb,
		return -EINVAL;
	}

	comm_idx = hns_dsaf_get_comm_idx_by_port(mac_cb->mac_id);

	if (vmid >= mac_cb->dsaf_dev->rcb_common[comm_idx]->max_vfn) {
	if (vmid >= mac_cb->dsaf_dev->rcb_common[0]->max_vfn) {
		dev_err(mac_cb->dev, "input invalid,%s mac%d vmid%d !\n",
			mac_cb->dsaf_dev->ae_dev.name, mac_cb->mac_id, vmid);
		return -EINVAL;
@@ -234,7 +232,7 @@ static int hns_mac_get_inner_port_num(struct hns_mac_cb *mac_cb,
}

/**
 *hns_mac_get_inner_port_num - change vf mac address
 *hns_mac_change_vf_addr - change vf mac address
 *@mac_cb: mac device
 *@vmid: vmid
 *@addr:mac address
@@ -651,14 +649,15 @@ static int hns_mac_init_ex(struct hns_mac_cb *mac_cb)
}

/**
 *mac_free_dev  - get mac information from device node
 *hns_mac_get_info  - get mac information from device node
 *@mac_cb: mac device
 *@np:device node
 *@mac_mode_idx:mac mode index
 * return: 0 --success, negative --fail
 */
static void hns_mac_get_info(struct hns_mac_cb *mac_cb,
			     struct device_node *np, u32 mac_mode_idx)
static int  hns_mac_get_info(struct hns_mac_cb *mac_cb)
{
	struct device_node *np = mac_cb->dev->of_node;
	struct regmap *syscon;
	mac_cb->link = false;
	mac_cb->half_duplex = false;
	mac_cb->speed = mac_phy_to_speed[mac_cb->phy_if];
@@ -675,11 +674,34 @@ static void hns_mac_get_info(struct hns_mac_cb *mac_cb,
	mac_cb->max_frm = MAC_DEFAULT_MTU;
	mac_cb->tx_pause_frm_time = MAC_DEFAULT_PAUSE_TIME;

	/* Get the rest of the PHY information */
	mac_cb->phy_node = of_parse_phandle(np, "phy-handle", mac_cb->mac_id);
	/* if the dsaf node doesn't contain a port subnode, get phy-handle
	 * from dsaf node
	 */
	if (!mac_cb->fw_port) {
		mac_cb->phy_node = of_parse_phandle(np, "phy-handle",
						    mac_cb->mac_id);
		if (mac_cb->phy_node)
			dev_dbg(mac_cb->dev, "mac%d phy_node: %s\n",
				mac_cb->mac_id, mac_cb->phy_node->name);
		return 0;
	}
	if (!is_of_node(mac_cb->fw_port))
		return -EINVAL;
	/* parse property from port subnode in dsaf */
	mac_cb->phy_node = of_parse_phandle(to_of_node(mac_cb->fw_port),
					    "phy-handle", 0);
	if (mac_cb->phy_node)
		dev_dbg(mac_cb->dev, "mac%d phy_node: %s\n",
			mac_cb->mac_id, mac_cb->phy_node->name);
	syscon = syscon_node_to_regmap(
			of_parse_phandle(to_of_node(mac_cb->fw_port),
					 "serdes-syscon", 0));
	if (IS_ERR_OR_NULL(syscon)) {
		dev_err(mac_cb->dev, "serdes-syscon is needed!\n");
		return -EINVAL;
	}
	mac_cb->serdes_ctrl = syscon;
	return 0;
}

/**
@@ -709,31 +731,27 @@ u8 __iomem *hns_mac_get_vaddr(struct dsaf_device *dsaf_dev,
		return base + 0x40000 + mac_id * 0x4000 -
				mac_mode_idx * 0x20000;
	else
		return mac_cb->serdes_vaddr + 0x1000
			+ (mac_id - DSAF_SERVICE_PORT_NUM_PER_DSAF) * 0x100000;
		return dsaf_dev->ppe_base + 0x1000;
}

/**
 * hns_mac_get_cfg - get mac cfg from dtb or acpi table
 * @dsaf_dev: dsa fabric device struct pointer
 * @mac_idx: mac index
 * retuen 0 - success , negative --fail
 * @mac_cb: mac control block
 * return 0 - success , negative --fail
 */
int hns_mac_get_cfg(struct dsaf_device *dsaf_dev, int mac_idx)
int hns_mac_get_cfg(struct dsaf_device *dsaf_dev, struct hns_mac_cb *mac_cb)
{
	int ret;
	u32 mac_mode_idx;
	struct hns_mac_cb *mac_cb = &dsaf_dev->mac_cb[mac_idx];

	mac_cb->dsaf_dev = dsaf_dev;
	mac_cb->dev = dsaf_dev->dev;
	mac_cb->mac_id = mac_idx;

	mac_cb->sys_ctl_vaddr =	dsaf_dev->sc_base;
	mac_cb->serdes_vaddr = dsaf_dev->sds_base;

	if (dsaf_dev->cpld_base &&
	    mac_idx < DSAF_SERVICE_PORT_NUM_PER_DSAF) {
	if (dsaf_dev->cpld_base && !HNS_DSAF_IS_DEBUG(dsaf_dev)) {
		mac_cb->cpld_vaddr = dsaf_dev->cpld_base +
			mac_cb->mac_id * CPLD_ADDR_PORT_OFFSET;
		cpld_led_reset(mac_cb);
@@ -742,7 +760,7 @@ int hns_mac_get_cfg(struct dsaf_device *dsaf_dev, int mac_idx)
	mac_cb->txpkt_for_led = 0;
	mac_cb->rxpkt_for_led = 0;

	if (mac_idx < DSAF_SERVICE_PORT_NUM_PER_DSAF)
	if (!HNS_DSAF_IS_DEBUG(dsaf_dev))
		mac_cb->mac_type = HNAE_PORT_SERVICE;
	else
		mac_cb->mac_type = HNAE_PORT_DEBUG;
@@ -758,53 +776,99 @@ int hns_mac_get_cfg(struct dsaf_device *dsaf_dev, int mac_idx)
	}
	mac_mode_idx = (u32)ret;

	hns_mac_get_info(mac_cb, mac_cb->dev->of_node, mac_mode_idx);
	ret  = hns_mac_get_info(mac_cb);
	if (ret)
		return ret;

	mac_cb->vaddr = hns_mac_get_vaddr(dsaf_dev, mac_cb, mac_mode_idx);

	return 0;
}

static int hns_mac_get_max_port_num(struct dsaf_device *dsaf_dev)
{
	if (HNS_DSAF_IS_DEBUG(dsaf_dev))
		return 1;
	else
		return  DSAF_MAX_PORT_NUM;
}

/**
 * hns_mac_init - init mac
 * @dsaf_dev: dsa fabric device struct pointer
 * retuen 0 - success , negative --fail
 * return 0 - success , negative --fail
 */
int hns_mac_init(struct dsaf_device *dsaf_dev)
{
	int i;
	bool found = false;
	int ret;
	size_t size;
	u32 port_id;
	int max_port_num = hns_mac_get_max_port_num(dsaf_dev);
	struct hns_mac_cb *mac_cb;
	struct fwnode_handle *child;

	size = sizeof(struct hns_mac_cb) * DSAF_MAX_PORT_NUM_PER_CHIP;
	dsaf_dev->mac_cb = devm_kzalloc(dsaf_dev->dev, size, GFP_KERNEL);
	if (!dsaf_dev->mac_cb)
	device_for_each_child_node(dsaf_dev->dev, child) {
		ret = fwnode_property_read_u32(child, "port-id", &port_id);
		if (ret) {
			dev_err(dsaf_dev->dev,
				"get port-id fail, ret=%d!\n", ret);
			return ret;
		}
		if (port_id >= max_port_num) {
			dev_err(dsaf_dev->dev,
				"port-id(%u) out of range!\n", port_id);
			return -EINVAL;
		}
		mac_cb = devm_kzalloc(dsaf_dev->dev, sizeof(*mac_cb),
				      GFP_KERNEL);
		if (!mac_cb)
			return -ENOMEM;
		mac_cb->fw_port = child;
		mac_cb->mac_id = (u8)port_id;
		dsaf_dev->mac_cb[port_id] = mac_cb;
		found = true;
	}

	for (i = 0; i < DSAF_MAX_PORT_NUM_PER_CHIP; i++) {
		ret = hns_mac_get_cfg(dsaf_dev, i);
		if (ret)
			goto free_mac_cb;
	/* if don't get any port subnode from dsaf node
	 * will init all port then, this is compatible with the old dts
	 */
	if (!found) {
		for (port_id = 0; port_id < max_port_num; port_id++) {
			mac_cb = devm_kzalloc(dsaf_dev->dev, sizeof(*mac_cb),
					      GFP_KERNEL);
			if (!mac_cb)
				return -ENOMEM;

		mac_cb = &dsaf_dev->mac_cb[i];
			mac_cb->mac_id = port_id;
			dsaf_dev->mac_cb[port_id] = mac_cb;
		}
	}
	/* init mac_cb for all port */
	for (port_id = 0; port_id < max_port_num; port_id++) {
		mac_cb = dsaf_dev->mac_cb[port_id];
		if (!mac_cb)
			continue;

		ret = hns_mac_get_cfg(dsaf_dev, mac_cb);
		if (ret)
			return ret;
		ret = hns_mac_init_ex(mac_cb);
		if (ret)
			goto free_mac_cb;
			return ret;
	}

	return 0;

free_mac_cb:
	dsaf_dev->mac_cb = NULL;

	return ret;
}

void hns_mac_uninit(struct dsaf_device *dsaf_dev)
{
	cpld_led_reset(dsaf_dev->mac_cb);
	dsaf_dev->mac_cb = NULL;
	int i;
	int max_port_num = hns_mac_get_max_port_num(dsaf_dev);

	for (i = 0; i < max_port_num; i++) {
		cpld_led_reset(dsaf_dev->mac_cb[i]);
		dsaf_dev->mac_cb[i] = NULL;
	}
}

int hns_mac_config_mac_loopback(struct hns_mac_cb *mac_cb,
+5 −2
Original line number Diff line number Diff line
@@ -10,9 +10,10 @@
#ifndef _HNS_DSAF_MAC_H
#define _HNS_DSAF_MAC_H

#include <linux/phy.h>
#include <linux/kernel.h>
#include <linux/if_vlan.h>
#include <linux/kernel.h>
#include <linux/phy.h>
#include <linux/regmap.h>
#include "hns_dsaf_main.h"

struct dsaf_device;
@@ -310,10 +311,12 @@ struct hns_mac_cb {
	struct device *dev;
	struct dsaf_device *dsaf_dev;
	struct mac_priv priv;
	struct fwnode_handle *fw_port;
	u8 __iomem *vaddr;
	u8 __iomem *cpld_vaddr;
	u8 __iomem *sys_ctl_vaddr;
	u8 __iomem *serdes_vaddr;
	struct regmap *serdes_ctrl;
	struct mac_entry_idx addr_entry_idx[DSAF_MAX_VM_NUM];
	u8 sfp_prsnt;
	u8 cpld_led_value;
+62 −31
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/netdevice.h>
#include <linux/mfd/syscon.h>
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/of_irq.h>
@@ -37,8 +38,12 @@ int hns_dsaf_get_cfg(struct dsaf_device *dsaf_dev)
	u32 desc_num;
	u32 buf_size;
	u32 reset_offset = 0;
	u32 res_idx = 0;
	const char *mode_str;
	struct regmap *syscon;
	struct resource *res;
	struct device_node *np = dsaf_dev->dev->of_node;
	struct platform_device *pdev = to_platform_device(dsaf_dev->dev);

	if (of_device_is_compatible(np, "hisilicon,hns-dsaf-v1"))
		dsaf_dev->dsaf_ver = AE_VERSION_1;
@@ -75,41 +80,67 @@ int hns_dsaf_get_cfg(struct dsaf_device *dsaf_dev)
	else
		dsaf_dev->dsaf_tc_mode = HRD_DSAF_4TC_MODE;

	dsaf_dev->sc_base = of_iomap(np, 0);
	syscon = syscon_node_to_regmap(
			of_parse_phandle(np, "subctrl-syscon", 0));
	if (IS_ERR_OR_NULL(syscon)) {
		res = platform_get_resource(pdev, IORESOURCE_MEM, res_idx++);
		if (!res) {
			dev_err(dsaf_dev->dev, "subctrl info is needed!\n");
			return -ENOMEM;
		}
		dsaf_dev->sc_base = devm_ioremap_resource(&pdev->dev, res);
		if (!dsaf_dev->sc_base) {
		dev_err(dsaf_dev->dev,
			"%s of_iomap 0 fail!\n", dsaf_dev->ae_dev.name);
		ret = -ENOMEM;
		goto unmap_base_addr;
			dev_err(dsaf_dev->dev, "subctrl can not map!\n");
			return -ENOMEM;
		}

	dsaf_dev->sds_base = of_iomap(np, 1);
		res = platform_get_resource(pdev, IORESOURCE_MEM, res_idx++);
		if (!res) {
			dev_err(dsaf_dev->dev, "serdes-ctrl info is needed!\n");
			return -ENOMEM;
		}
		dsaf_dev->sds_base = devm_ioremap_resource(&pdev->dev, res);
		if (!dsaf_dev->sds_base) {
		dev_err(dsaf_dev->dev,
			"%s of_iomap 1 fail!\n", dsaf_dev->ae_dev.name);
		ret = -ENOMEM;
		goto unmap_base_addr;
			dev_err(dsaf_dev->dev, "serdes-ctrl can not map!\n");
			return -ENOMEM;
		}
	} else {
		dsaf_dev->sub_ctrl = syscon;
	}

	dsaf_dev->ppe_base = of_iomap(np, 2);
	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ppe-base");
	if (!res) {
		res = platform_get_resource(pdev, IORESOURCE_MEM, res_idx++);
		if (!res) {
			dev_err(dsaf_dev->dev, "ppe-base info is needed!\n");
			return -ENOMEM;
		}
	}
	dsaf_dev->ppe_base = devm_ioremap_resource(&pdev->dev, res);
	if (!dsaf_dev->ppe_base) {
		dev_err(dsaf_dev->dev, "ppe-base resource can not map!\n");
		return -ENOMEM;
	}
	dsaf_dev->ppe_paddr = res->start;

	if (!HNS_DSAF_IS_DEBUG(dsaf_dev)) {
		res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
						   "dsaf-base");
		if (!res) {
			res = platform_get_resource(pdev, IORESOURCE_MEM,
						    res_idx);
			if (!res) {
				dev_err(dsaf_dev->dev,
			"%s of_iomap 2 fail!\n", dsaf_dev->ae_dev.name);
		ret = -ENOMEM;
		goto unmap_base_addr;
					"dsaf-base info is needed!\n");
				return -ENOMEM;
			}

	dsaf_dev->io_base = of_iomap(np, 3);
		}
		dsaf_dev->io_base = devm_ioremap_resource(&pdev->dev, res);
		if (!dsaf_dev->io_base) {
		dev_err(dsaf_dev->dev,
			"%s of_iomap 3 fail!\n", dsaf_dev->ae_dev.name);
		ret = -ENOMEM;
		goto unmap_base_addr;
			dev_err(dsaf_dev->dev, "dsaf-base resource can not map!\n");
			return -ENOMEM;
		}
	}

	dsaf_dev->cpld_base = of_iomap(np, 4);
	if (!dsaf_dev->cpld_base)
		dev_dbg(dsaf_dev->dev, "NO CPLD ADDR");

	ret = of_property_read_u32(np, "desc-num", &desc_num);
	if (ret < 0 || desc_num < HNS_DSAF_MIN_DESC_CNT ||
@@ -725,7 +756,7 @@ void hns_dsaf_set_promisc_mode(struct dsaf_device *dsaf_dev, u32 en)
void hns_dsaf_set_inner_lb(struct dsaf_device *dsaf_dev, u32 mac_id, u32 en)
{
	if (AE_IS_VER1(dsaf_dev->dsaf_ver) ||
	    dsaf_dev->mac_cb[mac_id].mac_type == HNAE_PORT_DEBUG)
	    dsaf_dev->mac_cb[mac_id]->mac_type == HNAE_PORT_DEBUG)
		return;

	dsaf_set_dev_bit(dsaf_dev, DSAFV2_SERDES_LBK_0_REG + 4 * mac_id,
+3 −9
Original line number Diff line number Diff line
@@ -278,6 +278,8 @@ struct dsaf_device {
	u8 __iomem *ppe_base;
	u8 __iomem *io_base;
	u8 __iomem *cpld_base;
	struct regmap *sub_ctrl;
	phys_addr_t ppe_paddr;

	u32 desc_num; /*  desc num per queue*/
	u32 buf_size; /*  ring buffer size */
@@ -290,7 +292,7 @@ struct dsaf_device {

	struct ppe_common_cb *ppe_common[DSAF_COMM_DEV_NUM];
	struct rcb_common_cb *rcb_common[DSAF_COMM_DEV_NUM];
	struct hns_mac_cb *mac_cb;
	struct hns_mac_cb *mac_cb[DSAF_MAX_PORT_NUM];

	struct dsaf_hw_stats hw_stats[DSAF_NODE_NUM];
	struct dsaf_int_stat int_stat;
@@ -362,14 +364,6 @@ static inline void hns_dsaf_tbl_line_addr_cfg(struct dsaf_device *dsaf_dev,
			   tab_line_addr);
}

static inline int hns_dsaf_get_comm_idx_by_port(int port)
{
	if ((port < DSAF_COMM_CHN) || (port == DSAF_MAX_PORT_NUM_PER_CHIP))
		return 0;
	else
		return (port - DSAF_COMM_CHN + 1);
}

static inline struct hnae_vf_cb *hns_ae_get_vf_cb(
	struct hnae_handle *handle)
{
Loading