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

Commit 26e392ca authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'hns3-next'



Huazhong Tan says:

====================
net: hns3: some code optimizations & cleanups & bugfixes

This patch-set includes code optimizations, cleanups and bugfixes for
the HNS3 ethernet controller driver.

[patch 1/12 - 6/12] adds some code optimizations and bugfixes about RAS
and MSI-X HW error.

[patch 7/12] fixes a loading issue.

[patch 8/12 - 11/12] adds some bugfixes.

[patch 12/12] adds some cleanups, which does not change the logic of code.
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents cbbe9bd0 ebaf1908
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -26,7 +26,8 @@ static bool hnae3_client_match(enum hnae3_client_type client_type)
}
}


void hnae3_set_client_init_flag(struct hnae3_client *client,
void hnae3_set_client_init_flag(struct hnae3_client *client,
				struct hnae3_ae_dev *ae_dev, int inited)
				struct hnae3_ae_dev *ae_dev,
				unsigned int inited)
{
{
	if (!client || !ae_dev)
	if (!client || !ae_dev)
		return;
		return;
+6 −2
Original line number Original line Diff line number Diff line
@@ -214,6 +214,7 @@ struct hnae3_ae_dev {
	struct list_head node;
	struct list_head node;
	u32 flag;
	u32 flag;
	u8 override_pci_need_reset; /* fix to stop multiple reset happening */
	u8 override_pci_need_reset; /* fix to stop multiple reset happening */
	unsigned long hw_err_reset_req;
	enum hnae3_reset_type reset_type;
	enum hnae3_reset_type reset_type;
	void *priv;
	void *priv;
};
};
@@ -459,6 +460,8 @@ struct hnae3_ae_ops {
				  u16 vlan, u8 qos, __be16 proto);
				  u16 vlan, u8 qos, __be16 proto);
	int (*enable_hw_strip_rxvtag)(struct hnae3_handle *handle, bool enable);
	int (*enable_hw_strip_rxvtag)(struct hnae3_handle *handle, bool enable);
	void (*reset_event)(struct pci_dev *pdev, struct hnae3_handle *handle);
	void (*reset_event)(struct pci_dev *pdev, struct hnae3_handle *handle);
	enum hnae3_reset_type (*get_reset_level)(struct hnae3_ae_dev *ae_dev,
						 unsigned long *addr);
	void (*set_default_reset_request)(struct hnae3_ae_dev *ae_dev,
	void (*set_default_reset_request)(struct hnae3_ae_dev *ae_dev,
					  enum hnae3_reset_type rst_type);
					  enum hnae3_reset_type rst_type);
	void (*get_channels)(struct hnae3_handle *handle,
	void (*get_channels)(struct hnae3_handle *handle,
@@ -490,7 +493,7 @@ struct hnae3_ae_ops {
	void (*enable_fd)(struct hnae3_handle *handle, bool enable);
	void (*enable_fd)(struct hnae3_handle *handle, bool enable);
	int (*add_arfs_entry)(struct hnae3_handle *handle, u16 queue_id,
	int (*add_arfs_entry)(struct hnae3_handle *handle, u16 queue_id,
			      u16 flow_id, struct flow_keys *fkeys);
			      u16 flow_id, struct flow_keys *fkeys);
	int (*dbg_run_cmd)(struct hnae3_handle *handle, char *cmd_buf);
	int (*dbg_run_cmd)(struct hnae3_handle *handle, const char *cmd_buf);
	pci_ers_result_t (*handle_hw_ras_error)(struct hnae3_ae_dev *ae_dev);
	pci_ers_result_t (*handle_hw_ras_error)(struct hnae3_ae_dev *ae_dev);
	bool (*get_hw_reset_stat)(struct hnae3_handle *handle);
	bool (*get_hw_reset_stat)(struct hnae3_handle *handle);
	bool (*ae_dev_resetting)(struct hnae3_handle *handle);
	bool (*ae_dev_resetting)(struct hnae3_handle *handle);
@@ -642,5 +645,6 @@ void hnae3_unregister_client(struct hnae3_client *client);
int hnae3_register_client(struct hnae3_client *client);
int hnae3_register_client(struct hnae3_client *client);


void hnae3_set_client_init_flag(struct hnae3_client *client,
void hnae3_set_client_init_flag(struct hnae3_client *client,
				struct hnae3_ae_dev *ae_dev, int inited);
				struct hnae3_ae_dev *ae_dev,
				unsigned int inited);
#endif
#endif
+3 −2
Original line number Original line Diff line number Diff line
@@ -11,7 +11,8 @@


static struct dentry *hns3_dbgfs_root;
static struct dentry *hns3_dbgfs_root;


static int hns3_dbg_queue_info(struct hnae3_handle *h, char *cmd_buf)
static int hns3_dbg_queue_info(struct hnae3_handle *h,
			       const char *cmd_buf)
{
{
	struct hns3_nic_priv *priv = h->priv;
	struct hns3_nic_priv *priv = h->priv;
	struct hns3_nic_ring_data *ring_data;
	struct hns3_nic_ring_data *ring_data;
@@ -155,7 +156,7 @@ static int hns3_dbg_queue_map(struct hnae3_handle *h)
	return 0;
	return 0;
}
}


static int hns3_dbg_bd_info(struct hnae3_handle *h, char *cmd_buf)
static int hns3_dbg_bd_info(struct hnae3_handle *h, const char *cmd_buf)
{
{
	struct hns3_nic_priv *priv = h->priv;
	struct hns3_nic_priv *priv = h->priv;
	struct hns3_nic_ring_data *ring_data;
	struct hns3_nic_ring_data *ring_data;
+33 −14
Original line number Original line Diff line number Diff line
@@ -29,7 +29,7 @@
#define hns3_tx_bd_count(S)	DIV_ROUND_UP(S, HNS3_MAX_BD_SIZE)
#define hns3_tx_bd_count(S)	DIV_ROUND_UP(S, HNS3_MAX_BD_SIZE)


static void hns3_clear_all_ring(struct hnae3_handle *h);
static void hns3_clear_all_ring(struct hnae3_handle *h);
static void hns3_force_clear_all_rx_ring(struct hnae3_handle *h);
static void hns3_force_clear_all_ring(struct hnae3_handle *h);
static void hns3_remove_hw_addr(struct net_device *netdev);
static void hns3_remove_hw_addr(struct net_device *netdev);


static const char hns3_driver_name[] = "hns3";
static const char hns3_driver_name[] = "hns3";
@@ -143,6 +143,7 @@ static int hns3_nic_init_irq(struct hns3_nic_priv *priv)
		if (ret) {
		if (ret) {
			netdev_err(priv->netdev, "request irq(%d) fail\n",
			netdev_err(priv->netdev, "request irq(%d) fail\n",
				   tqp_vectors->vector_irq);
				   tqp_vectors->vector_irq);
			hns3_nic_uninit_irq(priv);
			return ret;
			return ret;
		}
		}


@@ -487,6 +488,11 @@ static void hns3_nic_net_down(struct net_device *netdev)
	/* free irq resources */
	/* free irq resources */
	hns3_nic_uninit_irq(priv);
	hns3_nic_uninit_irq(priv);


	/* delay ring buffer clearing to hns3_reset_notify_uninit_enet
	 * during reset process, because driver may not be able
	 * to disable the ring through firmware when downing the netdev.
	 */
	if (!hns3_nic_resetting(netdev))
		hns3_clear_all_ring(priv->ae_handle);
		hns3_clear_all_ring(priv->ae_handle);
}
}


@@ -1005,7 +1011,8 @@ static int hns3_fill_desc_vtags(struct sk_buff *skb,
}
}


static int hns3_fill_desc(struct hns3_enet_ring *ring, void *priv,
static int hns3_fill_desc(struct hns3_enet_ring *ring, void *priv,
			  int size, int frag_end, enum hns_desc_type type)
			  unsigned int size, int frag_end,
			  enum hns_desc_type type)
{
{
	struct hns3_desc_cb *desc_cb = &ring->desc_cb[ring->next_to_use];
	struct hns3_desc_cb *desc_cb = &ring->desc_cb[ring->next_to_use];
	struct hns3_desc *desc = &ring->desc[ring->next_to_use];
	struct hns3_desc *desc = &ring->desc[ring->next_to_use];
@@ -1509,12 +1516,12 @@ static void hns3_nic_get_stats64(struct net_device *netdev,
static int hns3_setup_tc(struct net_device *netdev, void *type_data)
static int hns3_setup_tc(struct net_device *netdev, void *type_data)
{
{
	struct tc_mqprio_qopt_offload *mqprio_qopt = type_data;
	struct tc_mqprio_qopt_offload *mqprio_qopt = type_data;
	struct hnae3_handle *h = hns3_get_handle(netdev);
	struct hnae3_knic_private_info *kinfo = &h->kinfo;
	u8 *prio_tc = mqprio_qopt->qopt.prio_tc_map;
	u8 *prio_tc = mqprio_qopt->qopt.prio_tc_map;
	struct hnae3_knic_private_info *kinfo;
	u8 tc = mqprio_qopt->qopt.num_tc;
	u8 tc = mqprio_qopt->qopt.num_tc;
	u16 mode = mqprio_qopt->mode;
	u16 mode = mqprio_qopt->mode;
	u8 hw = mqprio_qopt->qopt.hw;
	u8 hw = mqprio_qopt->qopt.hw;
	struct hnae3_handle *h;


	if (!((hw == TC_MQPRIO_HW_OFFLOAD_TCS &&
	if (!((hw == TC_MQPRIO_HW_OFFLOAD_TCS &&
	       mode == TC_MQPRIO_MODE_CHANNEL) || (!hw && tc == 0)))
	       mode == TC_MQPRIO_MODE_CHANNEL) || (!hw && tc == 0)))
@@ -1526,6 +1533,9 @@ static int hns3_setup_tc(struct net_device *netdev, void *type_data)
	if (!netdev)
	if (!netdev)
		return -EINVAL;
		return -EINVAL;


	h = hns3_get_handle(netdev);
	kinfo = &h->kinfo;

	return (kinfo->dcb_ops && kinfo->dcb_ops->setup_tc) ?
	return (kinfo->dcb_ops && kinfo->dcb_ops->setup_tc) ?
		kinfo->dcb_ops->setup_tc(h, tc, prio_tc) : -EOPNOTSUPP;
		kinfo->dcb_ops->setup_tc(h, tc, prio_tc) : -EOPNOTSUPP;
}
}
@@ -1930,17 +1940,22 @@ static pci_ers_result_t hns3_error_detected(struct pci_dev *pdev,
static pci_ers_result_t hns3_slot_reset(struct pci_dev *pdev)
static pci_ers_result_t hns3_slot_reset(struct pci_dev *pdev)
{
{
	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(pdev);
	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(pdev);
	const struct hnae3_ae_ops *ops = ae_dev->ops;
	enum hnae3_reset_type reset_type;
	struct device *dev = &pdev->dev;
	struct device *dev = &pdev->dev;


	dev_info(dev, "requesting reset due to PCI error\n");

	if (!ae_dev || !ae_dev->ops)
	if (!ae_dev || !ae_dev->ops)
		return PCI_ERS_RESULT_NONE;
		return PCI_ERS_RESULT_NONE;


	/* request the reset */
	/* request the reset */
	if (ae_dev->ops->reset_event) {
	if (ops->reset_event) {
		if (!ae_dev->override_pci_need_reset)
		if (!ae_dev->override_pci_need_reset) {
			ae_dev->ops->reset_event(pdev, NULL);
			reset_type = ops->get_reset_level(ae_dev,
						&ae_dev->hw_err_reset_req);
			ops->set_default_reset_request(ae_dev, reset_type);
			dev_info(dev, "requesting reset due to PCI error\n");
			ops->reset_event(pdev, NULL);
		}


		return PCI_ERS_RESULT_RECOVERED;
		return PCI_ERS_RESULT_RECOVERED;
	}
	}
@@ -3410,7 +3425,7 @@ static int hns3_nic_dealloc_vector_data(struct hns3_nic_priv *priv)
}
}


static int hns3_ring_get_cfg(struct hnae3_queue *q, struct hns3_nic_priv *priv,
static int hns3_ring_get_cfg(struct hnae3_queue *q, struct hns3_nic_priv *priv,
			     int ring_type)
			     unsigned int ring_type)
{
{
	struct hns3_nic_ring_data *ring_data = priv->ring_data;
	struct hns3_nic_ring_data *ring_data = priv->ring_data;
	int queue_num = priv->ae_handle->kinfo.num_tqps;
	int queue_num = priv->ae_handle->kinfo.num_tqps;
@@ -3905,7 +3920,7 @@ static void hns3_client_uninit(struct hnae3_handle *handle, bool reset)


	hns3_del_all_fd_rules(netdev, true);
	hns3_del_all_fd_rules(netdev, true);


	hns3_force_clear_all_rx_ring(handle);
	hns3_force_clear_all_ring(handle);


	hns3_nic_uninit_vector_data(priv);
	hns3_nic_uninit_vector_data(priv);


@@ -4074,7 +4089,7 @@ static void hns3_force_clear_rx_ring(struct hns3_enet_ring *ring)
	}
	}
}
}


static void hns3_force_clear_all_rx_ring(struct hnae3_handle *h)
static void hns3_force_clear_all_ring(struct hnae3_handle *h)
{
{
	struct net_device *ndev = h->kinfo.netdev;
	struct net_device *ndev = h->kinfo.netdev;
	struct hns3_nic_priv *priv = netdev_priv(ndev);
	struct hns3_nic_priv *priv = netdev_priv(ndev);
@@ -4082,6 +4097,9 @@ static void hns3_force_clear_all_rx_ring(struct hnae3_handle *h)
	u32 i;
	u32 i;


	for (i = 0; i < h->kinfo.num_tqps; i++) {
	for (i = 0; i < h->kinfo.num_tqps; i++) {
		ring = priv->ring_data[i].ring;
		hns3_clear_tx_ring(ring);

		ring = priv->ring_data[i + h->kinfo.num_tqps].ring;
		ring = priv->ring_data[i + h->kinfo.num_tqps].ring;
		hns3_force_clear_rx_ring(ring);
		hns3_force_clear_rx_ring(ring);
	}
	}
@@ -4312,7 +4330,8 @@ static int hns3_reset_notify_uninit_enet(struct hnae3_handle *handle)
		return 0;
		return 0;
	}
	}


	hns3_force_clear_all_rx_ring(handle);
	hns3_clear_all_ring(handle);
	hns3_force_clear_all_ring(handle);


	hns3_nic_uninit_vector_data(priv);
	hns3_nic_uninit_vector_data(priv);


+1 −1
Original line number Original line Diff line number Diff line
@@ -417,7 +417,7 @@ struct hns3_enet_ring {
	 */
	 */
	int next_to_clean;
	int next_to_clean;


	int pull_len; /* head length for current packet */
	u32 pull_len; /* head length for current packet */
	u32 frag_num;
	u32 frag_num;
	unsigned char *va; /* first buffer address for current packet */
	unsigned char *va; /* first buffer address for current packet */


Loading