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

Commit 527f2273 authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'hns-next'



Yisen Zhuang says:

====================
net: hns: fix some bugs in hns driver

This series includes some bugs fixed. All these patches needs to be
applied after the patchset about ACPI support, so this series is
floated to net-next list.

The patches are:
 > from Daode, fixes about pfc pause frame, getting coaslesce, led
control logic, TSO on|off and tcam table configuration.

 > from Jun He, fix the potential leak to port unavailable

 > from Kejian, fix bug of loopback and failing to test ping6

 > from Qianqian, fix the several typo in hns driver

For more details, please see individual patches.
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 4906ce45 6fe27464
Loading
Loading
Loading
Loading
+0 −1
Original line number Original line Diff line number Diff line
@@ -400,7 +400,6 @@ int hnae_ae_register(struct hnae_ae_dev *hdev, struct module *owner)


	if (!hdev->ops || !hdev->ops->get_handle ||
	if (!hdev->ops || !hdev->ops->get_handle ||
	    !hdev->ops->toggle_ring_irq ||
	    !hdev->ops->toggle_ring_irq ||
	    !hdev->ops->toggle_queue_status ||
	    !hdev->ops->get_status || !hdev->ops->adjust_link)
	    !hdev->ops->get_status || !hdev->ops->adjust_link)
		return -EINVAL;
		return -EINVAL;


