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

Commit 1a713f87 authored by Igor Russkikh's avatar Igor Russkikh Committed by David S. Miller
Browse files

net: aquantia: Cleanup hardware access modules



Use direct aq_hw_s *self reference where possible
Eliminate useless abstraction PHAL, duplicated structures definitions,
Simplify nic config structure creation and management.

Signed-off-by: default avatarIgor Russkikh <igor.russkikh@aquantia.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 78f5193d
Loading
Loading
Loading
Loading
+17 −5
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@
 * version 2, as published by the Free Software Foundation.
 */

/* File aq_hw.h: Declaraion of abstract interface for NIC hardware specific
/* File aq_hw.h: Declaration of abstract interface for NIC hardware specific
 * functions.
 */

@@ -15,6 +15,7 @@
#define AQ_HW_H

#include "aq_common.h"
#include "hw_atl/hw_atl_utils.h"

/* NIC H/W capabilities */
struct aq_hw_caps_s {
@@ -93,6 +94,19 @@ struct aq_hw_s {
	void __iomem *mmio;
	unsigned int not_ff_addr;
	struct aq_hw_link_status_s aq_link_status;
	struct hw_aq_atl_utils_mbox mbox;
	struct hw_atl_stats_s last_stats;
	struct aq_stats_s curr_stats;
	u64 speed;
	u32 itr_tx;
	u32 itr_rx;
	unsigned int chip_features;
	u32 fw_ver_actual;
	atomic_t dpc;
	u32 mbox_addr;
	u32 rpc_addr;
	u32 rpc_tid;
	struct hw_aq_atl_utils_fw_rpc rpc;
};

struct aq_ring_s;
@@ -102,7 +116,7 @@ struct sk_buff;

struct aq_hw_ops {
	struct aq_hw_s *(*create)(struct aq_pci_func_s *aq_pci_func,
				  unsigned int port, struct aq_hw_ops *ops);
				  unsigned int port);

	void (*destroy)(struct aq_hw_s *self);

@@ -124,7 +138,6 @@ struct aq_hw_ops {
				      struct aq_ring_s *aq_ring);

	int (*hw_get_mac_permanent)(struct aq_hw_s *self,
				    struct aq_hw_caps_s *aq_hw_caps,
				    u8 *mac);

