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

Commit 4f4b93a8 authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'hns3-next'



Salil Mehta says:

====================
Bug fixes, snall modifications & cleanup for HNS3 driver

This patch presents some bug fixes, small modifications and cleanups
to the HNS3 VF and PF driver.
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents b1589924 ebfefb8a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -107,6 +107,7 @@ enum hnae3_media_type {
	HNAE3_MEDIA_TYPE_FIBER,
	HNAE3_MEDIA_TYPE_COPPER,
	HNAE3_MEDIA_TYPE_BACKPLANE,
	HNAE3_MEDIA_TYPE_NONE,
};

enum hnae3_reset_notify_type {
@@ -410,7 +411,6 @@ struct hnae3_ae_ops {
	void (*get_link_mode)(struct hnae3_handle *handle,
			      unsigned long *supported,
			      unsigned long *advertising);
	void (*get_port_type)(struct hnae3_handle *handle, u8 *port_type);
};

struct hnae3_dcb_ops {
+6 −7
Original line number Diff line number Diff line
@@ -1807,7 +1807,7 @@ static int hns3_map_buffer(struct hns3_enet_ring *ring, struct hns3_desc_cb *cb)
	cb->dma = dma_map_page(ring_to_dev(ring), cb->priv, 0,
			       cb->length, ring_to_dma_dir(ring));

	if (dma_mapping_error(ring_to_dev(ring), cb->dma))
	if (unlikely(dma_mapping_error(ring_to_dev(ring), cb->dma)))
		return -EIO;

	return 0;
@@ -1973,6 +1973,7 @@ static int is_valid_clean_head(struct hns3_enet_ring *ring, int h)
void hns3_clean_tx_ring(struct hns3_enet_ring *ring)
{
	struct net_device *netdev = ring->tqp->handle->kinfo.netdev;
	struct hns3_nic_priv *priv = netdev_priv(netdev);
	struct netdev_queue *dev_queue;
	int bytes, pkts;
	int head;
@@ -2018,7 +2019,8 @@ void hns3_clean_tx_ring(struct hns3_enet_ring *ring)
		 * sees the new next_to_clean.
		 */
		smp_mb();
		if (netif_tx_queue_stopped(dev_queue)) {
		if (netif_tx_queue_stopped(dev_queue) &&
		    !test_bit(HNS3_NIC_STATE_DOWN, &priv->state)) {
			netif_tx_wake_queue(dev_queue);
			ring->stats.restart_queue++;
		}
@@ -2147,7 +2149,6 @@ static void hns3_rx_checksum(struct hns3_enet_ring *ring, struct sk_buff *skb,
		     hnae3_get_bit(l234info, HNS3_RXD_L4E_B) ||
		     hnae3_get_bit(l234info, HNS3_RXD_OL3E_B) ||
		     hnae3_get_bit(l234info, HNS3_RXD_OL4E_B))) {
		netdev_err(netdev, "L3/L4 error pkt\n");
		u64_stats_update_begin(&ring->syncp);
		ring->stats.l3l4_csum_err++;
		u64_stats_update_end(&ring->syncp);
@@ -2176,6 +2177,8 @@ static void hns3_rx_checksum(struct hns3_enet_ring *ring, struct sk_buff *skb,
		     l4_type == HNS3_L4_TYPE_SCTP))
			skb->ip_summed = CHECKSUM_UNNECESSARY;
		break;
	default:
		break;
	}
}

@@ -2324,8 +2327,6 @@ static int hns3_handle_rx_bd(struct hns3_enet_ring *ring,
	}

