Skip to content

Commit

Permalink
net: ngbe: Remove structure ngbe_adapter
Browse files Browse the repository at this point in the history
Move the total private structure to libwx.

Signed-off-by: Mengyuan Lou <mengyuanlou@net-swift.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Mengyuan Lou authored and Jakub Kicinski committed Jan 7, 2023
1 parent 270a71e commit 803df55
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 205 deletions.
38 changes: 38 additions & 0 deletions drivers/net/ethernet/wangxun/libwx/wx_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@
#define WX_MAC_STATE_MODIFIED 0x2
#define WX_MAC_STATE_IN_USE 0x4

#define WX_CFG_PORT_ST 0x14404

/* Host Interface Command Structures */
struct wx_hic_hdr {
u8 cmd;
Expand Down Expand Up @@ -253,6 +255,12 @@ enum wx_mac_type {
wx_mac_em
};

enum em_mac_type {
em_mac_type_unknown = 0,
em_mac_type_mdi,
em_mac_type_rgmii
};

struct wx_mac_info {
enum wx_mac_type type;
bool set_lben;
Expand Down Expand Up @@ -306,6 +314,7 @@ struct wx {
struct net_device *netdev;
struct wx_bus_info bus;
struct wx_mac_info mac;
enum em_mac_type mac_type;
struct wx_eeprom_info eeprom;
struct wx_addr_filter_info addr_ctrl;
struct wx_mac_addr *mac_table;
Expand All @@ -320,6 +329,35 @@ struct wx {
bool adapter_stopped;
char eeprom_id[32];
enum wx_reset_type reset_type;

bool wol_enabled;
bool ncsi_enabled;
bool gpio_ctrl;

/* Tx fast path data */
int num_tx_queues;
u16 tx_itr_setting;
u16 tx_work_limit;

/* Rx fast path data */
int num_rx_queues;
u16 rx_itr_setting;
u16 rx_work_limit;

int num_q_vectors; /* current number of q_vectors for device */
int max_q_vectors; /* upper limit of q_vectors for device */

u32 tx_ring_count;
u32 rx_ring_count;

#define WX_MAX_RETA_ENTRIES 128
u8 rss_indir_tbl[WX_MAX_RETA_ENTRIES];

#define WX_RSS_KEY_SIZE 40 /* size of RSS Hash Key in bytes */
u32 *rss_key;
u32 wol;

u16 bd_number;
};

#define WX_INTR_ALL (~0ULL)
Expand Down
20 changes: 8 additions & 12 deletions drivers/net/ethernet/wangxun/ngbe/ngbe_hw.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@
#include "ngbe_type.h"
#include "ngbe_hw.h"

int ngbe_eeprom_chksum_hostif(struct ngbe_adapter *adapter)
int ngbe_eeprom_chksum_hostif(struct wx *wx)
{
struct wx_hic_read_shadow_ram buffer;
struct wx *wx = &adapter->wx;
int status;
int tmp;

Expand All @@ -37,14 +36,12 @@ int ngbe_eeprom_chksum_hostif(struct ngbe_adapter *adapter)
return -EIO;
}

static int ngbe_reset_misc(struct ngbe_adapter *adapter)
static int ngbe_reset_misc(struct wx *wx)
{
struct wx *wx = &adapter->wx;

wx_reset_misc(wx);
if (adapter->mac_type == ngbe_mac_type_rgmii)
if (wx->mac_type == em_mac_type_rgmii)
wr32(wx, NGBE_MDIO_CLAUSE_SELECT, 0xF);
if (adapter->gpio_ctrl) {
if (wx->gpio_ctrl) {
/* gpio0 is used to power on/off control*/
wr32(wx, NGBE_GPIO_DDR, 0x1);
wr32(wx, NGBE_GPIO_DR, NGBE_GPIO_DR_0);
Expand All @@ -54,25 +51,24 @@ static int ngbe_reset_misc(struct ngbe_adapter *adapter)

/**
* ngbe_reset_hw - Perform hardware reset
* @adapter: pointer to hardware structure
* @wx: pointer to hardware structure
*
* Resets the hardware by resetting the transmit and receive units, masks
* and clears all interrupts, perform a PHY reset, and perform a link (MAC)
* reset.
**/
int ngbe_reset_hw(struct ngbe_adapter *adapter)
int ngbe_reset_hw(struct wx *wx)
{
struct wx *wx = &adapter->wx;
int status = 0;
u32 reset = 0;

/* Call adapter stop to disable tx/rx and clear interrupts */
/* Call wx stop to disable tx/rx and clear interrupts */
status = wx_stop_adapter(wx);
if (status != 0)
return status;
reset = WX_MIS_RST_LAN_RST(wx->bus.func);
wr32(wx, WX_MIS_RST, reset | rd32(wx, WX_MIS_RST));
ngbe_reset_misc(adapter);
ngbe_reset_misc(wx);

/* Store the permanent mac address */
wx_get_mac_addr(wx, wx->mac.perm_addr);
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/ethernet/wangxun/ngbe/ngbe_hw.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
#ifndef _NGBE_HW_H_
#define _NGBE_HW_H_

int ngbe_eeprom_chksum_hostif(struct ngbe_adapter *adapter);
int ngbe_reset_hw(struct ngbe_adapter *adapter);
int ngbe_eeprom_chksum_hostif(struct wx *wx);
int ngbe_reset_hw(struct wx *wx);
#endif /* _NGBE_HW_H_ */
Loading

0 comments on commit 803df55

Please sign in to comment.