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

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
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* version 2, as published by the Free Software Foundation. * 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. * functions.
*/ */
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#define AQ_HW_H #define AQ_HW_H
#include "aq_common.h" #include "aq_common.h"
#include "hw_atl/hw_atl_utils.h"
/* NIC H/W capabilities */ /* NIC H/W capabilities */
struct aq_hw_caps_s { struct aq_hw_caps_s {
...@@ -93,6 +94,19 @@ struct aq_hw_s { ...@@ -93,6 +94,19 @@ struct aq_hw_s {
void __iomem *mmio; void __iomem *mmio;
unsigned int not_ff_addr; unsigned int not_ff_addr;
struct aq_hw_link_status_s aq_link_status; 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; struct aq_ring_s;
...@@ -102,7 +116,7 @@ struct sk_buff; ...@@ -102,7 +116,7 @@ struct sk_buff;
struct aq_hw_ops { struct aq_hw_ops {
struct aq_hw_s *(*create)(struct aq_pci_func_s *aq_pci_func, 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); void (*destroy)(struct aq_hw_s *self);
...@@ -124,7 +138,6 @@ struct aq_hw_ops { ...@@ -124,7 +138,6 @@ struct aq_hw_ops {
struct aq_ring_s *aq_ring); struct aq_ring_s *aq_ring);
int (*hw_get_mac_permanent)(struct aq_hw_s *self, int (*hw_get_mac_permanent)(struct aq_hw_s *self,
struct aq_hw_caps_s *aq_hw_caps,
u8 *mac); u8 *mac);
int (*hw_set_mac_address)(struct aq_hw_s *self, u8 *mac_addr); int (*hw_set_mac_address)(struct aq_hw_s *self, u8 *mac_addr);
...@@ -135,8 +148,7 @@ struct aq_hw_ops { ...@@ -135,8 +148,7 @@ struct aq_hw_ops {
int (*hw_reset)(struct aq_hw_s *self); int (*hw_reset)(struct aq_hw_s *self);
int (*hw_init)(struct aq_hw_s *self, struct aq_nic_cfg_s *aq_nic_cfg, int (*hw_init)(struct aq_hw_s *self, u8 *mac_addr);
u8 *mac_addr);
int (*hw_start)(struct aq_hw_s *self); int (*hw_start)(struct aq_hw_s *self);
......
...@@ -242,8 +242,9 @@ struct aq_nic_s *aq_nic_alloc_cold(const struct net_device_ops *ndev_ops, ...@@ -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->aq_hw_ops = *aq_hw_ops;
self->port = (u8)port; self->port = (u8)port;
self->aq_hw = self->aq_hw_ops.create(aq_pci_func, self->port, self->aq_hw = self->aq_hw_ops.create(aq_pci_func, self->port);
&self->aq_hw_ops); 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, err = self->aq_hw_ops.get_hw_caps(self->aq_hw, &self->aq_hw_caps,
pdev->device, pdev->subsystem_device); pdev->device, pdev->subsystem_device);
if (err < 0) if (err < 0)
...@@ -268,7 +269,6 @@ int aq_nic_ndev_register(struct aq_nic_s *self) ...@@ -268,7 +269,6 @@ int aq_nic_ndev_register(struct aq_nic_s *self)
goto err_exit; goto err_exit;
} }
err = self->aq_hw_ops.hw_get_mac_permanent(self->aq_hw, err = self->aq_hw_ops.hw_get_mac_permanent(self->aq_hw,
self->aq_nic_cfg.aq_hw_caps,
self->ndev->dev_addr); self->ndev->dev_addr);
if (err < 0) if (err < 0)
goto err_exit; goto err_exit;
...@@ -387,7 +387,7 @@ int aq_nic_init(struct aq_nic_s *self) ...@@ -387,7 +387,7 @@ int aq_nic_init(struct aq_nic_s *self)
if (err < 0) if (err < 0)
goto err_exit; 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); aq_nic_get_ndev(self)->dev_addr);
if (err < 0) if (err < 0)
goto err_exit; goto err_exit;
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "aq_common.h" #include "aq_common.h"
#include "aq_rss.h" #include "aq_rss.h"
#include "aq_hw.h"
struct aq_ring_s; struct aq_ring_s;
struct aq_pci_func_s; struct aq_pci_func_s;
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#define AQ_PCI_FUNC_H #define AQ_PCI_FUNC_H
#include "aq_common.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 aq_pci_func_s *aq_pci_func_alloc(struct aq_hw_ops *hw_ops,
struct pci_dev *pdev, struct pci_dev *pdev,
......
...@@ -36,21 +36,20 @@ static int hw_atl_a0_get_hw_caps(struct aq_hw_s *self, ...@@ -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, static struct aq_hw_s *hw_atl_a0_create(struct aq_pci_func_s *aq_pci_func,
unsigned int port, unsigned int port)
struct aq_hw_ops *ops)
{ {
struct hw_atl_s *self = NULL; struct aq_hw_s *self = NULL;
self = kzalloc(sizeof(*self), GFP_KERNEL); self = kzalloc(sizeof(*self), GFP_KERNEL);
if (!self) if (!self)
goto err_exit; 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: err_exit:
return (struct aq_hw_s *)self; return self;
} }
static void hw_atl_a0_destroy(struct aq_hw_s *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) ...@@ -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, static int hw_atl_a0_hw_rss_hash_set(struct aq_hw_s *self,
struct aq_rss_parameters *rss_params) 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; int err = 0;
unsigned int i = 0U; unsigned int i = 0U;
unsigned int addr = 0U; unsigned int addr = 0U;
cfg = self->aq_nic_cfg;
for (i = 10, addr = 0U; i--; ++addr) { for (i = 10, addr = 0U; i--; ++addr) {
u32 key_data = cfg->is_rss ? u32 key_data = cfg->is_rss ?
__swab32(rss_params->hash_secret_key[i]) : 0U; __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) ...@@ -312,9 +309,7 @@ static int hw_atl_a0_hw_mac_addr_set(struct aq_hw_s *self, u8 *mac_addr)
return err; return err;
} }
static int hw_atl_a0_hw_init(struct aq_hw_s *self, static int hw_atl_a0_hw_init(struct aq_hw_s *self, u8 *mac_addr)
struct aq_nic_cfg_s *aq_nic_cfg,
u8 *mac_addr)
{ {
static u32 aq_hw_atl_igcr_table_[4][2] = { static u32 aq_hw_atl_igcr_table_[4][2] = {
{ 0x20000000U, 0x20000000U }, /* AQ_IRQ_INVALID */ { 0x20000000U, 0x20000000U }, /* AQ_IRQ_INVALID */
...@@ -325,10 +320,7 @@ static int hw_atl_a0_hw_init(struct aq_hw_s *self, ...@@ -325,10 +320,7 @@ static int hw_atl_a0_hw_init(struct aq_hw_s *self,
int err = 0; int err = 0;
self->aq_nic_cfg = aq_nic_cfg; struct aq_nic_cfg_s *aq_nic_cfg = self->aq_nic_cfg;
hw_atl_utils_hw_chip_features_init(self,
&PHAL_ATLANTIC_A0->chip_features);
hw_atl_a0_hw_init_tx_path(self); hw_atl_a0_hw_init_tx_path(self);
hw_atl_a0_hw_init_rx_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) ...@@ -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)); itr_irq_status_clearlsw_set(self, LODWORD(mask));
if ((1U << 16) & reg_gen_irq_status_get(self)) if ((1U << 16) & reg_gen_irq_status_get(self))
atomic_inc(&self->dpc);
atomic_inc(&PHAL_ATLANTIC_A0->dpc);
return aq_hw_err_from_flags(self); return aq_hw_err_from_flags(self);
} }
......
...@@ -37,21 +37,20 @@ static int hw_atl_b0_get_hw_caps(struct aq_hw_s *self, ...@@ -37,21 +37,20 @@ static int hw_atl_b0_get_hw_caps(struct aq_hw_s *self,
} }
static struct aq_hw_s *hw_atl_b0_create(struct aq_pci_func_s *aq_pci_func, static struct aq_hw_s *hw_atl_b0_create(struct aq_pci_func_s *aq_pci_func,
unsigned int port, unsigned int port)
struct aq_hw_ops *ops)
{ {
struct hw_atl_s *self = NULL; struct aq_hw_s *self = NULL;
self = kzalloc(sizeof(*self), GFP_KERNEL); self = kzalloc(sizeof(*self), GFP_KERNEL);
if (!self) if (!self)
goto err_exit; 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: err_exit:
return (struct aq_hw_s *)self; return self;
} }
static void hw_atl_b0_destroy(struct aq_hw_s *self) static void hw_atl_b0_destroy(struct aq_hw_s *self)
...@@ -152,13 +151,11 @@ static int hw_atl_b0_hw_qos_set(struct aq_hw_s *self) ...@@ -152,13 +151,11 @@ static int hw_atl_b0_hw_qos_set(struct aq_hw_s *self)
static int hw_atl_b0_hw_rss_hash_set(struct aq_hw_s *self, static int hw_atl_b0_hw_rss_hash_set(struct aq_hw_s *self,
struct aq_rss_parameters *rss_params) 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; int err = 0;
unsigned int i = 0U; unsigned int i = 0U;
unsigned int addr = 0U; unsigned int addr = 0U;
cfg = self->aq_nic_cfg;
for (i = 10, addr = 0U; i--; ++addr) { for (i = 10, addr = 0U; i--; ++addr) {
u32 key_data = cfg->is_rss ? u32 key_data = cfg->is_rss ?
__swab32(rss_params->hash_secret_key[i]) : 0U; __swab32(rss_params->hash_secret_key[i]) : 0U;
...@@ -357,9 +354,7 @@ static int hw_atl_b0_hw_mac_addr_set(struct aq_hw_s *self, u8 *mac_addr) ...@@ -357,9 +354,7 @@ static int hw_atl_b0_hw_mac_addr_set(struct aq_hw_s *self, u8 *mac_addr)
return err; return err;
} }
static int hw_atl_b0_hw_init(struct aq_hw_s *self, static int hw_atl_b0_hw_init(struct aq_hw_s *self, u8 *mac_addr)
struct aq_nic_cfg_s *aq_nic_cfg,
u8 *mac_addr)
{ {
static u32 aq_hw_atl_igcr_table_[4][2] = { static u32 aq_hw_atl_igcr_table_[4][2] = {
{ 0x20000000U, 0x20000000U }, /* AQ_IRQ_INVALID */ { 0x20000000U, 0x20000000U }, /* AQ_IRQ_INVALID */
...@@ -371,10 +366,7 @@ static int hw_atl_b0_hw_init(struct aq_hw_s *self, ...@@ -371,10 +366,7 @@ static int hw_atl_b0_hw_init(struct aq_hw_s *self,
int err = 0; int err = 0;
u32 val; u32 val;
self->aq_nic_cfg = aq_nic_cfg; struct aq_nic_cfg_s *aq_nic_cfg = self->aq_nic_cfg;
hw_atl_utils_hw_chip_features_init(self,
&PHAL_ATLANTIC_B0->chip_features);
hw_atl_b0_hw_init_tx_path(self); hw_atl_b0_hw_init_tx_path(self);
hw_atl_b0_hw_init_rx_path(self); hw_atl_b0_hw_init_rx_path(self);
...@@ -737,7 +729,7 @@ static int hw_atl_b0_hw_irq_disable(struct aq_hw_s *self, u64 mask) ...@@ -737,7 +729,7 @@ static int hw_atl_b0_hw_irq_disable(struct aq_hw_s *self, u64 mask)
itr_irq_msk_clearlsw_set(self, LODWORD(mask)); itr_irq_msk_clearlsw_set(self, LODWORD(mask));
itr_irq_status_clearlsw_set(self, LODWORD(mask)); itr_irq_status_clearlsw_set(self, LODWORD(mask));
atomic_inc(&PHAL_ATLANTIC_B0->dpc); atomic_inc(&self->dpc);
return aq_hw_err_from_flags(self); return aq_hw_err_from_flags(self);
} }
......
...@@ -11,11 +11,9 @@ ...@@ -11,11 +11,9 @@
* abstraction layer. * abstraction layer.
*/ */
#include "../aq_hw.h" #include "../aq_nic.h"
#include "../aq_hw_utils.h" #include "../aq_hw_utils.h"
#include "../aq_pci_func.h" #include "../aq_pci_func.h"
#include "../aq_ring.h"
#include "../aq_vec.h"
#include "hw_atl_utils.h" #include "hw_atl_utils.h"
#include "hw_atl_llh.h" #include "hw_atl_llh.h"
...@@ -136,7 +134,7 @@ static int hw_atl_utils_init_ucp(struct aq_hw_s *self, ...@@ -136,7 +134,7 @@ static int hw_atl_utils_init_ucp(struct aq_hw_s *self,
reg_glb_cpu_scratch_scp_set(self, 0x00000000U, 25U); reg_glb_cpu_scratch_scp_set(self, 0x00000000U, 25U);
/* check 10 times by 1ms */ /* check 10 times by 1ms */
AQ_HW_WAIT_FOR(0U != (PHAL_ATLANTIC_A0->mbox_addr = AQ_HW_WAIT_FOR(0U != (self->mbox_addr =
aq_hw_read_reg(self, 0x360U)), 1000U, 10U); aq_hw_read_reg(self, 0x360U)), 1000U, 10U);
err = hw_atl_utils_ver_match(aq_hw_caps->fw_ver_expected, err = hw_atl_utils_ver_match(aq_hw_caps->fw_ver_expected,
...@@ -174,14 +172,14 @@ static int hw_atl_utils_fw_rpc_call(struct aq_hw_s *self, unsigned int rpc_size) ...@@ -174,14 +172,14 @@ static int hw_atl_utils_fw_rpc_call(struct aq_hw_s *self, unsigned int rpc_size)
err = -1; err = -1;
goto err_exit; goto err_exit;
} }
err = hw_atl_utils_fw_upload_dwords(self, PHAL_ATLANTIC->rpc_addr, err = hw_atl_utils_fw_upload_dwords(self, self->rpc_addr,
(u32 *)(void *)&PHAL_ATLANTIC->rpc, (u32 *)(void *)&self->rpc,
(rpc_size + sizeof(u32) - (rpc_size + sizeof(u32) -
sizeof(u8)) / sizeof(u32)); sizeof(u8)) / sizeof(u32));
if (err < 0) if (err < 0)
goto err_exit; goto err_exit;
sw.tid = 0xFFFFU & (++PHAL_ATLANTIC->rpc_tid); sw.tid = 0xFFFFU & (++self->rpc_tid);
sw.len = (u16)rpc_size; sw.len = (u16)rpc_size;
aq_hw_write_reg(self, HW_ATL_RPC_CONTROL_ADR, sw.val); aq_hw_write_reg(self, HW_ATL_RPC_CONTROL_ADR, sw.val);
...@@ -199,7 +197,7 @@ static int hw_atl_utils_fw_rpc_wait(struct aq_hw_s *self, ...@@ -199,7 +197,7 @@ static int hw_atl_utils_fw_rpc_wait(struct aq_hw_s *self,
do { do {
sw.val = aq_hw_read_reg(self, HW_ATL_RPC_CONTROL_ADR); sw.val = aq_hw_read_reg(self, HW_ATL_RPC_CONTROL_ADR);
PHAL_ATLANTIC->rpc_tid = sw.tid; self->rpc_tid = sw.tid;
AQ_HW_WAIT_FOR(sw.tid == AQ_HW_WAIT_FOR(sw.tid ==
(fw.val = (fw.val =
...@@ -221,9 +219,9 @@ static int hw_atl_utils_fw_rpc_wait(struct aq_hw_s *self, ...@@ -221,9 +219,9 @@ static int hw_atl_utils_fw_rpc_wait(struct aq_hw_s *self,
if (fw.len) { if (fw.len) {
err = err =
hw_atl_utils_fw_downld_dwords(self, hw_atl_utils_fw_downld_dwords(self,
PHAL_ATLANTIC->rpc_addr, self->rpc_addr,
(u32 *)(void *) (u32 *)(void *)
&PHAL_ATLANTIC->rpc, &self->rpc,
(fw.len + sizeof(u32) - (fw.len + sizeof(u32) -
sizeof(u8)) / sizeof(u8)) /
sizeof(u32)); sizeof(u32));
...@@ -231,19 +229,18 @@ static int hw_atl_utils_fw_rpc_wait(struct aq_hw_s *self, ...@@ -231,19 +229,18 @@ static int hw_atl_utils_fw_rpc_wait(struct aq_hw_s *self,
goto err_exit; goto err_exit;
} }
*rpc = &PHAL_ATLANTIC->rpc; *rpc = &self->rpc;
} }
err_exit: err_exit:
return err; return err;
} }
static int hw_atl_utils_mpi_create(struct aq_hw_s *self, static int hw_atl_utils_mpi_create(struct aq_hw_s *self)
struct aq_hw_caps_s *aq_hw_caps)
{ {
int err = 0; int err = 0;
err = hw_atl_utils_init_ucp(self, aq_hw_caps); err = hw_atl_utils_init_ucp(self, self->aq_nic_cfg->aq_hw_caps);
if (err < 0) if (err < 0)
goto err_exit; goto err_exit;
...@@ -259,7 +256,7 @@ int hw_atl_utils_mpi_read_mbox(struct aq_hw_s *self, ...@@ -259,7 +256,7 @@ int hw_atl_utils_mpi_read_mbox(struct aq_hw_s *self,
struct hw_aq_atl_utils_mbox_header *pmbox) struct hw_aq_atl_utils_mbox_header *pmbox)
{ {
return hw_atl_utils_fw_downld_dwords(self, return hw_atl_utils_fw_downld_dwords(self,
PHAL_ATLANTIC->mbox_addr, self->mbox_addr,
(u32 *)(void *)pmbox, (u32 *)(void *)pmbox,
sizeof(*pmbox) / sizeof(u32)); sizeof(*pmbox) / sizeof(u32));
} }
...@@ -270,7 +267,7 @@ void hw_atl_utils_mpi_read_stats(struct aq_hw_s *self, ...@@ -270,7 +267,7 @@ void hw_atl_utils_mpi_read_stats(struct aq_hw_s *self,
int err = 0; int err = 0;
err = hw_atl_utils_fw_downld_dwords(self, err = hw_atl_utils_fw_downld_dwords(self,
PHAL_ATLANTIC->mbox_addr, self->mbox_addr,
(u32 *)(void *)pmbox, (u32 *)(void *)pmbox,
sizeof(*pmbox) / sizeof(u32)); sizeof(*pmbox) / sizeof(u32));
if (err < 0) if (err < 0)
...@@ -281,7 +278,7 @@ void hw_atl_utils_mpi_read_stats(struct aq_hw_s *self, ...@@ -281,7 +278,7 @@ void hw_atl_utils_mpi_read_stats(struct aq_hw_s *self,
self->aq_nic_cfg->mtu : 1514U; self->aq_nic_cfg->mtu : 1514U;
pmbox->stats.ubrc = pmbox->stats.uprc * mtu; pmbox->stats.ubrc = pmbox->stats.uprc * mtu;
pmbox->stats.ubtc = pmbox->stats.uptc * mtu; pmbox->stats.ubtc = pmbox->stats.uptc * mtu;
pmbox->stats.dpc = atomic_read(&PHAL_ATLANTIC_A0->dpc); pmbox->stats.dpc = atomic_read(&self->dpc);
} else { } else {
pmbox->stats.dpc = reg_rx_dma_stat_counter7get(self); pmbox->stats.dpc = reg_rx_dma_stat_counter7get(self);
} }
...@@ -365,7 +362,6 @@ int hw_atl_utils_mpi_get_link_status(struct aq_hw_s *self) ...@@ -365,7 +362,6 @@ int hw_atl_utils_mpi_get_link_status(struct aq_hw_s *self)
} }
int hw_atl_utils_get_mac_permanent(struct aq_hw_s *self, int hw_atl_utils_get_mac_permanent(struct aq_hw_s *self,
struct aq_hw_caps_s *aq_hw_caps,
u8 *mac) u8 *mac)
{ {
int err = 0; int err = 0;
...@@ -376,9 +372,9 @@ int hw_atl_utils_get_mac_permanent(struct aq_hw_s *self, ...@@ -376,9 +372,9 @@ int hw_atl_utils_get_mac_permanent(struct aq_hw_s *self,
self->mmio = aq_pci_func_get_mmio(self->aq_pci_func); self->mmio = aq_pci_func_get_mmio(self->aq_pci_func);
hw_atl_utils_hw_chip_features_init(self, hw_atl_utils_hw_chip_features_init(self,
&PHAL_ATLANTIC_A0->chip_features); &self->chip_features);
err = hw_atl_utils_mpi_create(self, aq_hw_caps); err = hw_atl_utils_mpi_create(self);
if (err < 0) if (err < 0)
goto err_exit; goto err_exit;
...@@ -500,13 +496,13 @@ int hw_atl_utils_hw_set_power(struct aq_hw_s *self, ...@@ -500,13 +496,13 @@ int hw_atl_utils_hw_set_power(struct aq_hw_s *self,
int hw_atl_utils_update_stats(struct aq_hw_s *self) int hw_atl_utils_update_stats(struct aq_hw_s *self)
{ {
struct hw_atl_s *hw_self = PHAL_ATLANTIC;
struct hw_aq_atl_utils_mbox mbox; struct hw_aq_atl_utils_mbox mbox;
hw_atl_utils_mpi_read_stats(self, &mbox); hw_atl_utils_mpi_read_stats(self, &mbox);
#define AQ_SDELTA(_N_) (hw_self->curr_stats._N_ += \ #define AQ_SDELTA(_N_) (self->curr_stats._N_ += \
mbox.stats._N_ - hw_self->last_stats._N_) mbox.stats._N_ - self->last_stats._N_)
if (self->aq_link_status.mbps) { if (self->aq_link_status.mbps) {
AQ_SDELTA(uprc); AQ_SDELTA(uprc);
AQ_SDELTA(mprc); AQ_SDELTA(mprc);
...@@ -527,19 +523,19 @@ int hw_atl_utils_update_stats(struct aq_hw_s *self) ...@@ -527,19 +523,19 @@ int hw_atl_utils_update_stats(struct aq_hw_s *self)
AQ_SDELTA(dpc); AQ_SDELTA(dpc);
} }
#undef AQ_SDELTA #undef AQ_SDELTA
hw_self->curr_stats.dma_pkt_rc = stats_rx_dma_good_pkt_counterlsw_get(self); self->curr_stats.dma_pkt_rc = stats_rx_dma_good_pkt_counterlsw_get(self);
hw_self->curr_stats.dma_pkt_tc = stats_tx_dma_good_pkt_counterlsw_get(self); self->curr_stats.dma_pkt_tc = stats_tx_dma_good_pkt_counterlsw_get(self);
hw_self->curr_stats.dma_oct_rc = stats_rx_dma_good_octet_counterlsw_get(self); self->curr_stats.dma_oct_rc = stats_rx_dma_good_octet_counterlsw_get(self);
hw_self->curr_stats.dma_oct_tc = stats_tx_dma_good_octet_counterlsw_get(self); self->curr_stats.dma_oct_tc = stats_tx_dma_good_octet_counterlsw_get(self);
memcpy(&hw_self->last_stats, &mbox.stats, sizeof(mbox.stats)); memcpy(&self->last_stats, &mbox.stats, sizeof(mbox.stats));
return 0; return 0;
} }
struct aq_stats_s *hw_atl_utils_get_hw_stats(struct aq_hw_s *self) struct aq_stats_s *hw_atl_utils_get_hw_stats(struct aq_hw_s *self)
{ {
return &PHAL_ATLANTIC->curr_stats; return &self->curr_stats;
} }
static const u32 hw_atl_utils_hw_mac_regs[] = { static const u32 hw_atl_utils_hw_mac_regs[] = {
......
...@@ -14,8 +14,6 @@ ...@@ -14,8 +14,6 @@
#ifndef HW_ATL_UTILS_H #ifndef HW_ATL_UTILS_H
#define HW_ATL_UTILS_H #define HW_ATL_UTILS_H
#include "../aq_common.h"
#define HW_ATL_FLUSH() { (void)aq_hw_read_reg(self, 0x10); } #define HW_ATL_FLUSH() { (void)aq_hw_read_reg(self, 0x10); }
struct __packed hw_atl_stats_s { struct __packed hw_atl_stats_s {
...@@ -126,26 +124,6 @@ struct __packed hw_aq_atl_utils_mbox { ...@@ -126,26 +124,6 @@ struct __packed hw_aq_atl_utils_mbox {
struct hw_atl_stats_s stats; struct hw_atl_stats_s stats;
}; };
struct __packed hw_atl_s {
struct aq_hw_s base;
struct hw_atl_stats_s last_stats;
struct aq_stats_s curr_stats;
u64 speed;
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;
};
#define SELF ((struct hw_atl_s *)self)
#define PHAL_ATLANTIC ((struct hw_atl_s *)((void *)(self)))
#define PHAL_ATLANTIC_A0 ((struct hw_atl_s *)((void *)(self)))
#define PHAL_ATLANTIC_B0 ((struct hw_atl_s *)((void *)(self)))
#define HAL_ATLANTIC_UTILS_CHIP_MIPS 0x00000001U #define HAL_ATLANTIC_UTILS_CHIP_MIPS 0x00000001U
#define HAL_ATLANTIC_UTILS_CHIP_TPO2 0x00000002U #define HAL_ATLANTIC_UTILS_CHIP_TPO2 0x00000002U
#define HAL_ATLANTIC_UTILS_CHIP_RPF2 0x00000004U #define HAL_ATLANTIC_UTILS_CHIP_RPF2 0x00000004U
...@@ -154,7 +132,7 @@ struct __packed hw_atl_s { ...@@ -154,7 +132,7 @@ struct __packed hw_atl_s {
#define HAL_ATLANTIC_UTILS_CHIP_REVISION_B0 0x02000000U #define HAL_ATLANTIC_UTILS_CHIP_REVISION_B0 0x02000000U
#define IS_CHIP_FEATURE(_F_) (HAL_ATLANTIC_UTILS_CHIP_##_F_ & \ #define IS_CHIP_FEATURE(_F_) (HAL_ATLANTIC_UTILS_CHIP_##_F_ & \
PHAL_ATLANTIC->chip_features) self->chip_features)
enum hal_atl_utils_fw_state_e { enum hal_atl_utils_fw_state_e {
MPI_DEINIT = 0, MPI_DEINIT = 0,
...@@ -171,6 +149,10 @@ enum hal_atl_utils_fw_state_e { ...@@ -171,6 +149,10 @@ enum hal_atl_utils_fw_state_e {
#define HAL_ATLANTIC_RATE_100M BIT(5) #define HAL_ATLANTIC_RATE_100M BIT(5)
#define HAL_ATLANTIC_RATE_INVALID BIT(6) #define HAL_ATLANTIC_RATE_INVALID BIT(6)
struct aq_hw_s;
struct aq_hw_caps_s;
struct aq_hw_link_status_s;
void hw_atl_utils_hw_chip_features_init(struct aq_hw_s *self, u32 *p); void hw_atl_utils_hw_chip_features_init(struct aq_hw_s *self, u32 *p);
int hw_atl_utils_mpi_read_mbox(struct aq_hw_s *self, int hw_atl_utils_mpi_read_mbox(struct aq_hw_s *self,
...@@ -189,7 +171,6 @@ int hw_atl_utils_mpi_set_speed(struct aq_hw_s *self, u32 speed, ...@@ -189,7 +171,6 @@ int hw_atl_utils_mpi_set_speed(struct aq_hw_s *self, u32 speed,
int hw_atl_utils_mpi_get_link_status(struct aq_hw_s *self); int hw_atl_utils_mpi_get_link_status(struct aq_hw_s *self);
int hw_atl_utils_get_mac_permanent(struct aq_hw_s *self, int hw_atl_utils_get_mac_permanent(struct aq_hw_s *self,
struct aq_hw_caps_s *aq_hw_caps,
u8 *mac); u8 *mac);
unsigned int hw_atl_utils_mbps_2_speed_index(unsigned int mbps); unsigned int hw_atl_utils_mbps_2_speed_index(unsigned int mbps);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment