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

Commit 6d268910 authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'hns3-a-few-code-improvements'



Peng Li says:

====================
net: hns3: a few code improvements

This patchset fixes a few code stylistic issues from
concentrated review, no functional changes introduced.
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 16c0cd07 ab68059e
Loading
Loading
Loading
Loading
+11 −7
Original line number Diff line number Diff line
@@ -8,7 +8,6 @@
 */

#include <linux/list.h>
#include <linux/slab.h>
#include <linux/spinlock.h>

#include "hnae3.h"
@@ -95,7 +94,7 @@ static int hnae3_match_n_instantiate(struct hnae3_client *client,
		ret = ae_dev->ops->init_client_instance(client, ae_dev);
		if (ret) {
			dev_err(&ae_dev->pdev->dev,
				"fail to instantiate client\n");
				"fail to instantiate client, ret = %d\n", ret);
			return ret;
		}

@@ -135,7 +134,8 @@ int hnae3_register_client(struct hnae3_client *client)
		ret = hnae3_match_n_instantiate(client, ae_dev, true);
		if (ret)
			dev_err(&ae_dev->pdev->dev,
				"match and instantiation failed for port\n");
				"match and instantiation failed for port, ret = %d\n",
				ret);
	}

exit:
@@ -185,7 +185,8 @@ void hnae3_register_ae_algo(struct hnae3_ae_algo *ae_algo)
		ae_dev->ops = ae_algo->ops;
		ret = ae_algo->ops->init_ae_dev(ae_dev);
		if (ret) {
			dev_err(&ae_dev->pdev->dev, "init ae_dev error.\n");
			dev_err(&ae_dev->pdev->dev,
				"init ae_dev error, ret = %d\n", ret);
			continue;
		}

@@ -198,7 +199,8 @@ void hnae3_register_ae_algo(struct hnae3_ae_algo *ae_algo)
			ret = hnae3_match_n_instantiate(client, ae_dev, true);
			if (ret)
				dev_err(&ae_dev->pdev->dev,
					"match and instantiation failed\n");
					"match and instantiation failed, ret = %d\n",
					ret);
		}
	}

@@ -271,7 +273,8 @@ void hnae3_register_ae_dev(struct hnae3_ae_dev *ae_dev)
		/* ae_dev init should set flag */
		ret = ae_dev->ops->init_ae_dev(ae_dev);
		if (ret) {
			dev_err(&ae_dev->pdev->dev, "init ae_dev error\n");
			dev_err(&ae_dev->pdev->dev,
				"init ae_dev error, ret = %d\n", ret);
			goto out_err;
		}

@@ -286,7 +289,8 @@ void hnae3_register_ae_dev(struct hnae3_ae_dev *ae_dev)
		ret = hnae3_match_n_instantiate(client, ae_dev, true);
		if (ret)
			dev_err(&ae_dev->pdev->dev,
				"match and instantiation failed\n");
				"match and instantiation failed, ret = %d\n",
				ret);
	}