+5 −1
Original line number Original line Diff line number Diff line
@@ -454,7 +454,6 @@ struct hnae_ae_ops {
	int (*get_info)(struct hnae_handle *handle,
	int (*get_info)(struct hnae_handle *handle,
			u8 *auto_neg, u16 *speed, u8 *duplex);
			u8 *auto_neg, u16 *speed, u8 *duplex);
	void (*toggle_ring_irq)(struct hnae_ring *ring, u32 val);
	void (*toggle_ring_irq)(struct hnae_ring *ring, u32 val);
	void (*toggle_queue_status)(struct hnae_queue *queue, u32 val);
	void (*adjust_link)(struct hnae_handle *handle, int speed, int duplex);
	void (*adjust_link)(struct hnae_handle *handle, int speed, int duplex);
	int (*set_loopback)(struct hnae_handle *handle,
	int (*set_loopback)(struct hnae_handle *handle,
			    enum hnae_loop loop_mode, int en);
			    enum hnae_loop loop_mode, int en);
@@ -473,6 +472,11 @@ struct hnae_ae_ops {
	int (*set_coalesce_usecs)(struct hnae_handle *handle, u32 timeout);
	int (*set_coalesce_usecs)(struct hnae_handle *handle, u32 timeout);
	int (*set_coalesce_frames)(struct hnae_handle *handle,
	int (*set_coalesce_frames)(struct hnae_handle *handle,
				   u32 coalesce_frames);
				   u32 coalesce_frames);
	void (*get_coalesce_range)(struct hnae_handle *handle,
				   u32 *tx_frames_low, u32 *rx_frames_low,
				   u32 *tx_frames_high, u32 *rx_frames_high,
				   u32 *tx_usecs_low, u32 *rx_usecs_low,
				   u32 *tx_usecs_high, u32 *rx_usecs_high);
	void (*set_promisc_mode)(struct hnae_handle *handle, u32 en);
	void (*set_promisc_mode)(struct hnae_handle *handle, u32 en);
	int (*get_mac_addr)(struct hnae_handle *handle, void **p);
	int (*get_mac_addr)(struct hnae_handle *handle, void **p);
	int (*set_mac_addr)(struct hnae_handle *handle, void *p);
	int (*set_mac_addr)(struct hnae_handle *handle, void *p);
+38 −15
Original line number Original line Diff line number Diff line
@@ -247,12 +247,21 @@ static void hns_ae_set_tso_stats(struct hnae_handle *handle, int enable)
static int hns_ae_start(struct hnae_handle *handle)
static int hns_ae_start(struct hnae_handle *handle)
{
{
	int ret;
	int ret;
	int k;
	struct hns_mac_cb *mac_cb = hns_get_mac_cb(handle);
	struct hns_mac_cb *mac_cb = hns_get_mac_cb(handle);


	ret = hns_mac_vm_config_bc_en(mac_cb, 0, true);
	ret = hns_mac_vm_config_bc_en(mac_cb, 0, true);
	if (ret)
	if (ret)
		return ret;
		return ret;


	for (k = 0; k < handle->q_num; k++) {
		if (AE_IS_VER1(mac_cb->dsaf_dev->dsaf_ver))
			hns_rcb_int_clr_hw(handle->qs[k],
					   RCB_INT_FLAG_TX | RCB_INT_FLAG_RX);
		else
			hns_rcbv2_int_clr_hw(handle->qs[k],
					     RCB_INT_FLAG_TX | RCB_INT_FLAG_RX);
	}
	hns_ae_ring_enable_all(handle, 1);
	hns_ae_ring_enable_all(handle, 1);
	msleep(100);
	msleep(100);


@@ -313,18 +322,6 @@ static void hns_aev2_toggle_ring_irq(struct hnae_ring *ring, u32 mask)
	hns_rcbv2_int_ctrl_hw(ring->q, flag, mask);
	hns_rcbv2_int_ctrl_hw(ring->q, flag, mask);
}
}


static void hns_ae_toggle_queue_status(struct hnae_queue *queue, u32 val)
{
	struct dsaf_device *dsaf_dev = hns_ae_get_dsaf_dev(queue->dev);

	if (AE_IS_VER1(dsaf_dev->dsaf_ver))
		hns_rcb_int_clr_hw(queue, RCB_INT_FLAG_TX | RCB_INT_FLAG_RX);
	else
		hns_rcbv2_int_clr_hw(queue, RCB_INT_FLAG_TX | RCB_INT_FLAG_RX);

	hns_rcb_start(queue, val);
}

static int hns_ae_get_link_status(struct hnae_handle *handle)
static int hns_ae_get_link_status(struct hnae_handle *handle)
{
{
	u32 link_status;
	u32 link_status;
@@ -465,6 +462,30 @@ static int hns_ae_set_coalesce_frames(struct hnae_handle *handle,
		ring_pair->port_id_in_comm, coalesce_frames);
		ring_pair->port_id_in_comm, coalesce_frames);
}
}


static void hns_ae_get_coalesce_range(struct hnae_handle *handle,
				      u32 *tx_frames_low, u32 *rx_frames_low,
				      u32 *tx_frames_high, u32 *rx_frames_high,
				      u32 *tx_usecs_low, u32 *rx_usecs_low,
				      u32 *tx_usecs_high, u32 *rx_usecs_high)
{
	struct dsaf_device *dsaf_dev;

	dsaf_dev = hns_ae_get_dsaf_dev(handle->dev);

	*tx_frames_low  = HNS_RCB_MIN_COALESCED_FRAMES;
	*rx_frames_low  = HNS_RCB_MIN_COALESCED_FRAMES;
	*tx_frames_high =
		(dsaf_dev->desc_num - 1 > HNS_RCB_MAX_COALESCED_FRAMES) ?
		HNS_RCB_MAX_COALESCED_FRAMES : dsaf_dev->desc_num - 1;
	*rx_frames_high =
		(dsaf_dev->desc_num - 1 > HNS_RCB_MAX_COALESCED_FRAMES) ?
		 HNS_RCB_MAX_COALESCED_FRAMES : dsaf_dev->desc_num - 1;
	*tx_usecs_low   = 0;
	*rx_usecs_low   = 0;
	*tx_usecs_high  = HNS_RCB_MAX_COALESCED_USECS;
	*rx_usecs_high  = HNS_RCB_MAX_COALESCED_USECS;
}

void hns_ae_update_stats(struct hnae_handle *handle,
void hns_ae_update_stats(struct hnae_handle *handle,
			 struct net_device_stats *net_stats)
			 struct net_device_stats *net_stats)
{
{
@@ -587,6 +608,7 @@ void hns_ae_get_strings(struct hnae_handle *handle,
	int idx;
	int idx;
	struct hns_mac_cb *mac_cb;
	struct hns_mac_cb *mac_cb;
	struct hns_ppe_cb *ppe_cb;
	struct hns_ppe_cb *ppe_cb;
	struct dsaf_device *dsaf_dev = hns_ae_get_dsaf_dev(handle->dev);
	u8 *p = data;
	u8 *p = data;
	struct	hnae_vf_cb *vf_cb;
	struct	hnae_vf_cb *vf_cb;


@@ -609,13 +631,14 @@ void hns_ae_get_strings(struct hnae_handle *handle,
	p += ETH_GSTRING_LEN * hns_mac_get_sset_count(mac_cb, stringset);
	p += ETH_GSTRING_LEN * hns_mac_get_sset_count(mac_cb, stringset);


	if (mac_cb->mac_type == HNAE_PORT_SERVICE)
	if (mac_cb->mac_type == HNAE_PORT_SERVICE)
		hns_dsaf_get_strings(stringset, p, port);
		hns_dsaf_get_strings(stringset, p, port, dsaf_dev);
}
}


int hns_ae_get_sset_count(struct hnae_handle *handle, int stringset)
int hns_ae_get_sset_count(struct hnae_handle *handle, int stringset)
{
{
	u32 sset_count = 0;
	u32 sset_count = 0;
	struct hns_mac_cb *mac_cb;
	struct hns_mac_cb *mac_cb;
	struct dsaf_device *dsaf_dev = hns_ae_get_dsaf_dev(handle->dev);


	assert(handle);
	assert(handle);


@@ -626,7 +649,7 @@ int hns_ae_get_sset_count(struct hnae_handle *handle, int stringset)
	sset_count += hns_mac_get_sset_count(mac_cb, stringset);
	sset_count += hns_mac_get_sset_count(mac_cb, stringset);


	if (mac_cb->mac_type == HNAE_PORT_SERVICE)
	if (mac_cb->mac_type == HNAE_PORT_SERVICE)
		sset_count += hns_dsaf_get_sset_count(stringset);
		sset_count += hns_dsaf_get_sset_count(dsaf_dev, stringset);


	return sset_count;
	return sset_count;
}
}
@@ -782,7 +805,6 @@ static struct hnae_ae_ops hns_dsaf_ops = {
	.stop = hns_ae_stop,
	.stop = hns_ae_stop,
	.reset = hns_ae_reset,
	.reset = hns_ae_reset,
	.toggle_ring_irq = hns_ae_toggle_ring_irq,
	.toggle_ring_irq = hns_ae_toggle_ring_irq,
	.toggle_queue_status = hns_ae_toggle_queue_status,
	.get_status = hns_ae_get_link_status,
	.get_status = hns_ae_get_link_status,
	.get_info = hns_ae_get_mac_info,
	.get_info = hns_ae_get_mac_info,
	.adjust_link = hns_ae_adjust_link,
	.adjust_link = hns_ae_adjust_link,
@@ -796,6 +818,7 @@ static struct hnae_ae_ops hns_dsaf_ops = {
	.get_rx_max_coalesced_frames = hns_ae_get_rx_max_coalesced_frames,
	.get_rx_max_coalesced_frames = hns_ae_get_rx_max_coalesced_frames,
	.set_coalesce_usecs = hns_ae_set_coalesce_usecs,
	.set_coalesce_usecs = hns_ae_set_coalesce_usecs,
	.set_coalesce_frames = hns_ae_set_coalesce_frames,
	.set_coalesce_frames = hns_ae_set_coalesce_frames,
	.get_coalesce_range = hns_ae_get_coalesce_range,
	.set_promisc_mode = hns_ae_set_promisc_mode,
	.set_promisc_mode = hns_ae_set_promisc_mode,
	.set_mac_addr = hns_ae_set_mac_address,
	.set_mac_addr = hns_ae_set_mac_address,
	.set_mc_addr = hns_ae_set_multicast_one,
	.set_mc_addr = hns_ae_set_multicast_one,
+125 −65
Original line number Original line Diff line number Diff line
@@ -176,7 +176,7 @@ int hns_dsaf_get_cfg(struct dsaf_device *dsaf_dev)
	    desc_num > HNS_DSAF_MAX_DESC_CNT) {
	    desc_num > HNS_DSAF_MAX_DESC_CNT) {
		dev_err(dsaf_dev->dev, "get desc-num(%d) fail, ret=%d!\n",
		dev_err(dsaf_dev->dev, "get desc-num(%d) fail, ret=%d!\n",
			desc_num, ret);
			desc_num, ret);
		goto unmap_base_addr;
		return -EINVAL;
	}
	}
	dsaf_dev->desc_num = desc_num;
	dsaf_dev->desc_num = desc_num;


@@ -192,7 +192,7 @@ int hns_dsaf_get_cfg(struct dsaf_device *dsaf_dev)
	if (ret < 0) {
	if (ret < 0) {
		dev_err(dsaf_dev->dev,
		dev_err(dsaf_dev->dev,
			"get buf-size fail, ret=%d!\r\n", ret);
			"get buf-size fail, ret=%d!\r\n", ret);
		goto unmap_base_addr;
		return ret;
	}
	}
	dsaf_dev->buf_size = buf_size;
	dsaf_dev->buf_size = buf_size;


@@ -200,7 +200,7 @@ int hns_dsaf_get_cfg(struct dsaf_device *dsaf_dev)
	if (dsaf_dev->buf_size_type < 0) {
	if (dsaf_dev->buf_size_type < 0) {
		dev_err(dsaf_dev->dev,
		dev_err(dsaf_dev->dev,
			"buf_size(%d) is wrong!\n", buf_size);
			"buf_size(%d) is wrong!\n", buf_size);
		goto unmap_base_addr;
		return -EINVAL;
	}
	}


	dsaf_dev->misc_op = hns_misc_op_get(dsaf_dev);
	dsaf_dev->misc_op = hns_misc_op_get(dsaf_dev);
@@ -213,32 +213,6 @@ int hns_dsaf_get_cfg(struct dsaf_device *dsaf_dev)
		dev_err(dsaf_dev->dev, "set mask to 64bit fail!\n");
		dev_err(dsaf_dev->dev, "set mask to 64bit fail!\n");


	return 0;
	return 0;

unmap_base_addr:
	if (dsaf_dev->io_base)
		iounmap(dsaf_dev->io_base);
	if (dsaf_dev->ppe_base)
		iounmap(dsaf_dev->ppe_base);
	if (dsaf_dev->sds_base)
		iounmap(dsaf_dev->sds_base);
	if (dsaf_dev->sc_base)
		iounmap(dsaf_dev->sc_base);
	return ret;
}

static void hns_dsaf_free_cfg(struct dsaf_device *dsaf_dev)
{
	if (dsaf_dev->io_base)
		iounmap(dsaf_dev->io_base);

	if (dsaf_dev->ppe_base)
		iounmap(dsaf_dev->ppe_base);

	if (dsaf_dev->sds_base)
		iounmap(dsaf_dev->sds_base);

	if (dsaf_dev->sc_base)
		iounmap(dsaf_dev->sc_base);
}
}


/**
/**
@@ -542,10 +516,10 @@ static void hns_dsafv2_sbm_bp_wl_cfg(struct dsaf_device *dsaf_dev)
		o_sbm_bp_cfg = dsaf_read_dev(dsaf_dev, reg);
		o_sbm_bp_cfg = dsaf_read_dev(dsaf_dev, reg);
		dsaf_set_field(o_sbm_bp_cfg,
		dsaf_set_field(o_sbm_bp_cfg,
			       DSAFV2_SBM_CFG3_SET_BUF_NUM_NO_PFC_M,
			       DSAFV2_SBM_CFG3_SET_BUF_NUM_NO_PFC_M,
			       DSAFV2_SBM_CFG3_SET_BUF_NUM_NO_PFC_S, 110);
			       DSAFV2_SBM_CFG3_SET_BUF_NUM_NO_PFC_S, 48);
		dsaf_set_field(o_sbm_bp_cfg,
		dsaf_set_field(o_sbm_bp_cfg,
			       DSAFV2_SBM_CFG3_RESET_BUF_NUM_NO_PFC_M,
			       DSAFV2_SBM_CFG3_RESET_BUF_NUM_NO_PFC_M,
			       DSAFV2_SBM_CFG3_RESET_BUF_NUM_NO_PFC_S, 160);
			       DSAFV2_SBM_CFG3_RESET_BUF_NUM_NO_PFC_S, 80);
		dsaf_write_dev(dsaf_dev, reg, o_sbm_bp_cfg);
		dsaf_write_dev(dsaf_dev, reg, o_sbm_bp_cfg);


		/* for no enable pfc mode */
		/* for no enable pfc mode */
@@ -553,29 +527,39 @@ static void hns_dsafv2_sbm_bp_wl_cfg(struct dsaf_device *dsaf_dev)
		o_sbm_bp_cfg = dsaf_read_dev(dsaf_dev, reg);
		o_sbm_bp_cfg = dsaf_read_dev(dsaf_dev, reg);
		dsaf_set_field(o_sbm_bp_cfg,
		dsaf_set_field(o_sbm_bp_cfg,
			       DSAFV2_SBM_CFG4_SET_BUF_NUM_NO_PFC_M,
			       DSAFV2_SBM_CFG4_SET_BUF_NUM_NO_PFC_M,
			       DSAFV2_SBM_CFG4_SET_BUF_NUM_NO_PFC_S, 128);
			       DSAFV2_SBM_CFG4_SET_BUF_NUM_NO_PFC_S, 192);
		dsaf_set_field(o_sbm_bp_cfg,
		dsaf_set_field(o_sbm_bp_cfg,
			       DSAFV2_SBM_CFG4_RESET_BUF_NUM_NO_PFC_M,
			       DSAFV2_SBM_CFG4_RESET_BUF_NUM_NO_PFC_M,
			       DSAFV2_SBM_CFG4_RESET_BUF_NUM_NO_PFC_S, 192);
			       DSAFV2_SBM_CFG4_RESET_BUF_NUM_NO_PFC_S, 240);
		dsaf_write_dev(dsaf_dev, reg, o_sbm_bp_cfg);
		dsaf_write_dev(dsaf_dev, reg, o_sbm_bp_cfg);
	}
	}


	/* PPE */
	/* PPE */
	for (i = 0; i < DSAFV2_SBM_PPE_CHN; i++) {
		reg = DSAF_SBM_BP_CFG_2_PPE_REG_0_REG + 0x80 * i;
		reg = DSAF_SBM_BP_CFG_2_PPE_REG_0_REG + 0x80 * i;
		o_sbm_bp_cfg = dsaf_read_dev(dsaf_dev, reg);
		o_sbm_bp_cfg = dsaf_read_dev(dsaf_dev, reg);
	dsaf_set_field(o_sbm_bp_cfg, DSAFV2_SBM_CFG2_SET_BUF_NUM_M,
		dsaf_set_field(o_sbm_bp_cfg,
		       DSAFV2_SBM_CFG2_SET_BUF_NUM_S, 10);
			       DSAFV2_SBM_CFG2_PPE_SET_BUF_NUM_M,
	dsaf_set_field(o_sbm_bp_cfg, DSAFV2_SBM_CFG2_RESET_BUF_NUM_M,
			       DSAFV2_SBM_CFG2_PPE_SET_BUF_NUM_S, 2);
		       DSAFV2_SBM_CFG2_RESET_BUF_NUM_S, 12);
		dsaf_set_field(o_sbm_bp_cfg,
			       DSAFV2_SBM_CFG2_PPE_RESET_BUF_NUM_M,
			       DSAFV2_SBM_CFG2_PPE_RESET_BUF_NUM_S, 3);
		dsaf_set_field(o_sbm_bp_cfg,
			       DSAFV2_SBM_CFG2_PPE_CFG_USEFUL_NUM_M,
			       DSAFV2_SBM_CFG2_PPE_CFG_USEFUL_NUM_S, 52);
		dsaf_write_dev(dsaf_dev, reg, o_sbm_bp_cfg);
		dsaf_write_dev(dsaf_dev, reg, o_sbm_bp_cfg);
	}

	/* RoCEE */
	/* RoCEE */
	for (i = 0; i < DASFV2_ROCEE_CRD_NUM; i++) {
	for (i = 0; i < DASFV2_ROCEE_CRD_NUM; i++) {
		reg = DSAFV2_SBM_BP_CFG_2_ROCEE_REG_0_REG + 0x80 * i;
		reg = DSAFV2_SBM_BP_CFG_2_ROCEE_REG_0_REG + 0x80 * i;
		o_sbm_bp_cfg = dsaf_read_dev(dsaf_dev, reg);
		o_sbm_bp_cfg = dsaf_read_dev(dsaf_dev, reg);
		dsaf_set_field(o_sbm_bp_cfg, DSAFV2_SBM_CFG2_SET_BUF_NUM_M,
		dsaf_set_field(o_sbm_bp_cfg,
			       DSAFV2_SBM_CFG2_SET_BUF_NUM_S, 2);
			       DSAFV2_SBM_CFG2_ROCEE_SET_BUF_NUM_M,
		dsaf_set_field(o_sbm_bp_cfg, DSAFV2_SBM_CFG2_RESET_BUF_NUM_M,
			       DSAFV2_SBM_CFG2_ROCEE_SET_BUF_NUM_S, 2);
			       DSAFV2_SBM_CFG2_RESET_BUF_NUM_S, 4);
		dsaf_set_field(o_sbm_bp_cfg,
			       DSAFV2_SBM_CFG2_ROCEE_RESET_BUF_NUM_M,
			       DSAFV2_SBM_CFG2_ROCEE_RESET_BUF_NUM_S, 4);
		dsaf_write_dev(dsaf_dev, reg, o_sbm_bp_cfg);
		dsaf_write_dev(dsaf_dev, reg, o_sbm_bp_cfg);
	}
	}
}
}
@@ -886,6 +870,8 @@ static void hns_dsaf_single_line_tbl_cfg(
	struct dsaf_device *dsaf_dev,
	struct dsaf_device *dsaf_dev,
	u32 address, struct dsaf_tbl_line_cfg *ptbl_line)
	u32 address, struct dsaf_tbl_line_cfg *ptbl_line)
{
{
	spin_lock_bh(&dsaf_dev->tcam_lock);

	/*Write Addr*/
	/*Write Addr*/
	hns_dsaf_tbl_line_addr_cfg(dsaf_dev, address);
	hns_dsaf_tbl_line_addr_cfg(dsaf_dev, address);


@@ -894,6 +880,8 @@ static void hns_dsaf_single_line_tbl_cfg(


	/*Write Plus*/
	/*Write Plus*/
	hns_dsaf_tbl_line_pul(dsaf_dev);
	hns_dsaf_tbl_line_pul(dsaf_dev);

	spin_unlock_bh(&dsaf_dev->tcam_lock);
}
}


/**
/**
@@ -907,6 +895,8 @@ static void hns_dsaf_tcam_uc_cfg(
	struct dsaf_tbl_tcam_data *ptbl_tcam_data,
	struct dsaf_tbl_tcam_data *ptbl_tcam_data,
	struct dsaf_tbl_tcam_ucast_cfg *ptbl_tcam_ucast)
	struct dsaf_tbl_tcam_ucast_cfg *ptbl_tcam_ucast)
{
{
	spin_lock_bh(&dsaf_dev->tcam_lock);

	/*Write Addr*/
	/*Write Addr*/
	hns_dsaf_tbl_tcam_addr_cfg(dsaf_dev, address);
	hns_dsaf_tbl_tcam_addr_cfg(dsaf_dev, address);
	/*Write Tcam Data*/
	/*Write Tcam Data*/
@@ -915,6 +905,8 @@ static void hns_dsaf_tcam_uc_cfg(
	hns_dsaf_tbl_tcam_ucast_cfg(dsaf_dev, ptbl_tcam_ucast);
	hns_dsaf_tbl_tcam_ucast_cfg(dsaf_dev, ptbl_tcam_ucast);
	/*Write Plus*/
	/*Write Plus*/
	hns_dsaf_tbl_tcam_data_ucast_pul(dsaf_dev);
	hns_dsaf_tbl_tcam_data_ucast_pul(dsaf_dev);

	spin_unlock_bh(&dsaf_dev->tcam_lock);
}
}


/**
/**
@@ -929,6 +921,8 @@ static void hns_dsaf_tcam_mc_cfg(
	struct dsaf_tbl_tcam_data *ptbl_tcam_data,
	struct dsaf_tbl_tcam_data *ptbl_tcam_data,
	struct dsaf_tbl_tcam_mcast_cfg *ptbl_tcam_mcast)
	struct dsaf_tbl_tcam_mcast_cfg *ptbl_tcam_mcast)
{
{
	spin_lock_bh(&dsaf_dev->tcam_lock);

	/*Write Addr*/
	/*Write Addr*/
	hns_dsaf_tbl_tcam_addr_cfg(dsaf_dev, address);
	hns_dsaf_tbl_tcam_addr_cfg(dsaf_dev, address);
	/*Write Tcam Data*/
	/*Write Tcam Data*/
@@ -937,6 +931,8 @@ static void hns_dsaf_tcam_mc_cfg(
	hns_dsaf_tbl_tcam_mcast_cfg(dsaf_dev, ptbl_tcam_mcast);
	hns_dsaf_tbl_tcam_mcast_cfg(dsaf_dev, ptbl_tcam_mcast);
	/*Write Plus*/
	/*Write Plus*/
	hns_dsaf_tbl_tcam_data_mcast_pul(dsaf_dev);
	hns_dsaf_tbl_tcam_data_mcast_pul(dsaf_dev);

	spin_unlock_bh(&dsaf_dev->tcam_lock);
}
}


/**
/**
@@ -946,6 +942,8 @@ static void hns_dsaf_tcam_mc_cfg(
 */
 */
static void hns_dsaf_tcam_mc_invld(struct dsaf_device *dsaf_dev, u32 address)
static void hns_dsaf_tcam_mc_invld(struct dsaf_device *dsaf_dev, u32 address)
{
{
	spin_lock_bh(&dsaf_dev->tcam_lock);

	/*Write Addr*/
	/*Write Addr*/
	hns_dsaf_tbl_tcam_addr_cfg(dsaf_dev, address);
	hns_dsaf_tbl_tcam_addr_cfg(dsaf_dev, address);


@@ -958,6 +956,8 @@ static void hns_dsaf_tcam_mc_invld(struct dsaf_device *dsaf_dev, u32 address)


	/*Write Plus*/
	/*Write Plus*/
	hns_dsaf_tbl_tcam_mcast_pul(dsaf_dev);
	hns_dsaf_tbl_tcam_mcast_pul(dsaf_dev);

	spin_unlock_bh(&dsaf_dev->tcam_lock);
}
}


/**
/**
@@ -975,6 +975,8 @@ static void hns_dsaf_tcam_uc_get(
	u32 tcam_read_data0;
	u32 tcam_read_data0;
	u32 tcam_read_data4;
	u32 tcam_read_data4;


	spin_lock_bh(&dsaf_dev->tcam_lock);

	/*Write Addr*/
	/*Write Addr*/
	hns_dsaf_tbl_tcam_addr_cfg(dsaf_dev, address);
	hns_dsaf_tbl_tcam_addr_cfg(dsaf_dev, address);


