Commit f23395b4 authored by Jakub Kicinski's avatar Jakub Kicinski

Merge branch 'net-wangxun-adjust-code-structure'

Jiawen Wu says:

====================
net: wangxun: Adjust code structure

Remove useless structs 'txgbe_hw' and 'ngbe_hw' make the codes clear.
And move the same codes which sets MAC address between txgbe and ngbe
to libwx. Further more, rename struct 'wx_hw' to 'wx' and move total
adapter members to wx.
====================

Link: https://lore.kernel.org/r/20230106033853.2806007-1-jiawenwu@trustnetic.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 7abd92a5 803df55d
This diff is collapsed.
...@@ -4,25 +4,26 @@ ...@@ -4,25 +4,26 @@
#ifndef _WX_HW_H_ #ifndef _WX_HW_H_
#define _WX_HW_H_ #define _WX_HW_H_
int wx_check_flash_load(struct wx_hw *hw, u32 check_bit); int wx_check_flash_load(struct wx *wx, u32 check_bit);
void wx_control_hw(struct wx_hw *wxhw, bool drv); void wx_control_hw(struct wx *wx, bool drv);
int wx_mng_present(struct wx_hw *wxhw); int wx_mng_present(struct wx *wx);
int wx_host_interface_command(struct wx_hw *wxhw, u32 *buffer, int wx_host_interface_command(struct wx *wx, u32 *buffer,
u32 length, u32 timeout, bool return_data); u32 length, u32 timeout, bool return_data);
int wx_read_ee_hostif(struct wx_hw *wxhw, u16 offset, u16 *data); int wx_read_ee_hostif(struct wx *wx, u16 offset, u16 *data);
int wx_read_ee_hostif_buffer(struct wx_hw *wxhw, int wx_read_ee_hostif_buffer(struct wx *wx,
u16 offset, u16 words, u16 *data); u16 offset, u16 words, u16 *data);
int wx_reset_hostif(struct wx_hw *wxhw); int wx_reset_hostif(struct wx *wx);
void wx_init_eeprom_params(struct wx_hw *wxhw); void wx_init_eeprom_params(struct wx *wx);
void wx_get_mac_addr(struct wx_hw *wxhw, u8 *mac_addr); void wx_get_mac_addr(struct wx *wx, u8 *mac_addr);
int wx_set_rar(struct wx_hw *wxhw, u32 index, u8 *addr, u64 pools, u32 enable_addr); void wx_init_rx_addrs(struct wx *wx);
int wx_clear_rar(struct wx_hw *wxhw, u32 index); void wx_mac_set_default_filter(struct wx *wx, u8 *addr);
void wx_init_rx_addrs(struct wx_hw *wxhw); void wx_flush_sw_mac_table(struct wx *wx);
void wx_disable_rx(struct wx_hw *wxhw); int wx_set_mac(struct net_device *netdev, void *p);
int wx_disable_pcie_master(struct wx_hw *wxhw); void wx_disable_rx(struct wx *wx);
int wx_stop_adapter(struct wx_hw *wxhw); int wx_disable_pcie_master(struct wx *wx);
void wx_reset_misc(struct wx_hw *wxhw); int wx_stop_adapter(struct wx *wx);
int wx_get_pcie_msix_counts(struct wx_hw *wxhw, u16 *msix_count, u16 max_msix_count); void wx_reset_misc(struct wx *wx);
int wx_sw_init(struct wx_hw *wxhw); int wx_get_pcie_msix_counts(struct wx *wx, u16 *msix_count, u16 max_msix_count);
int wx_sw_init(struct wx *wx);
#endif /* _WX_HW_H_ */ #endif /* _WX_HW_H_ */
...@@ -185,6 +185,12 @@ ...@@ -185,6 +185,12 @@
#define WX_SW_REGION_PTR 0x1C #define WX_SW_REGION_PTR 0x1C
#define WX_MAC_STATE_DEFAULT 0x1
#define WX_MAC_STATE_MODIFIED 0x2
#define WX_MAC_STATE_IN_USE 0x4
#define WX_CFG_PORT_ST 0x14404
/* Host Interface Command Structures */ /* Host Interface Command Structures */
struct wx_hic_hdr { struct wx_hic_hdr {
u8 cmd; u8 cmd;
...@@ -249,6 +255,12 @@ enum wx_mac_type { ...@@ -249,6 +255,12 @@ enum wx_mac_type {
wx_mac_em wx_mac_em
}; };
enum em_mac_type {
em_mac_type_unknown = 0,
em_mac_type_mdi,
em_mac_type_rgmii
};
struct wx_mac_info { struct wx_mac_info {
enum wx_mac_type type; enum wx_mac_type type;
bool set_lben; bool set_lben;
...@@ -284,19 +296,28 @@ struct wx_addr_filter_info { ...@@ -284,19 +296,28 @@ struct wx_addr_filter_info {
bool user_set_promisc; bool user_set_promisc;
}; };
struct wx_mac_addr {
u8 addr[ETH_ALEN];
u16 state; /* bitmask */
u64 pools;
};
enum wx_reset_type { enum wx_reset_type {
WX_LAN_RESET = 0, WX_LAN_RESET = 0,
WX_SW_RESET, WX_SW_RESET,
WX_GLOBAL_RESET WX_GLOBAL_RESET
}; };
struct wx_hw { struct wx {
u8 __iomem *hw_addr; u8 __iomem *hw_addr;
struct pci_dev *pdev; struct pci_dev *pdev;
struct net_device *netdev;
struct wx_bus_info bus; struct wx_bus_info bus;
struct wx_mac_info mac; struct wx_mac_info mac;
enum em_mac_type mac_type;
struct wx_eeprom_info eeprom; struct wx_eeprom_info eeprom;
struct wx_addr_filter_info addr_ctrl; struct wx_addr_filter_info addr_ctrl;
struct wx_mac_addr *mac_table;
u16 device_id; u16 device_id;
u16 vendor_id; u16 vendor_id;
u16 subsystem_device_id; u16 subsystem_device_id;
...@@ -304,8 +325,39 @@ struct wx_hw { ...@@ -304,8 +325,39 @@ struct wx_hw {
u8 revision_id; u8 revision_id;
u16 oem_ssid; u16 oem_ssid;
u16 oem_svid; u16 oem_svid;
u16 msg_enable;
bool adapter_stopped; bool adapter_stopped;
char eeprom_id[32];
enum wx_reset_type reset_type; 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) #define WX_INTR_ALL (~0ULL)
...@@ -319,23 +371,23 @@ struct wx_hw { ...@@ -319,23 +371,23 @@ struct wx_hw {
wr32((a), (reg) + ((off) << 2), (val)) wr32((a), (reg) + ((off) << 2), (val))
static inline u32 static inline u32
rd32m(struct wx_hw *wxhw, u32 reg, u32 mask) rd32m(struct wx *wx, u32 reg, u32 mask)
{ {
u32 val; u32 val;
val = rd32(wxhw, reg); val = rd32(wx, reg);
return val & mask; return val & mask;
} }
static inline void static inline void
wr32m(struct wx_hw *wxhw, u32 reg, u32 mask, u32 field) wr32m(struct wx *wx, u32 reg, u32 mask, u32 field)
{ {
u32 val; u32 val;
val = rd32(wxhw, reg); val = rd32(wx, reg);
val = ((val & ~mask) | (field & mask)); val = ((val & ~mask) | (field & mask));
wr32(wxhw, reg, val); wr32(wx, reg, val);
} }
/* On some domestic CPU platforms, sometimes IO is not synchronized with /* On some domestic CPU platforms, sometimes IO is not synchronized with
...@@ -343,10 +395,10 @@ wr32m(struct wx_hw *wxhw, u32 reg, u32 mask, u32 field) ...@@ -343,10 +395,10 @@ wr32m(struct wx_hw *wxhw, u32 reg, u32 mask, u32 field)
*/ */
#define WX_WRITE_FLUSH(H) rd32(H, WX_MIS_PWR) #define WX_WRITE_FLUSH(H) rd32(H, WX_MIS_PWR)
#define wx_err(wxhw, fmt, arg...) \ #define wx_err(wx, fmt, arg...) \
dev_err(&(wxhw)->pdev->dev, fmt, ##arg) dev_err(&(wx)->pdev->dev, fmt, ##arg)
#define wx_dbg(wxhw, fmt, arg...) \ #define wx_dbg(wx, fmt, arg...) \
dev_dbg(&(wxhw)->pdev->dev, fmt, ##arg) dev_dbg(&(wx)->pdev->dev, fmt, ##arg)
#endif /* _WX_TYPE_H_ */ #endif /* _WX_TYPE_H_ */
/* SPDX-License-Identifier: GPL-2.0 */
/* Copyright (c) 2019 - 2022 Beijing WangXun Technology Co., Ltd. */
#ifndef _NGBE_H_
#define _NGBE_H_
#include "ngbe_type.h"
#define NGBE_MAX_FDIR_INDICES 7
#define NGBE_MAX_RX_QUEUES (NGBE_MAX_FDIR_INDICES + 1)
#define NGBE_MAX_TX_QUEUES (NGBE_MAX_FDIR_INDICES + 1)
#define NGBE_ETH_LENGTH_OF_ADDRESS 6
#define NGBE_MAX_MSIX_VECTORS 0x09
#define NGBE_RAR_ENTRIES 32
/* TX/RX descriptor defines */
#define NGBE_DEFAULT_TXD 512 /* default ring size */
#define NGBE_DEFAULT_TX_WORK 256
#define NGBE_MAX_TXD 8192
#define NGBE_MIN_TXD 128
#define NGBE_DEFAULT_RXD 512 /* default ring size */
#define NGBE_DEFAULT_RX_WORK 256
#define NGBE_MAX_RXD 8192
#define NGBE_MIN_RXD 128
#define NGBE_MAC_STATE_DEFAULT 0x1
#define NGBE_MAC_STATE_MODIFIED 0x2
#define NGBE_MAC_STATE_IN_USE 0x4
struct ngbe_mac_addr {
u8 addr[ETH_ALEN];
u16 state; /* bitmask */
u64 pools;
};
/* board specific private data structure */
struct ngbe_adapter {
u8 __iomem *io_addr; /* Mainly for iounmap use */
/* OS defined structs */
struct net_device *netdev;
struct pci_dev *pdev;
/* structs defined in ngbe_hw.h */
struct ngbe_hw hw;
struct ngbe_mac_addr *mac_table;
u16 msg_enable;
/* 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 NGBE_MAX_RETA_ENTRIES 128
u8 rss_indir_tbl[NGBE_MAX_RETA_ENTRIES];
#define NGBE_RSS_KEY_SIZE 40 /* size of RSS Hash Key in bytes */
u32 *rss_key;
u32 wol;
u16 bd_number;
};
extern char ngbe_driver_name[];
#endif /* _NGBE_H_ */
...@@ -9,12 +9,10 @@ ...@@ -9,12 +9,10 @@
#include "../libwx/wx_hw.h" #include "../libwx/wx_hw.h"
#include "ngbe_type.h" #include "ngbe_type.h"
#include "ngbe_hw.h" #include "ngbe_hw.h"
#include "ngbe.h"
int ngbe_eeprom_chksum_hostif(struct ngbe_hw *hw) int ngbe_eeprom_chksum_hostif(struct wx *wx)
{ {
struct wx_hic_read_shadow_ram buffer; struct wx_hic_read_shadow_ram buffer;
struct wx_hw *wxhw = &hw->wxhw;
int status; int status;
int tmp; int tmp;
...@@ -27,61 +25,58 @@ int ngbe_eeprom_chksum_hostif(struct ngbe_hw *hw) ...@@ -27,61 +25,58 @@ int ngbe_eeprom_chksum_hostif(struct ngbe_hw *hw)
/* one word */ /* one word */
buffer.length = 0; buffer.length = 0;
status = wx_host_interface_command(wxhw, (u32 *)&buffer, sizeof(buffer), status = wx_host_interface_command(wx, (u32 *)&buffer, sizeof(buffer),
WX_HI_COMMAND_TIMEOUT, false); WX_HI_COMMAND_TIMEOUT, false);
if (status < 0) if (status < 0)
return status; return status;
tmp = rd32a(wxhw, WX_MNG_MBOX, 1); tmp = rd32a(wx, WX_MNG_MBOX, 1);
if (tmp == NGBE_FW_CMD_ST_PASS) if (tmp == NGBE_FW_CMD_ST_PASS)
return 0; return 0;
return -EIO; return -EIO;
} }
static int ngbe_reset_misc(struct ngbe_hw *hw) static int ngbe_reset_misc(struct wx *wx)
{ {
struct wx_hw *wxhw = &hw->wxhw; wx_reset_misc(wx);
if (wx->mac_type == em_mac_type_rgmii)
wx_reset_misc(wxhw); wr32(wx, NGBE_MDIO_CLAUSE_SELECT, 0xF);
if (hw->mac_type == ngbe_mac_type_rgmii) if (wx->gpio_ctrl) {
wr32(wxhw, NGBE_MDIO_CLAUSE_SELECT, 0xF);
if (hw->gpio_ctrl) {
/* gpio0 is used to power on/off control*/ /* gpio0 is used to power on/off control*/
wr32(wxhw, NGBE_GPIO_DDR, 0x1); wr32(wx, NGBE_GPIO_DDR, 0x1);
wr32(wxhw, NGBE_GPIO_DR, NGBE_GPIO_DR_0); wr32(wx, NGBE_GPIO_DR, NGBE_GPIO_DR_0);
} }
return 0; return 0;
} }
/** /**
* ngbe_reset_hw - Perform hardware reset * ngbe_reset_hw - Perform hardware reset
* @hw: pointer to hardware structure * @wx: pointer to hardware structure
* *
* Resets the hardware by resetting the transmit and receive units, masks * Resets the hardware by resetting the transmit and receive units, masks
* and clears all interrupts, perform a PHY reset, and perform a link (MAC) * and clears all interrupts, perform a PHY reset, and perform a link (MAC)
* reset. * reset.
**/ **/
int ngbe_reset_hw(struct ngbe_hw *hw) int ngbe_reset_hw(struct wx *wx)
{ {
struct wx_hw *wxhw = &hw->wxhw;
int status = 0; int status = 0;
u32 reset = 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(wxhw); status = wx_stop_adapter(wx);
if (status != 0) if (status != 0)
return status; return status;
reset = WX_MIS_RST_LAN_RST(wxhw->bus.func); reset = WX_MIS_RST_LAN_RST(wx->bus.func);
wr32(wxhw, WX_MIS_RST, reset | rd32(wxhw, WX_MIS_RST)); wr32(wx, WX_MIS_RST, reset | rd32(wx, WX_MIS_RST));
ngbe_reset_misc(hw); ngbe_reset_misc(wx);
/* Store the permanent mac address */ /* Store the permanent mac address */
wx_get_mac_addr(wxhw, wxhw->mac.perm_addr); wx_get_mac_addr(wx, wx->mac.perm_addr);
/* reset num_rar_entries to 128 */ /* reset num_rar_entries to 128 */
wxhw->mac.num_rar_entries = NGBE_RAR_ENTRIES; wx->mac.num_rar_entries = NGBE_RAR_ENTRIES;
wx_init_rx_addrs(wxhw); wx_init_rx_addrs(wx);
pci_set_master(wxhw->pdev); pci_set_master(wx->pdev);
return 0; return 0;
} }
...@@ -7,6 +7,6 @@ ...@@ -7,6 +7,6 @@
#ifndef _NGBE_HW_H_ #ifndef _NGBE_HW_H_
#define _NGBE_HW_H_ #define _NGBE_HW_H_
int ngbe_eeprom_chksum_hostif(struct ngbe_hw *hw); int ngbe_eeprom_chksum_hostif(struct wx *wx);
int ngbe_reset_hw(struct ngbe_hw *hw); int ngbe_reset_hw(struct wx *wx);
#endif /* _NGBE_HW_H_ */ #endif /* _NGBE_HW_H_ */
...@@ -90,50 +90,26 @@ ...@@ -90,50 +90,26 @@
#define NGBE_FW_CMD_ST_PASS 0x80658383 #define NGBE_FW_CMD_ST_PASS 0x80658383
#define NGBE_FW_CMD_ST_FAIL 0x70657376 #define NGBE_FW_CMD_ST_FAIL 0x70657376
enum ngbe_phy_type { #define NGBE_MAX_FDIR_INDICES 7
ngbe_phy_unknown = 0,
ngbe_phy_none, #define NGBE_MAX_RX_QUEUES (NGBE_MAX_FDIR_INDICES + 1)
ngbe_phy_internal, #define NGBE_MAX_TX_QUEUES (NGBE_MAX_FDIR_INDICES + 1)
ngbe_phy_m88e1512,
ngbe_phy_m88e1512_sfi, #define NGBE_ETH_LENGTH_OF_ADDRESS 6
ngbe_phy_m88e1512_unknown, #define NGBE_MAX_MSIX_VECTORS 0x09
ngbe_phy_yt8521s, #define NGBE_RAR_ENTRIES 32
ngbe_phy_yt8521s_sfi,
ngbe_phy_internal_yt8521s_sfi, /* TX/RX descriptor defines */
ngbe_phy_generic #define NGBE_DEFAULT_TXD 512 /* default ring size */
}; #define NGBE_DEFAULT_TX_WORK 256
#define NGBE_MAX_TXD 8192
enum ngbe_media_type { #define NGBE_MIN_TXD 128
ngbe_media_type_unknown = 0,
ngbe_media_type_fiber, #define NGBE_DEFAULT_RXD 512 /* default ring size */
ngbe_media_type_copper, #define NGBE_DEFAULT_RX_WORK 256
ngbe_media_type_backplane, #define NGBE_MAX_RXD 8192
}; #define NGBE_MIN_RXD 128
enum ngbe_mac_type { extern char ngbe_driver_name[];
ngbe_mac_type_unknown = 0,
ngbe_mac_type_mdi,
ngbe_mac_type_rgmii
};
struct ngbe_phy_info {
enum ngbe_phy_type type;
enum ngbe_media_type media_type;
u32 addr;
u32 id;
bool reset_if_overtemp;
};
struct ngbe_hw {
struct wx_hw wxhw;
struct ngbe_phy_info phy;
enum ngbe_mac_type mac_type;
bool wol_enabled;
bool ncsi_enabled;
bool gpio_ctrl;
};
#endif /* _NGBE_TYPE_H_ */ #endif /* _NGBE_TYPE_H_ */
/* SPDX-License-Identifier: GPL-2.0 */
/* Copyright (c) 2015 - 2022 Beijing WangXun Technology Co., Ltd. */
#ifndef _TXGBE_H_
#define _TXGBE_H_
#define TXGBE_MAX_FDIR_INDICES 63
#define TXGBE_MAX_RX_QUEUES (TXGBE_MAX_FDIR_INDICES + 1)
#define TXGBE_MAX_TX_QUEUES (TXGBE_MAX_FDIR_INDICES + 1)
#define TXGBE_SP_MAX_TX_QUEUES 128
#define TXGBE_SP_MAX_RX_QUEUES 128
#define TXGBE_SP_RAR_ENTRIES 128
#define TXGBE_SP_MC_TBL_SIZE 128
struct txgbe_mac_addr {
u8 addr[ETH_ALEN];
u16 state; /* bitmask */
u64 pools;
};
#define TXGBE_MAC_STATE_DEFAULT 0x1
#define TXGBE_MAC_STATE_MODIFIED 0x2
#define TXGBE_MAC_STATE_IN_USE 0x4
/* board specific private data structure */
struct txgbe_adapter {
u8 __iomem *io_addr; /* Mainly for iounmap use */
/* OS defined structs */
struct net_device *netdev;
struct pci_dev *pdev;
/* structs defined in txgbe_type.h */
struct txgbe_hw hw;
u16 msg_enable;
struct txgbe_mac_addr *mac_table;
char eeprom_id[32];
};
extern char txgbe_driver_name[];
#endif /* _TXGBE_H_ */
...@@ -12,70 +12,67 @@ ...@@ -12,70 +12,67 @@
#include "../libwx/wx_hw.h" #include "../libwx/wx_hw.h"
#include "txgbe_type.h" #include "txgbe_type.h"
#include "txgbe_hw.h" #include "txgbe_hw.h"
#include "txgbe.h"
/** /**
* txgbe_init_thermal_sensor_thresh - Inits thermal sensor thresholds * txgbe_init_thermal_sensor_thresh - Inits thermal sensor thresholds
* @hw: pointer to hardware structure * @wx: pointer to hardware structure
* *
* Inits the thermal sensor thresholds according to the NVM map * Inits the thermal sensor thresholds according to the NVM map
* and save off the threshold and location values into mac.thermal_sensor_data * and save off the threshold and location values into mac.thermal_sensor_data
**/ **/
static void txgbe_init_thermal_sensor_thresh(struct txgbe_hw *hw) static void txgbe_init_thermal_sensor_thresh(struct wx *wx)
{ {
struct wx_hw *wxhw = &hw->wxhw; struct wx_thermal_sensor_data *data = &wx->mac.sensor;
struct wx_thermal_sensor_data *data = &wxhw->mac.sensor;
memset(data, 0, sizeof(struct wx_thermal_sensor_data)); memset(data, 0, sizeof(struct wx_thermal_sensor_data));
/* Only support thermal sensors attached to SP physical port 0 */ /* Only support thermal sensors attached to SP physical port 0 */
if (wxhw->bus.func) if (wx->bus.func)
return; return;
wr32(wxhw, TXGBE_TS_CTL, TXGBE_TS_CTL_EVAL_MD); wr32(wx, TXGBE_TS_CTL, TXGBE_TS_CTL_EVAL_MD);
wr32(wxhw, WX_TS_INT_EN, wr32(wx, WX_TS_INT_EN,
WX_TS_INT_EN_ALARM_INT_EN | WX_TS_INT_EN_DALARM_INT_EN); WX_TS_INT_EN_ALARM_INT_EN | WX_TS_INT_EN_DALARM_INT_EN);
wr32(wxhw, WX_TS_EN, WX_TS_EN_ENA); wr32(wx, WX_TS_EN, WX_TS_EN_ENA);
data->alarm_thresh = 100; data->alarm_thresh = 100;
wr32(wxhw, WX_TS_ALARM_THRE, 677); wr32(wx, WX_TS_ALARM_THRE, 677);
data->dalarm_thresh = 90; data->dalarm_thresh = 90;
wr32(wxhw, WX_TS_DALARM_THRE, 614); wr32(wx, WX_TS_DALARM_THRE, 614);
} }
/** /**
* txgbe_read_pba_string - Reads part number string from EEPROM * txgbe_read_pba_string - Reads part number string from EEPROM
* @hw: pointer to hardware structure * @wx: pointer to hardware structure
* @pba_num: stores the part number string from the EEPROM * @pba_num: stores the part number string from the EEPROM
* @pba_num_size: part number string buffer length * @pba_num_size: part number string buffer length
* *
* Reads the part number string from the EEPROM. * Reads the part number string from the EEPROM.
**/ **/
int txgbe_read_pba_string(struct txgbe_hw *hw, u8 *pba_num, u32 pba_num_size) int txgbe_read_pba_string(struct wx *wx, u8 *pba_num, u32 pba_num_size)
{ {
u16 pba_ptr, offset, length, data; u16 pba_ptr, offset, length, data;
struct wx_hw *wxhw = &hw->wxhw;
int ret_val; int ret_val;
if (!pba_num) { if (!pba_num) {
wx_err(wxhw, "PBA string buffer was null\n"); wx_err(wx, "PBA string buffer was null\n");
return -EINVAL; return -EINVAL;
} }
ret_val = wx_read_ee_hostif(wxhw, ret_val = wx_read_ee_hostif(wx,
wxhw->eeprom.sw_region_offset + TXGBE_PBANUM0_PTR, wx->eeprom.sw_region_offset + TXGBE_PBANUM0_PTR,
&data); &data);
if (ret_val != 0) { if (ret_val != 0) {
wx_err(wxhw, "NVM Read Error\n"); wx_err(wx, "NVM Read Error\n");
return ret_val; return ret_val;
} }
ret_val = wx_read_ee_hostif(wxhw, ret_val = wx_read_ee_hostif(wx,
wxhw->eeprom.sw_region_offset + TXGBE_PBANUM1_PTR, wx->eeprom.sw_region_offset + TXGBE_PBANUM1_PTR,
&pba_ptr); &pba_ptr);
if (ret_val != 0) { if (ret_val != 0) {
wx_err(wxhw, "NVM Read Error\n"); wx_err(wx, "NVM Read Error\n");
return ret_val; return ret_val;
} }
...@@ -84,11 +81,11 @@ int txgbe_read_pba_string(struct txgbe_hw *hw, u8 *pba_num, u32 pba_num_size) ...@@ -84,11 +81,11 @@ int txgbe_read_pba_string(struct txgbe_hw *hw, u8 *pba_num, u32 pba_num_size)
* and we can decode it into an ascii string * and we can decode it into an ascii string
*/ */
if (data != TXGBE_PBANUM_PTR_GUARD) { if (data != TXGBE_PBANUM_PTR_GUARD) {
wx_err(wxhw, "NVM PBA number is not stored as string\n"); wx_err(wx, "NVM PBA number is not stored as string\n");
/* we will need 11 characters to store the PBA */ /* we will need 11 characters to store the PBA */
if (pba_num_size < 11) { if (pba_num_size < 11) {
wx_err(wxhw, "PBA string buffer too small\n"); wx_err(wx, "PBA string buffer too small\n");
return -ENOMEM; return -ENOMEM;
} }
...@@ -118,20 +115,20 @@ int txgbe_read_pba_string(struct txgbe_hw *hw, u8 *pba_num, u32 pba_num_size) ...@@ -118,20 +115,20 @@ int txgbe_read_pba_string(struct txgbe_hw *hw, u8 *pba_num, u32 pba_num_size)
return 0; return 0;
} }
ret_val = wx_read_ee_hostif(wxhw, pba_ptr, &length); ret_val = wx_read_ee_hostif(wx, pba_ptr, &length);
if (ret_val != 0) { if (ret_val != 0) {
wx_err(wxhw, "NVM Read Error\n"); wx_err(wx, "NVM Read Error\n");
return ret_val; return ret_val;
} }
if (length == 0xFFFF || length == 0) { if (length == 0xFFFF || length == 0) {
wx_err(wxhw, "NVM PBA number section invalid length\n"); wx_err(wx, "NVM PBA number section invalid length\n");
return -EINVAL; return -EINVAL;
} }
/* check if pba_num buffer is big enough */ /* check if pba_num buffer is big enough */
if (pba_num_size < (((u32)length * 2) - 1)) { if (pba_num_size < (((u32)length * 2) - 1)) {
wx_err(wxhw, "PBA string buffer too small\n"); wx_err(wx, "PBA string buffer too small\n");
return -ENOMEM; return -ENOMEM;
} }
...@@ -140,9 +137,9 @@ int txgbe_read_pba_string(struct txgbe_hw *hw, u8 *pba_num, u32 pba_num_size) ...@@ -140,9 +137,9 @@ int txgbe_read_pba_string(struct txgbe_hw *hw, u8 *pba_num, u32 pba_num_size)
length--; length--;
for (offset = 0; offset < length; offset++) { for (offset = 0; offset < length; offset++) {
ret_val = wx_read_ee_hostif(wxhw, pba_ptr + offset, &data); ret_val = wx_read_ee_hostif(wx, pba_ptr + offset, &data);
if (ret_val != 0) { if (ret_val != 0) {
wx_err(wxhw, "NVM Read Error\n"); wx_err(wx, "NVM Read Error\n");
return ret_val; return ret_val;
} }
pba_num[offset * 2] = (u8)(data >> 8); pba_num[offset * 2] = (u8)(data >> 8);
...@@ -155,14 +152,13 @@ int txgbe_read_pba_string(struct txgbe_hw *hw, u8 *pba_num, u32 pba_num_size) ...@@ -155,14 +152,13 @@ int txgbe_read_pba_string(struct txgbe_hw *hw, u8 *pba_num, u32 pba_num_size)
/** /**
* txgbe_calc_eeprom_checksum - Calculates and returns the checksum * txgbe_calc_eeprom_checksum - Calculates and returns the checksum
* @hw: pointer to hardware structure * @wx: pointer to hardware structure
* @checksum: pointer to cheksum * @checksum: pointer to cheksum
* *
* Returns a negative error code on error * Returns a negative error code on error
**/ **/
static int txgbe_calc_eeprom_checksum(struct txgbe_hw *hw, u16 *checksum) static int txgbe_calc_eeprom_checksum(struct wx *wx, u16 *checksum)
{ {
struct wx_hw *wxhw = &hw->wxhw;
u16 *eeprom_ptrs = NULL; u16 *eeprom_ptrs = NULL;
u32 buffer_size = 0; u32 buffer_size = 0;
u16 *buffer = NULL; u16 *buffer = NULL;
...@@ -170,7 +166,7 @@ static int txgbe_calc_eeprom_checksum(struct txgbe_hw *hw, u16 *checksum) ...@@ -170,7 +166,7 @@ static int txgbe_calc_eeprom_checksum(struct txgbe_hw *hw, u16 *checksum)
int status; int status;
u16 i; u16 i;
wx_init_eeprom_params(wxhw); wx_init_eeprom_params(wx);
if (!buffer) { if (!buffer) {
eeprom_ptrs = kvmalloc_array(TXGBE_EEPROM_LAST_WORD, sizeof(u16), eeprom_ptrs = kvmalloc_array(TXGBE_EEPROM_LAST_WORD, sizeof(u16),
...@@ -178,11 +174,11 @@ static int txgbe_calc_eeprom_checksum(struct txgbe_hw *hw, u16 *checksum) ...@@ -178,11 +174,11 @@ static int txgbe_calc_eeprom_checksum(struct txgbe_hw *hw, u16 *checksum)
if (!eeprom_ptrs) if (!eeprom_ptrs)
return -ENOMEM; return -ENOMEM;
/* Read pointer area */ /* Read pointer area */
status = wx_read_ee_hostif_buffer(wxhw, 0, status = wx_read_ee_hostif_buffer(wx, 0,
TXGBE_EEPROM_LAST_WORD, TXGBE_EEPROM_LAST_WORD,
eeprom_ptrs); eeprom_ptrs);
if (status != 0) { if (status != 0) {
wx_err(wxhw, "Failed to read EEPROM image\n"); wx_err(wx, "Failed to read EEPROM image\n");
kvfree(eeprom_ptrs); kvfree(eeprom_ptrs);
return status; return status;
} }
...@@ -194,7 +190,7 @@ static int txgbe_calc_eeprom_checksum(struct txgbe_hw *hw, u16 *checksum) ...@@ -194,7 +190,7 @@ static int txgbe_calc_eeprom_checksum(struct txgbe_hw *hw, u16 *checksum)
} }
for (i = 0; i < TXGBE_EEPROM_LAST_WORD; i++) for (i = 0; i < TXGBE_EEPROM_LAST_WORD; i++)
if (i != wxhw->eeprom.sw_region_offset + TXGBE_EEPROM_CHECKSUM) if (i != wx->eeprom.sw_region_offset + TXGBE_EEPROM_CHECKSUM)
*checksum += local_buffer[i]; *checksum += local_buffer[i];
if (eeprom_ptrs) if (eeprom_ptrs)
...@@ -210,15 +206,14 @@ static int txgbe_calc_eeprom_checksum(struct txgbe_hw *hw, u16 *checksum) ...@@ -210,15 +206,14 @@ static int txgbe_calc_eeprom_checksum(struct txgbe_hw *hw, u16 *checksum)
/** /**
* txgbe_validate_eeprom_checksum - Validate EEPROM checksum * txgbe_validate_eeprom_checksum - Validate EEPROM checksum
* @hw: pointer to hardware structure * @wx: pointer to hardware structure
* @checksum_val: calculated checksum * @checksum_val: calculated checksum
* *
* Performs checksum calculation and validates the EEPROM checksum. If the * Performs checksum calculation and validates the EEPROM checksum. If the
* caller does not need checksum_val, the value can be NULL. * caller does not need checksum_val, the value can be NULL.
**/ **/
int txgbe_validate_eeprom_checksum(struct txgbe_hw *hw, u16 *checksum_val) int txgbe_validate_eeprom_checksum(struct wx *wx, u16 *checksum_val)
{ {
struct wx_hw *wxhw = &hw->wxhw;
u16 read_checksum = 0; u16 read_checksum = 0;
u16 checksum; u16 checksum;
int status; int status;
...@@ -227,18 +222,18 @@ int txgbe_validate_eeprom_checksum(struct txgbe_hw *hw, u16 *checksum_val) ...@@ -227,18 +222,18 @@ int txgbe_validate_eeprom_checksum(struct txgbe_hw *hw, u16 *checksum_val)
* not continue or we could be in for a very long wait while every * not continue or we could be in for a very long wait while every
* EEPROM read fails * EEPROM read fails
*/ */
status = wx_read_ee_hostif(wxhw, 0, &checksum); status = wx_read_ee_hostif(wx, 0, &checksum);
if (status) { if (status) {
wx_err(wxhw, "EEPROM read failed\n"); wx_err(wx, "EEPROM read failed\n");
return status; return status;
} }
checksum = 0; checksum = 0;
status = txgbe_calc_eeprom_checksum(hw, &checksum); status = txgbe_calc_eeprom_checksum(wx, &checksum);
if (status != 0) if (status != 0)
return status; return status;
status = wx_read_ee_hostif(wxhw, wxhw->eeprom.sw_region_offset + status = wx_read_ee_hostif(wx, wx->eeprom.sw_region_offset +
TXGBE_EEPROM_CHECKSUM, &read_checksum); TXGBE_EEPROM_CHECKSUM, &read_checksum);
if (status != 0) if (status != 0)
return status; return status;
...@@ -248,7 +243,7 @@ int txgbe_validate_eeprom_checksum(struct txgbe_hw *hw, u16 *checksum_val) ...@@ -248,7 +243,7 @@ int txgbe_validate_eeprom_checksum(struct txgbe_hw *hw, u16 *checksum_val)
*/ */
if (read_checksum != checksum) { if (read_checksum != checksum) {
status = -EIO; status = -EIO;
wx_err(wxhw, "Invalid EEPROM checksum\n"); wx_err(wx, "Invalid EEPROM checksum\n");
} }
/* If the user cares, return the calculated checksum */ /* If the user cares, return the calculated checksum */
...@@ -258,55 +253,52 @@ int txgbe_validate_eeprom_checksum(struct txgbe_hw *hw, u16 *checksum_val) ...@@ -258,55 +253,52 @@ int txgbe_validate_eeprom_checksum(struct txgbe_hw *hw, u16 *checksum_val)
return status; return status;
} }
static void txgbe_reset_misc(struct txgbe_hw *hw) static void txgbe_reset_misc(struct wx *wx)
{ {
struct wx_hw *wxhw = &hw->wxhw; wx_reset_misc(wx);
txgbe_init_thermal_sensor_thresh(wx);
wx_reset_misc(wxhw);
txgbe_init_thermal_sensor_thresh(hw);
} }
/** /**
* txgbe_reset_hw - Perform hardware reset * txgbe_reset_hw - Perform hardware reset
* @hw: pointer to hardware structure * @wx: pointer to wx structure
* *
* Resets the hardware by resetting the transmit and receive units, masks * Resets the hardware by resetting the transmit and receive units, masks
* and clears all interrupts, perform a PHY reset, and perform a link (MAC) * and clears all interrupts, perform a PHY reset, and perform a link (MAC)
* reset. * reset.
**/ **/
int txgbe_reset_hw(struct txgbe_hw *hw) int txgbe_reset_hw(struct wx *wx)
{ {
struct wx_hw *wxhw = &hw->wxhw;
int status; int status;
/* Call adapter stop to disable tx/rx and clear interrupts */ /* Call adapter stop to disable tx/rx and clear interrupts */
status = wx_stop_adapter(wxhw); status = wx_stop_adapter(wx);
if (status != 0) if (status != 0)
return status; return status;
if (!(((wxhw->subsystem_device_id & WX_NCSI_MASK) == WX_NCSI_SUP) || if (!(((wx->subsystem_device_id & WX_NCSI_MASK) == WX_NCSI_SUP) ||
((wxhw->subsystem_device_id & WX_WOL_MASK) == WX_WOL_SUP))) ((wx->subsystem_device_id & WX_WOL_MASK) == WX_WOL_SUP)))
wx_reset_hostif(wxhw); wx_reset_hostif(wx);
usleep_range(10, 100); usleep_range(10, 100);
status = wx_check_flash_load(wxhw, TXGBE_SPI_ILDR_STATUS_LAN_SW_RST(wxhw->bus.func)); status = wx_check_flash_load(wx, TXGBE_SPI_ILDR_STATUS_LAN_SW_RST(wx->bus.func));
if (status != 0) if (status != 0)
return status; return status;
txgbe_reset_misc(hw); txgbe_reset_misc(wx);
/* Store the permanent mac address */ /* Store the permanent mac address */
wx_get_mac_addr(wxhw, wxhw->mac.perm_addr); wx_get_mac_addr(wx, wx->mac.perm_addr);
/* Store MAC address from RAR0, clear receive address registers, and /* Store MAC address from RAR0, clear receive address registers, and
* clear the multicast table. Also reset num_rar_entries to 128, * clear the multicast table. Also reset num_rar_entries to 128,
* since we modify this value when programming the SAN MAC address. * since we modify this value when programming the SAN MAC address.
*/ */
wxhw->mac.num_rar_entries = TXGBE_SP_RAR_ENTRIES; wx->mac.num_rar_entries = TXGBE_SP_RAR_ENTRIES;
wx_init_rx_addrs(wxhw); wx_init_rx_addrs(wx);
pci_set_master(wxhw->pdev); pci_set_master(wx->pdev);
return 0; return 0;
} }
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
#ifndef _TXGBE_HW_H_ #ifndef _TXGBE_HW_H_
#define _TXGBE_HW_H_ #define _TXGBE_HW_H_
int txgbe_read_pba_string(struct txgbe_hw *hw, u8 *pba_num, u32 pba_num_size); int txgbe_read_pba_string(struct wx *wx, u8 *pba_num, u32 pba_num_size);
int txgbe_validate_eeprom_checksum(struct txgbe_hw *hw, u16 *checksum_val); int txgbe_validate_eeprom_checksum(struct wx *wx, u16 *checksum_val);
int txgbe_reset_hw(struct txgbe_hw *hw); int txgbe_reset_hw(struct wx *wx);
#endif /* _TXGBE_HW_H_ */ #endif /* _TXGBE_HW_H_ */
...@@ -67,8 +67,16 @@ ...@@ -67,8 +67,16 @@
#define TXGBE_PBANUM1_PTR 0x06 #define TXGBE_PBANUM1_PTR 0x06
#define TXGBE_PBANUM_PTR_GUARD 0xFAFA #define TXGBE_PBANUM_PTR_GUARD 0xFAFA
struct txgbe_hw { #define TXGBE_MAX_FDIR_INDICES 63
struct wx_hw wxhw;
}; #define TXGBE_MAX_RX_QUEUES (TXGBE_MAX_FDIR_INDICES + 1)
#define TXGBE_MAX_TX_QUEUES (TXGBE_MAX_FDIR_INDICES + 1)
#define TXGBE_SP_MAX_TX_QUEUES 128
#define TXGBE_SP_MAX_RX_QUEUES 128
#define TXGBE_SP_RAR_ENTRIES 128
#define TXGBE_SP_MC_TBL_SIZE 128
extern char txgbe_driver_name[];
#endif /* _TXGBE_TYPE_H_ */ #endif /* _TXGBE_TYPE_H_ */
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