out_err:
+7 −11
Original line number Diff line number Diff line
@@ -1917,7 +1917,7 @@ bool hns3_clean_tx_ring(struct hns3_enet_ring *ring, int budget)
	if (is_ring_empty(ring) || head == ring->next_to_clean)
		return true; /* no data to poll */

	if (!is_valid_clean_head(ring, head)) {
	if (unlikely(!is_valid_clean_head(ring, head))) {
		netdev_err(netdev, "wrong head (%d, %d-%d)\n", head,
			   ring->next_to_use, ring->next_to_clean);

@@ -2103,11 +2103,11 @@ static void hns3_rx_checksum(struct hns3_enet_ring *ring, struct sk_buff *skb,
		skb->csum_level = 1;
	case HNS3_OL4_TYPE_NO_TUN:
		/* Can checksum ipv4 or ipv6 + UDP/TCP/SCTP packets */
		if (l3_type == HNS3_L3_TYPE_IPV4 ||
		    (l3_type == HNS3_L3_TYPE_IPV6 &&
		if ((l3_type == HNS3_L3_TYPE_IPV4 ||
		     l3_type == HNS3_L3_TYPE_IPV6) &&
		    (l4_type == HNS3_L4_TYPE_UDP ||
		     l4_type == HNS3_L4_TYPE_TCP ||
		      l4_type == HNS3_L4_TYPE_SCTP)))
		     l4_type == HNS3_L4_TYPE_SCTP))
			skb->ip_summed = CHECKSUM_UNNECESSARY;
		break;
	}
@@ -2174,7 +2174,7 @@ static int hns3_handle_rx_bd(struct hns3_enet_ring *ring,
	bd_base_info = le32_to_cpu(desc->rx.bd_base_info);

	/* Check valid BD */
	if (!hnae_get_bit(bd_base_info, HNS3_RXD_VLD_B))
	if (unlikely(!hnae_get_bit(bd_base_info, HNS3_RXD_VLD_B)))
		return -EFAULT;

	va = (unsigned char *)desc_cb->buf + desc_cb->page_offset;
@@ -2745,10 +2745,6 @@ static int hns3_nic_uninit_vector_data(struct hns3_nic_priv *priv)
		if (ret)
			return ret;

		ret = h->ae_algo->ops->put_vector(h, tqp_vector->vector_irq);
		if (ret)
			return ret;

		hns3_free_vector_ring_chain(tqp_vector, &vector_ring_chain);

		if (priv->tqp_vector[i].irq_init_flag == HNS3_VECTOR_INITED) {
+6 −6
Original line number Diff line number Diff line
@@ -123,9 +123,9 @@ static void hclge_cmd_config_regs(struct hclge_cmq_ring *ring)

	if (ring->flag == HCLGE_TYPE_CSQ) {
		hclge_write_dev(hw, HCLGE_NIC_CSQ_BASEADDR_L_REG,
				(u32)dma);
				lower_32_bits(dma));
		hclge_write_dev(hw, HCLGE_NIC_CSQ_BASEADDR_H_REG,
				(u32)((dma >> 31) >> 1));
				upper_32_bits(dma));
		hclge_write_dev(hw, HCLGE_NIC_CSQ_DEPTH_REG,
				(ring->desc_num >> HCLGE_NIC_CMQ_DESC_NUM_S) |
				HCLGE_NIC_CMQ_ENABLE);
@@ -133,9 +133,9 @@ static void hclge_cmd_config_regs(struct hclge_cmq_ring *ring)
		hclge_write_dev(hw, HCLGE_NIC_CSQ_HEAD_REG, 0);
	} else {
		hclge_write_dev(hw, HCLGE_NIC_CRQ_BASEADDR_L_REG,
				(u32)dma);
				lower_32_bits(dma));
		hclge_write_dev(hw, HCLGE_NIC_CRQ_BASEADDR_H_REG,
				(u32)((dma >> 31) >> 1));
				upper_32_bits(dma));
		hclge_write_dev(hw, HCLGE_NIC_CRQ_DEPTH_REG,
				(ring->desc_num >> HCLGE_NIC_CMQ_DESC_NUM_S) |
				HCLGE_NIC_CMQ_ENABLE);
@@ -152,7 +152,7 @@ static void hclge_cmd_init_regs(struct hclge_hw *hw)