@@ -983,9 +985,9 @@ static void hns_dsaf_tcam_uc_get(


	/*read tcam data*/
	/*read tcam data*/
	ptbl_tcam_data->tbl_tcam_data_high
	ptbl_tcam_data->tbl_tcam_data_high
		= dsaf_read_dev(dsaf_dev, DSAF_TBL_TCAM_RDATA_LOW_0_REG);
	ptbl_tcam_data->tbl_tcam_data_low
		= dsaf_read_dev(dsaf_dev, DSAF_TBL_TCAM_RDATA_HIGH_0_REG);
		= dsaf_read_dev(dsaf_dev, DSAF_TBL_TCAM_RDATA_HIGH_0_REG);
	ptbl_tcam_data->tbl_tcam_data_low
		= dsaf_read_dev(dsaf_dev, DSAF_TBL_TCAM_RDATA_LOW_0_REG);


	/*read tcam mcast*/
	/*read tcam mcast*/
	tcam_read_data0 = dsaf_read_dev(dsaf_dev,
	tcam_read_data0 = dsaf_read_dev(dsaf_dev,
@@ -1007,6 +1009,8 @@ static void hns_dsaf_tcam_uc_get(
				 DSAF_TBL_UCAST_CFG1_OUT_PORT_S);
				 DSAF_TBL_UCAST_CFG1_OUT_PORT_S);
	ptbl_tcam_ucast->tbl_ucast_dvc
	ptbl_tcam_ucast->tbl_ucast_dvc
		= dsaf_get_bit(tcam_read_data0, DSAF_TBL_UCAST_CFG1_DVC_S);
		= dsaf_get_bit(tcam_read_data0, DSAF_TBL_UCAST_CFG1_DVC_S);

	spin_unlock_bh(&dsaf_dev->tcam_lock);
}
}