	if (unlikely(!hnae3_get_bit(bd_base_info, HNS3_RXD_VLD_B))) {
		netdev_err(netdev, "no valid bd,%016llx,%016llx\n",
			   ((u64 *)desc)[0], ((u64 *)desc)[1]);
		u64_stats_update_begin(&ring->syncp);
		ring->stats.non_vld_descs++;
		u64_stats_update_end(&ring->syncp);
@@ -2336,7 +2337,6 @@ static int hns3_handle_rx_bd(struct hns3_enet_ring *ring,

	if (unlikely((!desc->rx.pkt_len) ||
		     hnae3_get_bit(l234info, HNS3_RXD_TRUNCAT_B))) {
		netdev_err(netdev, "truncated pkt\n");
		u64_stats_update_begin(&ring->syncp);
		ring->stats.err_pkt_len++;
		u64_stats_update_end(&ring->syncp);
@@ -2346,7 +2346,6 @@ static int hns3_handle_rx_bd(struct hns3_enet_ring *ring,
	}

	if (unlikely(hnae3_get_bit(l234info, HNS3_RXD_L2E_B))) {
		netdev_err(netdev, "L2 error pkt\n");
		u64_stats_update_begin(&ring->syncp);
		ring->stats.l2_err++;
		u64_stats_update_end(&ring->syncp);
+49 −34
Original line number Diff line number Diff line
@@ -22,13 +22,13 @@ struct hns3_stats {
static const struct hns3_stats hns3_txq_stats[] = {
	/* Tx per-queue statistics */
	HNS3_TQP_STAT("io_err_cnt", io_err_cnt),
	HNS3_TQP_STAT("tx_dropped", sw_err_cnt),
	HNS3_TQP_STAT("dropped", sw_err_cnt),
	HNS3_TQP_STAT("seg_pkt_cnt", seg_pkt_cnt),
	HNS3_TQP_STAT("packets", tx_pkts),
	HNS3_TQP_STAT("bytes", tx_bytes),
	HNS3_TQP_STAT("errors", tx_err_cnt),
	HNS3_TQP_STAT("tx_wake", restart_queue),
	HNS3_TQP_STAT("tx_busy", tx_busy),
	HNS3_TQP_STAT("wake", restart_queue),
	HNS3_TQP_STAT("busy", tx_busy),
};

#define HNS3_TXQ_STATS_COUNT ARRAY_SIZE(hns3_txq_stats)
@@ -36,7 +36,7 @@ static const struct hns3_stats hns3_txq_stats[] = {
static const struct hns3_stats hns3_rxq_stats[] = {
	/* Rx per-queue statistics */
	HNS3_TQP_STAT("io_err_cnt", io_err_cnt),
	HNS3_TQP_STAT("rx_dropped", sw_err_cnt),
	HNS3_TQP_STAT("dropped", sw_err_cnt),
	HNS3_TQP_STAT("seg_pkt_cnt", seg_pkt_cnt),
	HNS3_TQP_STAT("packets", rx_pkts),
	HNS3_TQP_STAT("bytes", rx_bytes),
@@ -351,9 +351,10 @@ static int hns3_get_sset_count(struct net_device *netdev, int stringset)

	case ETH_SS_TEST:
		return ops->get_sset_count(h, stringset);
	}

	return 0;
	default:
		return -EOPNOTSUPP;
	}
}

static void *hns3_update_strings(u8 *data, const struct hns3_stats *stats,
@@ -369,7 +370,7 @@ static void *hns3_update_strings(u8 *data, const struct hns3_stats *stats,
			data[ETH_GSTRING_LEN - 1] = '\0';

			/* first, prepend the prefix string */
			n1 = snprintf(data, MAX_PREFIX_SIZE, "%s#%d_",
			n1 = snprintf(data, MAX_PREFIX_SIZE, "%s%d_",
				      prefix, i);
			n1 = min_t(uint, n1, MAX_PREFIX_SIZE - 1);
			size_left = (ETH_GSTRING_LEN - 1) - n1;
@@ -417,6 +418,8 @@ static void hns3_get_strings(struct net_device *netdev, u32 stringset, u8 *data)
	case ETH_SS_TEST:
		ops->get_strings(h, stringset, data);
		break;
	default:
		break;
	}
}

@@ -542,32 +545,17 @@ static int hns3_set_pauseparam(struct net_device *netdev,
	return -EOPNOTSUPP;
}

static int hns3_get_link_ksettings(struct net_device *netdev,
static void hns3_get_ksettings(struct hnae3_handle *h,
			       struct ethtool_link_ksettings *cmd)
{
	struct hnae3_handle *h = hns3_get_handle(netdev);
	const struct hnae3_ae_ops *ops;
	u8 link_stat;

	if (!h->ae_algo || !h->ae_algo->ops)
		return -EOPNOTSUPP;

	ops = h->ae_algo->ops;
	if (ops->get_port_type)
		ops->get_port_type(h, &cmd->base.port);
	else
		return -EOPNOTSUPP;
	const struct hnae3_ae_ops *ops = h->ae_algo->ops;

	switch (cmd->base.port) {
	case PORT_FIBRE:
	/* 1.auto_neg & speed & duplex from cmd */
	if (ops->get_ksettings_an_result)
		ops->get_ksettings_an_result(h,
					     &cmd->base.autoneg,
					     &cmd->base.speed,
					     &cmd->base.duplex);
		else
			return -EOPNOTSUPP;

	/* 2.get link mode*/
	if (ops->get_link_mode)
@@ -579,18 +567,45 @@ static int hns3_get_link_ksettings(struct net_device *netdev,
	if (ops->get_mdix_mode)
		ops->get_mdix_mode(h, &cmd->base.eth_tp_mdix_ctrl,
				   &cmd->base.eth_tp_mdix);
}

static int hns3_get_link_ksettings(struct net_device *netdev,
				   struct ethtool_link_ksettings *cmd)
{
	struct hnae3_handle *h = hns3_get_handle(netdev);
	const struct hnae3_ae_ops *ops;
	u8 media_type;
	u8 link_stat;

	if (!h->ae_algo || !h->ae_algo->ops)
		return -EOPNOTSUPP;

	ops = h->ae_algo->ops;
	if (ops->get_media_type)
		ops->get_media_type(h, &media_type);
	else
		return -EOPNOTSUPP;

	switch (media_type) {
	case HNAE3_MEDIA_TYPE_NONE:
		cmd->base.port = PORT_NONE;
		hns3_get_ksettings(h, cmd);
		break;
	case PORT_TP:
	case HNAE3_MEDIA_TYPE_FIBER:
		cmd->base.port = PORT_FIBRE;
		hns3_get_ksettings(h, cmd);
		break;
	case HNAE3_MEDIA_TYPE_COPPER:
		if (!netdev->phydev)
			return -EOPNOTSUPP;

		cmd->base.port = PORT_TP;
		phy_ethtool_ksettings_get(netdev->phydev, cmd);

		break;
	default:
		netdev_warn(netdev,
			    "Unknown port type, neither Fibre/Copper detected");

		netdev_warn(netdev, "Unknown media type");
		return 0;
	}

+4 −2
Original line number Diff line number Diff line
@@ -73,6 +73,7 @@ static int hclge_ieee_getets(struct hnae3_handle *h, struct ieee_ets *ets)
static int hclge_ets_validate(struct hclge_dev *hdev, struct ieee_ets *ets,
			      u8 *tc, bool *changed)
{
	bool has_ets_tc = false;
	u32 total_ets_bw = 0;
	u8 max_tc = 0;
	u8 i;
@@ -100,13 +101,14 @@ static int hclge_ets_validate(struct hclge_dev *hdev, struct ieee_ets *ets,
				*changed = true;

			total_ets_bw += ets->tc_tx_bw[i];
			has_ets_tc = true;
			break;
		default:
			return -EINVAL;
		}
	}

	if (total_ets_bw != BW_PERCENT)
	if (has_ets_tc && total_ets_bw != BW_PERCENT)
		return -EINVAL;

	*tc = max_tc + 1;
+10 −26
Original line number Diff line number Diff line
@@ -354,7 +354,7 @@ static u8 *hclge_tqps_get_strings(struct hnae3_handle *handle, u8 *data)
	for (i = 0; i < kinfo->num_tqps; i++) {
		struct hclge_tqp *tqp = container_of(handle->kinfo.tqp[i],
			struct hclge_tqp, q);
		snprintf(buff, ETH_GSTRING_LEN, "txq#%d_pktnum_rcd",
		snprintf(buff, ETH_GSTRING_LEN, "txq%d_pktnum_rcd",
			 tqp->index);
		buff = buff + ETH_GSTRING_LEN;
	}
@@ -362,7 +362,7 @@ static u8 *hclge_tqps_get_strings(struct hnae3_handle *handle, u8 *data)
	for (i = 0; i < kinfo->num_tqps; i++) {
		struct hclge_tqp *tqp = container_of(kinfo->tqp[i],
			struct hclge_tqp, q);
		snprintf(buff, ETH_GSTRING_LEN, "rxq#%d_pktnum_rcd",
		snprintf(buff, ETH_GSTRING_LEN, "rxq%d_pktnum_rcd",
			 tqp->index);
		buff = buff + ETH_GSTRING_LEN;
	}
@@ -2224,6 +2224,8 @@ static void hclge_clear_event_cause(struct hclge_dev *hdev, u32 event_type,
	case HCLGE_VECTOR0_EVENT_MBX:
		hclge_write_dev(&hdev->hw, HCLGE_VECTOR0_CMDQ_SRC_REG, regclr);
		break;
	default:
		break;
	}
}

@@ -3387,7 +3389,7 @@ static int hclge_set_serdes_loopback(struct hclge_dev *hdev, bool en)
	struct hclge_desc desc;
	int ret, i = 0;

	req = (struct hclge_serdes_lb_cmd *)&desc.data[0];
	req = (struct hclge_serdes_lb_cmd *)desc.data;
	hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_SERDES_LOOPBACK, false);

	if (en) {
@@ -4634,7 +4636,7 @@ static int hclge_set_vlan_protocol_type(struct hclge_dev *hdev)

	hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_MAC_VLAN_INSERT, false);

	tx_req = (struct hclge_tx_vlan_type_cfg_cmd *)&desc.data;
	tx_req = (struct hclge_tx_vlan_type_cfg_cmd *)desc.data;
	tx_req->ot_vlan_type = cpu_to_le16(hdev->vlan_type_cfg.tx_ot_vlan_type);
	tx_req->in_vlan_type = cpu_to_le16(hdev->vlan_type_cfg.tx_in_vlan_type);

@@ -5218,6 +5220,10 @@ static int hclge_init_client_instance(struct hnae3_client *client,

				hnae3_set_client_init_flag(client, ae_dev, 1);
			}

			break;
		default:
			return -EINVAL;
		}
	}

@@ -5964,27 +5970,6 @@ static void hclge_get_link_mode(struct hnae3_handle *handle,
	}
}

static void hclge_get_port_type(struct hnae3_handle *handle,
				u8 *port_type)
{
	struct hclge_vport *vport = hclge_get_vport(handle);
	struct hclge_dev *hdev = vport->back;
	u8 media_type = hdev->hw.mac.media_type;

	switch (media_type) {
	case HNAE3_MEDIA_TYPE_FIBER:
		*port_type = PORT_FIBRE;
		break;
	case HNAE3_MEDIA_TYPE_COPPER:
		*port_type = PORT_TP;
		break;
	case HNAE3_MEDIA_TYPE_UNKNOWN:
	default:
		*port_type = PORT_OTHER;
		break;
	}
}

static const struct hnae3_ae_ops hclge_ops = {
	.init_ae_dev = hclge_init_ae_dev,
	.uninit_ae_dev = hclge_uninit_ae_dev,
@@ -6042,7 +6027,6 @@ static const struct hnae3_ae_ops hclge_ops = {
	.get_regs = hclge_get_regs,
	.set_led_id = hclge_set_led_id,
	.get_link_mode = hclge_get_link_mode,
	.get_port_type = hclge_get_port_type,
};

static struct hnae3_ae_algo ae_algo = {
Loading