	int (*hw_set_mac_address)(struct aq_hw_s *self, u8 *mac_addr);
@@ -135,8 +148,7 @@ struct aq_hw_ops {

	int (*hw_reset)(struct aq_hw_s *self);

	int (*hw_init)(struct aq_hw_s *self, struct aq_nic_cfg_s *aq_nic_cfg,
		       u8 *mac_addr);
	int (*hw_init)(struct aq_hw_s *self, u8 *mac_addr);

	int (*hw_start)(struct aq_hw_s *self);

+4 −4
Original line number Diff line number Diff line
@@ -242,8 +242,9 @@ struct aq_nic_s *aq_nic_alloc_cold(const struct net_device_ops *ndev_ops,
	self->aq_hw_ops = *aq_hw_ops;
	self->port = (u8)port;

	self->aq_hw = self->aq_hw_ops.create(aq_pci_func, self->port,
						&self->aq_hw_ops);
	self->aq_hw = self->aq_hw_ops.create(aq_pci_func, self->port);
	self->aq_hw->aq_nic_cfg = &self->aq_nic_cfg;

	err = self->aq_hw_ops.get_hw_caps(self->aq_hw, &self->aq_hw_caps,
					  pdev->device, pdev->subsystem_device);
	if (err < 0)
@@ -268,7 +269,6 @@ int aq_nic_ndev_register(struct aq_nic_s *self)
		goto err_exit;
	}
	err = self->aq_hw_ops.hw_get_mac_permanent(self->aq_hw,
			    self->aq_nic_cfg.aq_hw_caps,
			    self->ndev->dev_addr);
	if (err < 0)
		goto err_exit;
@@ -387,7 +387,7 @@ int aq_nic_init(struct aq_nic_s *self)
	if (err < 0)
		goto err_exit;

	err = self->aq_hw_ops.hw_init(self->aq_hw, &self->aq_nic_cfg,
	err = self->aq_hw_ops.hw_init(self->aq_hw,
			    aq_nic_get_ndev(self)->dev_addr);
	if (err < 0)
		goto err_exit;
+1 −0
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@

#include "aq_common.h"
#include "aq_rss.h"
#include "aq_hw.h"

struct aq_ring_s;
struct aq_pci_func_s;
+1 −0
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@
#define AQ_PCI_FUNC_H

#include "aq_common.h"
#include "aq_nic.h"

struct aq_pci_func_s *aq_pci_func_alloc(struct aq_hw_ops *hw_ops,
					struct pci_dev *pdev,
+9 −18
Original line number Diff line number Diff line
@@ -36,21 +36,20 @@ static int hw_atl_a0_get_hw_caps(struct aq_hw_s *self,
}

static struct aq_hw_s *hw_atl_a0_create(struct aq_pci_func_s *aq_pci_func,
					unsigned int port,
					struct aq_hw_ops *ops)
					unsigned int port)
{
	struct hw_atl_s *self = NULL;
	struct aq_hw_s *self = NULL;

	self = kzalloc(sizeof(*self), GFP_KERNEL);
	if (!self)
		goto err_exit;

	self->base.aq_pci_func = aq_pci_func;
	self->aq_pci_func = aq_pci_func;

	self->base.not_ff_addr = 0x10U;
	self->not_ff_addr = 0x10U;

err_exit:
	return (struct aq_hw_s *)self;
	return self;
}

static void hw_atl_a0_destroy(struct aq_hw_s *self)
@@ -151,13 +150,11 @@ static int hw_atl_a0_hw_qos_set(struct aq_hw_s *self)
static int hw_atl_a0_hw_rss_hash_set(struct aq_hw_s *self,
				     struct aq_rss_parameters *rss_params)
{
	struct aq_nic_cfg_s *cfg = NULL;
	struct aq_nic_cfg_s *cfg = self->aq_nic_cfg;
	int err = 0;
	unsigned int i = 0U;
	unsigned int addr = 0U;

	cfg = self->aq_nic_cfg;

	for (i = 10, addr = 0U; i--; ++addr) {
		u32 key_data = cfg->is_rss ?
			__swab32(rss_params->hash_secret_key[i]) : 0U;
@@ -312,9 +309,7 @@ static int hw_atl_a0_hw_mac_addr_set(struct aq_hw_s *self, u8 *mac_addr)
	return err;
}

static int hw_atl_a0_hw_init(struct aq_hw_s *self,
			     struct aq_nic_cfg_s *aq_nic_cfg,
			     u8 *mac_addr)
static int hw_atl_a0_hw_init(struct aq_hw_s *self, u8 *mac_addr)
{
	static u32 aq_hw_atl_igcr_table_[4][2] = {
		{ 0x20000000U, 0x20000000U }, /* AQ_IRQ_INVALID */
@@ -325,10 +320,7 @@ static int hw_atl_a0_hw_init(struct aq_hw_s *self,

	int err = 0;

	self->aq_nic_cfg = aq_nic_cfg;

	hw_atl_utils_hw_chip_features_init(self,
					   &PHAL_ATLANTIC_A0->chip_features);
	struct aq_nic_cfg_s *aq_nic_cfg = self->aq_nic_cfg;

	hw_atl_a0_hw_init_tx_path(self);
	hw_atl_a0_hw_init_rx_path(self);
@@ -704,8 +696,7 @@ static int hw_atl_a0_hw_irq_disable(struct aq_hw_s *self, u64 mask)
	itr_irq_status_clearlsw_set(self, LODWORD(mask));

	if ((1U << 16) & reg_gen_irq_status_get(self))

		atomic_inc(&PHAL_ATLANTIC_A0->dpc);
		atomic_inc(&self->dpc);

	return aq_hw_err_from_flags(self);
}
Loading