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

Commit 47b62cd8 authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'net-hns-bugfixes-for-HNS-Driver'



Yonglong Liu says:

====================
net: hns: bugfixes for HNS Driver

This patchset fix some bugs that were found in the test of
various scenarios, or identify by KASAN/sparse.
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents ef0efcd3 15400663
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -150,7 +150,6 @@ static int hnae_alloc_buffers(struct hnae_ring *ring)
/* free desc along with its attached buffer */
static void hnae_free_desc(struct hnae_ring *ring)
{
	hnae_free_buffers(ring);
	dma_unmap_single(ring_to_dev(ring), ring->desc_dma_addr,
			 ring->desc_num * sizeof(ring->desc[0]),
			 ring_to_dma_dir(ring));
@@ -183,6 +182,9 @@ static int hnae_alloc_desc(struct hnae_ring *ring)
/* fini ring, also free the buffer for the ring */
static void hnae_fini_ring(struct hnae_ring *ring)
{
	if (is_rx_ring(ring))
		hnae_free_buffers(ring);

	hnae_free_desc(ring);
	kfree(ring->desc_cb);
	ring->desc_cb = NULL;
+1 −1
Original line number Diff line number Diff line
@@ -357,7 +357,7 @@ struct hnae_buf_ops {
};

struct hnae_queue {
	void __iomem *io_base;
	u8 __iomem *io_base;
	phys_addr_t phy_base;
	struct hnae_ae_dev *dev;	/* the device who use this queue */
	struct hnae_ring rx_ring ____cacheline_internodealigned_in_smp;
+1 −1
Original line number Diff line number Diff line
@@ -370,7 +370,7 @@ int hns_mac_clr_multicast(struct hns_mac_cb *mac_cb, int vfn)
static void hns_mac_param_get(struct mac_params *param,
			      struct hns_mac_cb *mac_cb)
{
	param->vaddr = (void *)mac_cb->vaddr;
	param->vaddr = mac_cb->vaddr;
	param->mac_mode = hns_get_enet_interface(mac_cb);
	ether_addr_copy(param->addr, mac_cb->addr_entry_idx[0].addr);
	param->mac_id = mac_cb->mac_id;
+2 −2
Original line number Diff line number Diff line
@@ -187,7 +187,7 @@ struct mac_statistics {
/*mac para struct ,mac get param from nic or dsaf when initialize*/
struct mac_params {
	char addr[ETH_ALEN];
	void *vaddr; /*virtual address*/
	u8 __iomem *vaddr; /*virtual address*/
	struct device *dev;
	u8 mac_id;
	/**< Ethernet operation mode (MAC-PHY interface and speed) */
@@ -402,7 +402,7 @@ struct mac_driver {
	enum mac_mode mac_mode;
	u8 mac_id;
	struct hns_mac_cb *mac_cb;
	void __iomem *io_base;
	u8 __iomem *io_base;
	unsigned int mac_en_flg;/*you'd better don't enable mac twice*/
	unsigned int virt_dev_num;
	struct device *dev;
+33 −20
Original line number Diff line number Diff line
@@ -1602,8 +1602,6 @@ static void hns_dsaf_set_mac_key(
		       DSAF_TBL_TCAM_KEY_VLAN_S, vlan_id);
	dsaf_set_field(mac_key->low.bits.port_vlan, DSAF_TBL_TCAM_KEY_PORT_M,
		       DSAF_TBL_TCAM_KEY_PORT_S, port);

	mac_key->low.bits.port_vlan = le16_to_cpu(mac_key->low.bits.port_vlan);
}

/**
@@ -1663,8 +1661,8 @@ int hns_dsaf_set_mac_uc_entry(
	/* default config dvc to 0 */
	mac_data.tbl_ucast_dvc = 0;
	mac_data.tbl_ucast_out_port = mac_entry->port_num;
	tcam_data.tbl_tcam_data_high = cpu_to_le32(mac_key.high.val);
	tcam_data.tbl_tcam_data_low = cpu_to_le32(mac_key.low.val);
	tcam_data.tbl_tcam_data_high = mac_key.high.val;
	tcam_data.tbl_tcam_data_low = mac_key.low.val;

	hns_dsaf_tcam_uc_cfg(dsaf_dev, entry_index, &tcam_data, &mac_data);

@@ -1786,9 +1784,6 @@ int hns_dsaf_add_mac_mc_port(struct dsaf_device *dsaf_dev,
				     0xff,
				     mc_mask);

		mask_key.high.val = le32_to_cpu(mask_key.high.val);
		mask_key.low.val = le32_to_cpu(mask_key.low.val);

		pmask_key = (struct dsaf_tbl_tcam_data *)(&mask_key);
	}

@@ -1840,8 +1835,8 @@ int hns_dsaf_add_mac_mc_port(struct dsaf_device *dsaf_dev,
		dsaf_dev->ae_dev.name, mac_key.high.val,
		mac_key.low.val, entry_index);

	tcam_data.tbl_tcam_data_high = cpu_to_le32(mac_key.high.val);
	tcam_data.tbl_tcam_data_low = cpu_to_le32(mac_key.low.val);
	tcam_data.tbl_tcam_data_high = mac_key.high.val;
	tcam_data.tbl_tcam_data_low = mac_key.low.val;

	/* config mc entry with mask */
	hns_dsaf_tcam_mc_cfg(dsaf_dev, entry_index, &tcam_data,
@@ -1956,9 +1951,6 @@ int hns_dsaf_del_mac_mc_port(struct dsaf_device *dsaf_dev,
		/* config key mask */
		hns_dsaf_set_mac_key(dsaf_dev, &mask_key, 0x00, 0xff, mc_mask);

		mask_key.high.val = le32_to_cpu(mask_key.high.val);
		mask_key.low.val = le32_to_cpu(mask_key.low.val);

		pmask_key = (struct dsaf_tbl_tcam_data *)(&mask_key);
	}

@@ -2012,8 +2004,8 @@ int hns_dsaf_del_mac_mc_port(struct dsaf_device *dsaf_dev,
		soft_mac_entry += entry_index;
		soft_mac_entry->index = DSAF_INVALID_ENTRY_IDX;
	} else { /* not zero, just del port, update */
		tcam_data.tbl_tcam_data_high = cpu_to_le32(mac_key.high.val);
		tcam_data.tbl_tcam_data_low = cpu_to_le32(mac_key.low.val);
		tcam_data.tbl_tcam_data_high = mac_key.high.val;
		tcam_data.tbl_tcam_data_low = mac_key.low.val;

		hns_dsaf_tcam_mc_cfg(dsaf_dev, entry_index,
				     &tcam_data,
@@ -2750,6 +2742,17 @@ int hns_dsaf_get_regs_count(void)
	return DSAF_DUMP_REGS_NUM;
}

static int hns_dsaf_get_port_id(u8 port)
{
	if (port < DSAF_SERVICE_NW_NUM)
		return port;

	if (port >= DSAF_BASE_INNER_PORT_NUM)
		return port - DSAF_BASE_INNER_PORT_NUM + DSAF_SERVICE_NW_NUM;

	return -EINVAL;
}

static void set_promisc_tcam_enable(struct dsaf_device *dsaf_dev, u32 port)
{
	struct dsaf_tbl_tcam_ucast_cfg tbl_tcam_ucast = {0, 1, 0, 0, 0x80};
@@ -2815,23 +2818,33 @@ static void set_promisc_tcam_enable(struct dsaf_device *dsaf_dev, u32 port)
	memset(&temp_key, 0x0, sizeof(temp_key));
	mask_entry.addr[0] = 0x01;
	hns_dsaf_set_mac_key(dsaf_dev, &mask_key, mask_entry.in_vlan_id,
			     port, mask_entry.addr);
			     0xf, mask_entry.addr);
	tbl_tcam_mcast.tbl_mcast_item_vld = 1;
	tbl_tcam_mcast.tbl_mcast_old_en = 0;

	if (port < DSAF_SERVICE_NW_NUM) {
		mskid = port;
	} else if (port >= DSAF_BASE_INNER_PORT_NUM) {
		mskid = port - DSAF_BASE_INNER_PORT_NUM + DSAF_SERVICE_NW_NUM;
	} else {
	/* set MAC port to handle multicast */
	mskid = hns_dsaf_get_port_id(port);
	if (mskid == -EINVAL) {
		dev_err(dsaf_dev->dev, "%s,pnum(%d)error,key(%#x:%#x)\n",
			dsaf_dev->ae_dev.name, port,
			mask_key.high.val, mask_key.low.val);
		return;
	}
	dsaf_set_bit(tbl_tcam_mcast.tbl_mcast_port_msk[mskid / 32],
		     mskid % 32, 1);

	/* set pool bit map to handle multicast */
	mskid = hns_dsaf_get_port_id(port_num);
	if (mskid == -EINVAL) {
		dev_err(dsaf_dev->dev,
			"%s, pool bit map pnum(%d)error,key(%#x:%#x)\n",
			dsaf_dev->ae_dev.name, port_num,
			mask_key.high.val, mask_key.low.val);
		return;
	}
	dsaf_set_bit(tbl_tcam_mcast.tbl_mcast_port_msk[mskid / 32],
		     mskid % 32, 1);

	memcpy(&temp_key, &mask_key, sizeof(mask_key));
	hns_dsaf_tcam_mc_cfg_vague(dsaf_dev, entry_index, &tbl_tcam_data_mc,
				   (struct dsaf_tbl_tcam_data *)(&mask_key),
Loading