/**
/**
@@ -1023,6 +1027,8 @@ static void hns_dsaf_tcam_mc_get(
{
{
	u32 data_tmp;
	u32 data_tmp;


	spin_lock_bh(&dsaf_dev->tcam_lock);

	/*Write Addr*/
	/*Write Addr*/
	hns_dsaf_tbl_tcam_addr_cfg(dsaf_dev, address);
	hns_dsaf_tbl_tcam_addr_cfg(dsaf_dev, address);


@@ -1031,9 +1037,9 @@ static void hns_dsaf_tcam_mc_get(


	/*read tcam data*/
	/*read tcam data*/
	ptbl_tcam_data->tbl_tcam_data_high =
	ptbl_tcam_data->tbl_tcam_data_high =
		dsaf_read_dev(dsaf_dev, DSAF_TBL_TCAM_RDATA_LOW_0_REG);
	ptbl_tcam_data->tbl_tcam_data_low =
		dsaf_read_dev(dsaf_dev, DSAF_TBL_TCAM_RDATA_HIGH_0_REG);
		dsaf_read_dev(dsaf_dev, DSAF_TBL_TCAM_RDATA_HIGH_0_REG);
	ptbl_tcam_data->tbl_tcam_data_low =
		dsaf_read_dev(dsaf_dev, DSAF_TBL_TCAM_RDATA_LOW_0_REG);


	/*read tcam mcast*/
	/*read tcam mcast*/
	ptbl_tcam_mcast->tbl_mcast_port_msk[0] =
	ptbl_tcam_mcast->tbl_mcast_port_msk[0] =
@@ -1053,6 +1059,8 @@ static void hns_dsaf_tcam_mc_get(
	ptbl_tcam_mcast->tbl_mcast_port_msk[4] =
	ptbl_tcam_mcast->tbl_mcast_port_msk[4] =
		dsaf_get_field(data_tmp, DSAF_TBL_MCAST_CFG4_VM128_112_M,
		dsaf_get_field(data_tmp, DSAF_TBL_MCAST_CFG4_VM128_112_M,
			       DSAF_TBL_MCAST_CFG4_VM128_112_S);
			       DSAF_TBL_MCAST_CFG4_VM128_112_S);

	spin_unlock_bh(&dsaf_dev->tcam_lock);
}
}


/**
/**
@@ -1114,11 +1122,11 @@ int hns_dsaf_set_rx_mac_pause_en(struct dsaf_device *dsaf_dev, int mac_id,
				 u32 en)
				 u32 en)
{
{
	if (AE_IS_VER1(dsaf_dev->dsaf_ver)) {
	if (AE_IS_VER1(dsaf_dev->dsaf_ver)) {
		if (!en)
		if (!en) {
			dev_err(dsaf_dev->dev, "dsafv1 can't close rx_pause!\n");
			dev_err(dsaf_dev->dev, "dsafv1 can't close rx_pause!\n");

			return -EINVAL;
			return -EINVAL;
		}
		}
	}


	dsaf_set_dev_bit(dsaf_dev, DSAF_PAUSE_CFG_REG + mac_id * 4,
	dsaf_set_dev_bit(dsaf_dev, DSAF_PAUSE_CFG_REG + mac_id * 4,
			 DSAF_MAC_PAUSE_RX_EN_B, !!en);
			 DSAF_MAC_PAUSE_RX_EN_B, !!en);
@@ -1377,6 +1385,7 @@ static int hns_dsaf_init(struct dsaf_device *dsaf_dev)
	if (HNS_DSAF_IS_DEBUG(dsaf_dev))
	if (HNS_DSAF_IS_DEBUG(dsaf_dev))
		return 0;
		return 0;


	spin_lock_init(&dsaf_dev->tcam_lock);
	ret = hns_dsaf_init_hw(dsaf_dev);
	ret = hns_dsaf_init_hw(dsaf_dev);
	if (ret)
	if (ret)
		return ret;
		return ret;
@@ -2122,11 +2131,24 @@ void hns_dsaf_fix_mac_mode(struct hns_mac_cb *mac_cb)
	hns_dsaf_port_work_rate_cfg(dsaf_dev, mac_id, mode);
	hns_dsaf_port_work_rate_cfg(dsaf_dev, mac_id, mode);
}
}


static u32 hns_dsaf_get_inode_prio_reg(int index)
{
	int base_index, offset;
	u32 base_addr = DSAF_INODE_IN_PRIO_PAUSE_BASE_REG;

	base_index = (index + 1) / DSAF_REG_PER_ZONE;
	offset = (index + 1) % DSAF_REG_PER_ZONE;

	return base_addr + DSAF_INODE_IN_PRIO_PAUSE_BASE_OFFSET * base_index +
		DSAF_INODE_IN_PRIO_PAUSE_OFFSET * offset;
}

void hns_dsaf_update_stats(struct dsaf_device *dsaf_dev, u32 node_num)
void hns_dsaf_update_stats(struct dsaf_device *dsaf_dev, u32 node_num)
{
{
	struct dsaf_hw_stats *hw_stats
	struct dsaf_hw_stats *hw_stats
		= &dsaf_dev->hw_stats[node_num];
		= &dsaf_dev->hw_stats[node_num];
	bool is_ver1 = AE_IS_VER1(dsaf_dev->dsaf_ver);
	bool is_ver1 = AE_IS_VER1(dsaf_dev->dsaf_ver);
	int i;
	u32 reg_tmp;
	u32 reg_tmp;


	hw_stats->pad_drop += dsaf_read_dev(dsaf_dev,
	hw_stats->pad_drop += dsaf_read_dev(dsaf_dev,
@@ -2161,6 +2183,18 @@ void hns_dsaf_update_stats(struct dsaf_device *dsaf_dev, u32 node_num)
	hw_stats->stp_drop += dsaf_read_dev(dsaf_dev,
	hw_stats->stp_drop += dsaf_read_dev(dsaf_dev,
		DSAF_INODE_IN_DATA_STP_DISC_0_REG + 0x80 * (u64)node_num);
		DSAF_INODE_IN_DATA_STP_DISC_0_REG + 0x80 * (u64)node_num);


	/* pfc pause frame statistics stored in dsaf inode*/
	if ((node_num < DSAF_SERVICE_NW_NUM) && !is_ver1) {
		for (i = 0; i < DSAF_PRIO_NR; i++) {
			reg_tmp = hns_dsaf_get_inode_prio_reg(i);
			hw_stats->rx_pfc[i] += dsaf_read_dev(dsaf_dev,
				reg_tmp + 0x4 * (u64)node_num);
			hw_stats->tx_pfc[i] += dsaf_read_dev(dsaf_dev,
				DSAF_XOD_XGE_PFC_PRIO_CNT_BASE_REG +
				DSAF_XOD_XGE_PFC_PRIO_CNT_OFFSET * i +
				0xF0 * (u64)node_num);
		}
	}
	hw_stats->tx_pkts += dsaf_read_dev(dsaf_dev,
	hw_stats->tx_pkts += dsaf_read_dev(dsaf_dev,
		DSAF_XOD_RCVPKT_CNT_0_REG + 0x90 * (u64)node_num);
		DSAF_XOD_RCVPKT_CNT_0_REG + 0x90 * (u64)node_num);
}
}
@@ -2498,9 +2532,12 @@ void hns_dsaf_get_regs(struct dsaf_device *ddev, u32 port, void *data)
		p[i] = 0xdddddddd;
		p[i] = 0xdddddddd;
}
}


static char *hns_dsaf_get_node_stats_strings(char *data, int node)
static char *hns_dsaf_get_node_stats_strings(char *data, int node,
					     struct dsaf_device *dsaf_dev)
{
{
	char *buff = data;
	char *buff = data;
	int i;
	bool is_ver1 = AE_IS_VER1(dsaf_dev->dsaf_ver);


	snprintf(buff, ETH_GSTRING_LEN, "innod%d_pad_drop_pkts", node);
	snprintf(buff, ETH_GSTRING_LEN, "innod%d_pad_drop_pkts", node);
	buff = buff + ETH_GSTRING_LEN;
	buff = buff + ETH_GSTRING_LEN;
@@ -2528,6 +2565,18 @@ static char *hns_dsaf_get_node_stats_strings(char *data, int node)
	buff = buff + ETH_GSTRING_LEN;
	buff = buff + ETH_GSTRING_LEN;
	snprintf(buff, ETH_GSTRING_LEN, "innod%d_stp_drop_pkts", node);
	snprintf(buff, ETH_GSTRING_LEN, "innod%d_stp_drop_pkts", node);
	buff = buff + ETH_GSTRING_LEN;
	buff = buff + ETH_GSTRING_LEN;
	if ((node < DSAF_SERVICE_NW_NUM) && (!is_ver1)) {
		for (i = 0; i < DSAF_PRIO_NR; i++) {
			snprintf(buff, ETH_GSTRING_LEN,
				 "inod%d_pfc_prio%d_pkts", node, i);
			buff = buff + ETH_GSTRING_LEN;
		}
		for (i = 0; i < DSAF_PRIO_NR; i++) {
			snprintf(buff, ETH_GSTRING_LEN,
				 "onod%d_pfc_prio%d_pkts", node, i);
			buff = buff + ETH_GSTRING_LEN;
		}
	}
	snprintf(buff, ETH_GSTRING_LEN, "onnod%d_tx_pkts", node);
	snprintf(buff, ETH_GSTRING_LEN, "onnod%d_tx_pkts", node);
	buff = buff + ETH_GSTRING_LEN;
	buff = buff + ETH_GSTRING_LEN;


@@ -2538,7 +2587,9 @@ static u64 *hns_dsaf_get_node_stats(struct dsaf_device *ddev, u64 *data,
				    int node_num)
				    int node_num)
{
{
	u64 *p = data;
	u64 *p = data;
	int i;
	struct dsaf_hw_stats *hw_stats = &ddev->hw_stats[node_num];
	struct dsaf_hw_stats *hw_stats = &ddev->hw_stats[node_num];
	bool is_ver1 = AE_IS_VER1(ddev->dsaf_ver);


	p[0] = hw_stats->pad_drop;
	p[0] = hw_stats->pad_drop;
	p[1] = hw_stats->man_pkts;
	p[1] = hw_stats->man_pkts;
@@ -2553,8 +2604,16 @@ static u64 *hns_dsaf_get_node_stats(struct dsaf_device *ddev, u64 *data,
	p[10] = hw_stats->local_addr_false;
	p[10] = hw_stats->local_addr_false;
	p[11] = hw_stats->vlan_drop;
	p[11] = hw_stats->vlan_drop;
	p[12] = hw_stats->stp_drop;
	p[12] = hw_stats->stp_drop;
	p[13] = hw_stats->tx_pkts;
	if ((node_num < DSAF_SERVICE_NW_NUM) && (!is_ver1)) {
		for (i = 0; i < DSAF_PRIO_NR; i++) {
			p[13 + i] = hw_stats->rx_pfc[i];
			p[13 + i + DSAF_PRIO_NR] = hw_stats->tx_pfc[i];
		}
		p[29] = hw_stats->tx_pkts;
		return &p[30];
	}


	p[13] = hw_stats->tx_pkts;
	return &p[14];
	return &p[14];
}
}


@@ -2582,11 +2641,16 @@ void hns_dsaf_get_stats(struct dsaf_device *ddev, u64 *data, int port)
 *@stringset: type of values in data
 *@stringset: type of values in data
 *return dsaf string name count
 *return dsaf string name count
 */
 */
int hns_dsaf_get_sset_count(int stringset)
int hns_dsaf_get_sset_count(struct dsaf_device *dsaf_dev, int stringset)
{
{
	if (stringset == ETH_SS_STATS)
	bool is_ver1 = AE_IS_VER1(dsaf_dev->dsaf_ver);
		return DSAF_STATIC_NUM;


	if (stringset == ETH_SS_STATS) {
		if (is_ver1)
			return DSAF_STATIC_NUM;
		else
			return DSAF_V2_STATIC_NUM;
	}
	return 0;
	return 0;
}
}


@@ -2596,7 +2660,8 @@ int hns_dsaf_get_sset_count(int stringset)
 *@data:strings name value
 *@data:strings name value
 *@port:port index
 *@port:port index
 */
 */
void hns_dsaf_get_strings(int stringset, u8 *data, int port)
void hns_dsaf_get_strings(int stringset, u8 *data, int port,
			  struct dsaf_device *dsaf_dev)
{
{
	char *buff = (char *)data;
	char *buff = (char *)data;
	int node = port;
	int node = port;
@@ -2605,11 +2670,11 @@ void hns_dsaf_get_strings(int stringset, u8 *data, int port)
		return;
		return;


	/* for ge/xge node info */
	/* for ge/xge node info */
	buff = hns_dsaf_get_node_stats_strings(buff, node);
	buff = hns_dsaf_get_node_stats_strings(buff, node, dsaf_dev);


	/* for ppe node info */
	/* for ppe node info */
	node = port + DSAF_PPE_INODE_BASE;
	node = port + DSAF_PPE_INODE_BASE;
	(void)hns_dsaf_get_node_stats_strings(buff, node);
	(void)hns_dsaf_get_node_stats_strings(buff, node, dsaf_dev);
}
}


/**
/**
@@ -2645,7 +2710,7 @@ static int hns_dsaf_probe(struct platform_device *pdev)


	ret = hns_dsaf_init(dsaf_dev);
	ret = hns_dsaf_init(dsaf_dev);
	if (ret)
	if (ret)
		goto free_cfg;
		goto free_dev;


	ret = hns_mac_init(dsaf_dev);
	ret = hns_mac_init(dsaf_dev);
	if (ret)
	if (ret)
@@ -2670,9 +2735,6 @@ static int hns_dsaf_probe(struct platform_device *pdev)
uninit_dsaf:
uninit_dsaf:
	hns_dsaf_free(dsaf_dev);
	hns_dsaf_free(dsaf_dev);


free_cfg:
	hns_dsaf_free_cfg(dsaf_dev);

free_dev:
free_dev:
	hns_dsaf_free_dev(dsaf_dev);
	hns_dsaf_free_dev(dsaf_dev);


@@ -2695,8 +2757,6 @@ static int hns_dsaf_remove(struct platform_device *pdev)


	hns_dsaf_free(dsaf_dev);
	hns_dsaf_free(dsaf_dev);


	hns_dsaf_free_cfg(dsaf_dev);

	hns_dsaf_free_dev(dsaf_dev);
	hns_dsaf_free_dev(dsaf_dev);


	return 0;
	return 0;
+10 −2
Original line number Original line Diff line number Diff line
@@ -39,6 +39,9 @@ struct hns_mac_cb;


#define DSAF_DUMP_REGS_NUM 504
#define DSAF_DUMP_REGS_NUM 504
#define DSAF_STATIC_NUM 28
#define DSAF_STATIC_NUM 28
#define DSAF_V2_STATIC_NUM	44
#define DSAF_PRIO_NR	8
#define DSAF_REG_PER_ZONE	3


#define DSAF_STATS_READ(p, offset) (*((u64 *)((u8 *)(p) + (offset))))
#define DSAF_STATS_READ(p, offset) (*((u64 *)((u8 *)(p) + (offset))))
#define HNS_DSAF_IS_DEBUG(dev) (dev->dsaf_mode == DSAF_MODE_DISABLE_SP)
#define HNS_DSAF_IS_DEBUG(dev) (dev->dsaf_mode == DSAF_MODE_DISABLE_SP)
@@ -176,6 +179,8 @@ struct dsaf_hw_stats {
	u64 local_addr_false;
	u64 local_addr_false;
	u64 vlan_drop;
	u64 vlan_drop;
	u64 stp_drop;
	u64 stp_drop;
	u64 rx_pfc[DSAF_PRIO_NR];
	u64 tx_pfc[DSAF_PRIO_NR];
	u64 tx_pkts;
	u64 tx_pkts;
};
};


@@ -317,6 +322,8 @@ struct dsaf_device {


	struct dsaf_hw_stats hw_stats[DSAF_NODE_NUM];
	struct dsaf_hw_stats hw_stats[DSAF_NODE_NUM];
	struct dsaf_int_stat int_stat;
	struct dsaf_int_stat int_stat;
	/* make sure tcam table config spinlock */
	spinlock_t tcam_lock;
};
};