static int hclge_cmd_csq_clean(struct hclge_hw *hw)
{
	struct hclge_dev *hdev = (struct hclge_dev *)hw->back;
	struct hclge_dev *hdev = container_of(hw, struct hclge_dev, hw);
	struct hclge_cmq_ring *csq = &hw->cmq.csq;
	u16 ntc = csq->next_to_clean;
	struct hclge_desc *desc;
@@ -216,7 +216,7 @@ static bool hclge_is_special_opcode(u16 opcode)
 **/
int hclge_cmd_send(struct hclge_hw *hw, struct hclge_desc *desc, int num)
{
	struct hclge_dev *hdev = (struct hclge_dev *)hw->back;
	struct hclge_dev *hdev = container_of(hw, struct hclge_dev, hw);
	struct hclge_desc *desc_to_use;
	bool complete = false;
	u32 timeout = 0;
+32 −17
Original line number Diff line number Diff line
@@ -2614,6 +2614,12 @@ static irqreturn_t hclge_misc_irq_handle(int irq, void *data)

static void hclge_free_vector(struct hclge_dev *hdev, int vector_id)
{
	if (hdev->vector_status[vector_id] == HCLGE_INVALID_VPORT) {
		dev_warn(&hdev->pdev->dev,
			 "vector(vector_id %d) has been freed.\n", vector_id);
		return;
	}

	hdev->vector_status[vector_id] = HCLGE_INVALID_VPORT;
	hdev->num_msi_left += 1;
	hdev->num_msi_used -= 1;
@@ -5531,7 +5537,6 @@ static int hclge_pci_init(struct hclge_dev *hdev)

	pci_set_master(pdev);
	hw = &hdev->hw;
	hw->back = hdev;
	hw->io_base = pcim_iomap(pdev, 2, 0);
	if (!hw->io_base) {
		dev_err(&pdev->dev, "Can't map configuration register space\n");
@@ -5562,6 +5567,30 @@ static void hclge_pci_uninit(struct hclge_dev *hdev)
	pci_disable_device(pdev);
}

static void hclge_state_init(struct hclge_dev *hdev)
{
	set_bit(HCLGE_STATE_SERVICE_INITED, &hdev->state);
	set_bit(HCLGE_STATE_DOWN, &hdev->state);
	clear_bit(HCLGE_STATE_RST_SERVICE_SCHED, &hdev->state);
	clear_bit(HCLGE_STATE_RST_HANDLING, &hdev->state);
	clear_bit(HCLGE_STATE_MBX_SERVICE_SCHED, &hdev->state);
	clear_bit(HCLGE_STATE_MBX_HANDLING, &hdev->state);
}

static void hclge_state_uninit(struct hclge_dev *hdev)
{
	set_bit(HCLGE_STATE_DOWN, &hdev->state);

	if (hdev->service_timer.function)
		del_timer_sync(&hdev->service_timer);
	if (hdev->service_task.func)
		cancel_work_sync(&hdev->service_task);
	if (hdev->rst_service_task.func)
		cancel_work_sync(&hdev->rst_service_task);
	if (hdev->mbx_service_task.func)
		cancel_work_sync(&hdev->mbx_service_task);
}

static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev)
{
	struct pci_dev *pdev = ae_dev->pdev;
@@ -5702,12 +5731,7 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev)
	/* Enable MISC vector(vector0) */
	hclge_enable_vector(&hdev->misc_vector, true);

	set_bit(HCLGE_STATE_SERVICE_INITED, &hdev->state);
	set_bit(HCLGE_STATE_DOWN, &hdev->state);
	clear_bit(HCLGE_STATE_RST_SERVICE_SCHED, &hdev->state);
	clear_bit(HCLGE_STATE_RST_HANDLING, &hdev->state);
	clear_bit(HCLGE_STATE_MBX_SERVICE_SCHED, &hdev->state);
	clear_bit(HCLGE_STATE_MBX_HANDLING, &hdev->state);
	hclge_state_init(hdev);

	pr_info("%s driver initialization finished.\n", HCLGE_DRIVER_NAME);
	return 0;
@@ -5812,16 +5836,7 @@ static void hclge_uninit_ae_dev(struct hnae3_ae_dev *ae_dev)
	struct hclge_dev *hdev = ae_dev->priv;
	struct hclge_mac *mac = &hdev->hw.mac;

	set_bit(HCLGE_STATE_DOWN, &hdev->state);

	if (hdev->service_timer.function)
		del_timer_sync(&hdev->service_timer);
	if (hdev->service_task.func)
		cancel_work_sync(&hdev->service_task);
	if (hdev->rst_service_task.func)
		cancel_work_sync(&hdev->rst_service_task);
	if (hdev->mbx_service_task.func)
		cancel_work_sync(&hdev->mbx_service_task);
	hclge_state_uninit(hdev);

	if (mac->phydev)
		mdiobus_unregister(mac->mdio_bus);
+0 −1
Original line number Diff line number Diff line
@@ -190,7 +190,6 @@ struct hclge_hw {
	int num_vec;
	struct hclge_cmq cmq;
	struct hclge_caps caps;
	void *back;
};

/* TQP stats */
Loading