static inline void *hns_dsaf_dev_priv(const struct dsaf_device *dsaf_dev)
static inline void *hns_dsaf_dev_priv(const struct dsaf_device *dsaf_dev)
@@ -417,9 +424,10 @@ void hns_dsaf_ae_uninit(struct dsaf_device *dsaf_dev);


void hns_dsaf_update_stats(struct dsaf_device *dsaf_dev, u32 inode_num);
void hns_dsaf_update_stats(struct dsaf_device *dsaf_dev, u32 inode_num);


int hns_dsaf_get_sset_count(int stringset);
int hns_dsaf_get_sset_count(struct dsaf_device *dsaf_dev, int stringset);
void hns_dsaf_get_stats(struct dsaf_device *ddev, u64 *data, int port);
void hns_dsaf_get_stats(struct dsaf_device *ddev, u64 *data, int port);
void hns_dsaf_get_strings(int stringset, u8 *data, int port);
void hns_dsaf_get_strings(int stringset, u8 *data, int port,
			  struct dsaf_device *dsaf_dev);


void hns_dsaf_get_regs(struct dsaf_device *ddev, u32 port, void *data);
void hns_dsaf_get_regs(struct dsaf_device *ddev, u32 port, void *data);
int hns_dsaf_get_regs_count(void);
int hns_dsaf_get_regs_count(void);
Loading