提交 f85582f8 编写于 作者: D Dmitry Kravkov 提交者: David S. Miller

bnx2x: code beautify

This patch does not include any functional changes.
The changes are: empty lines, indentation and comments.
Signed-off-by: NDmitry Kravkov <dmitry@broadcom.com>
Signed-off-by: NEilon Greenstein <eilong@broadcom.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 c2bff63f
...@@ -180,13 +180,14 @@ void bnx2x_panic_dump(struct bnx2x *bp); ...@@ -180,13 +180,14 @@ void bnx2x_panic_dump(struct bnx2x *bp);
#define SHMEM2_WR(bp, field, val) REG_WR(bp, SHMEM2_ADDR(bp, field), val) #define SHMEM2_WR(bp, field, val) REG_WR(bp, SHMEM2_ADDR(bp, field), val)
#define MF_CFG_ADDR(bp, field) (bp->common.mf_cfg_base + \ #define MF_CFG_ADDR(bp, field) (bp->common.mf_cfg_base + \
offsetof(struct mf_cfg, field)) offsetof(struct mf_cfg, field))
#define MF2_CFG_ADDR(bp, field) (bp->common.mf2_cfg_base + \ #define MF2_CFG_ADDR(bp, field) (bp->common.mf2_cfg_base + \
offsetof(struct mf2_cfg, field)) offsetof(struct mf2_cfg, field))
#define MF_CFG_RD(bp, field) REG_RD(bp, MF_CFG_ADDR(bp, field)) #define MF_CFG_RD(bp, field) REG_RD(bp, MF_CFG_ADDR(bp, field))
#define MF_CFG_WR(bp, field, val) REG_WR(bp,\ #define MF_CFG_WR(bp, field, val) REG_WR(bp,\
MF_CFG_ADDR(bp, field), (val)) MF_CFG_ADDR(bp, field), (val))
#define MF2_CFG_RD(bp, field) REG_RD(bp, MF2_CFG_ADDR(bp, field)) #define MF2_CFG_RD(bp, field) REG_RD(bp, MF2_CFG_ADDR(bp, field))
#define SHMEM2_HAS(bp, field) ((bp)->common.shmem2_base && \ #define SHMEM2_HAS(bp, field) ((bp)->common.shmem2_base && \
(SHMEM2_RD((bp), size) > \ (SHMEM2_RD((bp), size) > \
offsetof(struct shmem2_region, field))) offsetof(struct shmem2_region, field)))
...@@ -310,7 +311,7 @@ struct bnx2x_fastpath { ...@@ -310,7 +311,7 @@ struct bnx2x_fastpath {
#define BNX2X_NAPI_WEIGHT 128 #define BNX2X_NAPI_WEIGHT 128
struct napi_struct napi; struct napi_struct napi;
union host_hc_status_block status_blk; union host_hc_status_block status_blk;
/* chip independed shortcuts into sb structure */ /* chip independed shortcuts into sb structure */
__le16 *sb_index_values; __le16 *sb_index_values;
__le16 *sb_running_index; __le16 *sb_running_index;
...@@ -349,8 +350,8 @@ struct bnx2x_fastpath { ...@@ -349,8 +350,8 @@ struct bnx2x_fastpath {
#define BNX2X_FP_STATE_TERMINATING 0xd0000 #define BNX2X_FP_STATE_TERMINATING 0xd0000
#define BNX2X_FP_STATE_TERMINATED 0xe0000 #define BNX2X_FP_STATE_TERMINATED 0xe0000
u8 index; /* number in fp array */ u8 index; /* number in fp array */
u8 cl_id; /* eth client id */ u8 cl_id; /* eth client id */
u8 cl_qzone_id; u8 cl_qzone_id;
u8 fw_sb_id; /* status block number in FW */ u8 fw_sb_id; /* status block number in FW */
u8 igu_sb_id; /* status block number in HW */ u8 igu_sb_id; /* status block number in HW */
...@@ -375,8 +376,6 @@ struct bnx2x_fastpath { ...@@ -375,8 +376,6 @@ struct bnx2x_fastpath {
u16 last_max_sge; u16 last_max_sge;
__le16 *rx_cons_sb; __le16 *rx_cons_sb;
unsigned long tx_pkt, unsigned long tx_pkt,
rx_pkt, rx_pkt,
rx_calls; rx_calls;
...@@ -977,7 +976,7 @@ struct bnx2x { ...@@ -977,7 +976,7 @@ struct bnx2x {
u32 mf2_config[E2_FUNC_MAX]; u32 mf2_config[E2_FUNC_MAX];
u16 mf_ov; u16 mf_ov;
u8 mf_mode; u8 mf_mode;
#define IS_MF(bp) (bp->mf_mode != 0) #define IS_MF(bp) (bp->mf_mode != 0)
u8 wol; u8 wol;
...@@ -1302,21 +1301,35 @@ struct bnx2x_func_init_params { ...@@ -1302,21 +1301,35 @@ struct bnx2x_func_init_params {
for (var = 1; var < BNX2X_NUM_QUEUES(bp); var++) for (var = 1; var < BNX2X_NUM_QUEUES(bp); var++)
#define WAIT_RAMROD_POLL 0x01
#define WAIT_RAMROD_COMMON 0x02
int bnx2x_wait_ramrod(struct bnx2x *bp, int state, int idx,
int *state_p, int flags);
/* dmae */
void bnx2x_read_dmae(struct bnx2x *bp, u32 src_addr, u32 len32); void bnx2x_read_dmae(struct bnx2x *bp, u32 src_addr, u32 len32);
void bnx2x_write_dmae(struct bnx2x *bp, dma_addr_t dma_addr, u32 dst_addr, void bnx2x_write_dmae(struct bnx2x *bp, dma_addr_t dma_addr, u32 dst_addr,
u32 len32); u32 len32);
void bnx2x_write_dmae_phys_len(struct bnx2x *bp, dma_addr_t phys_addr,
u32 addr, u32 len);
void bnx2x_post_dmae(struct bnx2x *bp, struct dmae_command *dmae, int idx);
u32 bnx2x_dmae_opcode_add_comp(u32 opcode, u8 comp_type);
u32 bnx2x_dmae_opcode_clr_src_reset(u32 opcode);
u32 bnx2x_dmae_opcode(struct bnx2x *bp, u8 src_type, u8 dst_type,
bool with_comp, u8 comp_type);
int bnx2x_get_gpio(struct bnx2x *bp, int gpio_num, u8 port); int bnx2x_get_gpio(struct bnx2x *bp, int gpio_num, u8 port);
int bnx2x_set_gpio(struct bnx2x *bp, int gpio_num, u32 mode, u8 port); int bnx2x_set_gpio(struct bnx2x *bp, int gpio_num, u32 mode, u8 port);
int bnx2x_set_gpio_int(struct bnx2x *bp, int gpio_num, u32 mode, u8 port); int bnx2x_set_gpio_int(struct bnx2x *bp, int gpio_num, u32 mode, u8 port);
u32 bnx2x_fw_command(struct bnx2x *bp, u32 command, u32 param); u32 bnx2x_fw_command(struct bnx2x *bp, u32 command, u32 param);
void bnx2x_reg_wr_ind(struct bnx2x *bp, u32 addr, u32 val); void bnx2x_reg_wr_ind(struct bnx2x *bp, u32 addr, u32 val);
void bnx2x_write_dmae_phys_len(struct bnx2x *bp, dma_addr_t phys_addr,
u32 addr, u32 len);
void bnx2x_calc_fc_adv(struct bnx2x *bp); void bnx2x_calc_fc_adv(struct bnx2x *bp);
int bnx2x_sp_post(struct bnx2x *bp, int command, int cid, int bnx2x_sp_post(struct bnx2x *bp, int command, int cid,
u32 data_hi, u32 data_lo, int common); u32 data_hi, u32 data_lo, int common);
void bnx2x_update_coalesce(struct bnx2x *bp); void bnx2x_update_coalesce(struct bnx2x *bp);
int bnx2x_get_link_cfg_idx(struct bnx2x *bp); int bnx2x_get_link_cfg_idx(struct bnx2x *bp);
static inline u32 reg_poll(struct bnx2x *bp, u32 reg, u32 expected, int ms, static inline u32 reg_poll(struct bnx2x *bp, u32 reg, u32 expected, int ms,
int wait) int wait)
{ {
...@@ -1333,6 +1346,7 @@ static inline u32 reg_poll(struct bnx2x *bp, u32 reg, u32 expected, int ms, ...@@ -1333,6 +1346,7 @@ static inline u32 reg_poll(struct bnx2x *bp, u32 reg, u32 expected, int ms,
return val; return val;
} }
#define BNX2X_ILT_ZALLOC(x, y, size) \ #define BNX2X_ILT_ZALLOC(x, y, size) \
do { \ do { \
x = pci_alloc_consistent(bp->pdev, size, y); \ x = pci_alloc_consistent(bp->pdev, size, y); \
...@@ -1353,6 +1367,8 @@ static inline u32 reg_poll(struct bnx2x *bp, u32 reg, u32 expected, int ms, ...@@ -1353,6 +1367,8 @@ static inline u32 reg_poll(struct bnx2x *bp, u32 reg, u32 expected, int ms,
#define ILT_NUM_PAGE_ENTRIES (3072) #define ILT_NUM_PAGE_ENTRIES (3072)
/* In 57710/11 we use whole table since we have 8 func /* In 57710/11 we use whole table since we have 8 func
* In 57712 we have only 4 func, but use same size per func, then only half of
* the table in use
*/ */
#define ILT_PER_FUNC (ILT_NUM_PAGE_ENTRIES/8) #define ILT_PER_FUNC (ILT_NUM_PAGE_ENTRIES/8)
...@@ -1366,14 +1382,13 @@ static inline u32 reg_poll(struct bnx2x *bp, u32 reg, u32 expected, int ms, ...@@ -1366,14 +1382,13 @@ static inline u32 reg_poll(struct bnx2x *bp, u32 reg, u32 expected, int ms,
#define ONCHIP_ADDR1(x) ((u32)(((u64)x >> 12) & 0xFFFFFFFF)) #define ONCHIP_ADDR1(x) ((u32)(((u64)x >> 12) & 0xFFFFFFFF))
#define ONCHIP_ADDR2(x) ((u32)((1 << 20) | ((u64)x >> 44))) #define ONCHIP_ADDR2(x) ((u32)((1 << 20) | ((u64)x >> 44)))
/* load/unload mode */ /* load/unload mode */
#define LOAD_NORMAL 0 #define LOAD_NORMAL 0
#define LOAD_OPEN 1 #define LOAD_OPEN 1
#define LOAD_DIAG 2 #define LOAD_DIAG 2
#define UNLOAD_NORMAL 0 #define UNLOAD_NORMAL 0
#define UNLOAD_CLOSE 1 #define UNLOAD_CLOSE 1
#define UNLOAD_RECOVERY 2 #define UNLOAD_RECOVERY 2
/* DMAE command defines */ /* DMAE command defines */
...@@ -1447,7 +1462,6 @@ static inline u32 reg_poll(struct bnx2x *bp, u32 reg, u32 expected, int ms, ...@@ -1447,7 +1462,6 @@ static inline u32 reg_poll(struct bnx2x *bp, u32 reg, u32 expected, int ms,
#define PMF_DMAE_C(bp) (BP_PORT(bp) * MAX_DMAE_C_PER_PORT + \ #define PMF_DMAE_C(bp) (BP_PORT(bp) * MAX_DMAE_C_PER_PORT + \
E1HVN_MAX) E1HVN_MAX)
/* PCIE link and speed */ /* PCIE link and speed */
#define PCICFG_LINK_WIDTH 0x1f00000 #define PCICFG_LINK_WIDTH 0x1f00000
#define PCICFG_LINK_WIDTH_SHIFT 20 #define PCICFG_LINK_WIDTH_SHIFT 20
...@@ -1596,6 +1610,7 @@ static inline u32 reg_poll(struct bnx2x *bp, u32 reg, u32 expected, int ms, ...@@ -1596,6 +1610,7 @@ static inline u32 reg_poll(struct bnx2x *bp, u32 reg, u32 expected, int ms,
#define BNX2X_SP_DSB_INDEX \ #define BNX2X_SP_DSB_INDEX \
(&bp->def_status_blk->sp_sb.\ (&bp->def_status_blk->sp_sb.\
index_values[HC_SP_INDEX_ETH_DEF_CONS]) index_values[HC_SP_INDEX_ETH_DEF_CONS])
#define SET_FLAG(value, mask, flag) \ #define SET_FLAG(value, mask, flag) \
do {\ do {\
(value) &= ~(mask);\ (value) &= ~(mask);\
...@@ -1630,6 +1645,7 @@ static inline u32 reg_poll(struct bnx2x *bp, u32 reg, u32 expected, int ms, ...@@ -1630,6 +1645,7 @@ static inline u32 reg_poll(struct bnx2x *bp, u32 reg, u32 expected, int ms,
#ifndef ETH_MAX_RX_CLIENTS_E2 #ifndef ETH_MAX_RX_CLIENTS_E2
#define ETH_MAX_RX_CLIENTS_E2 ETH_MAX_RX_CLIENTS_E1H #define ETH_MAX_RX_CLIENTS_E2 ETH_MAX_RX_CLIENTS_E1H
#endif #endif
#define BNX2X_VPD_LEN 128 #define BNX2X_VPD_LEN 128
#define VENDOR_ID_LEN 4 #define VENDOR_ID_LEN 4
...@@ -1649,20 +1665,6 @@ static inline u32 reg_poll(struct bnx2x *bp, u32 reg, u32 expected, int ms, ...@@ -1649,20 +1665,6 @@ static inline u32 reg_poll(struct bnx2x *bp, u32 reg, u32 expected, int ms,
BNX2X_EXTERN int load_count[2][3]; /* per path: 0-common, 1-port0, 2-port1 */ BNX2X_EXTERN int load_count[2][3]; /* per path: 0-common, 1-port0, 2-port1 */
/* MISC_REG_RESET_REG - this is here for the hsi to work don't touch */
extern void bnx2x_set_ethtool_ops(struct net_device *netdev); extern void bnx2x_set_ethtool_ops(struct net_device *netdev);
void bnx2x_post_dmae(struct bnx2x *bp, struct dmae_command *dmae, int idx);
u32 bnx2x_dmae_opcode_add_comp(u32 opcode, u8 comp_type);
u32 bnx2x_dmae_opcode_clr_src_reset(u32 opcode);
u32 bnx2x_dmae_opcode(struct bnx2x *bp, u8 src_type, u8 dst_type,
bool with_comp, u8 comp_type);
#define WAIT_RAMROD_POLL 0x01
#define WAIT_RAMROD_COMMON 0x02
int bnx2x_wait_ramrod(struct bnx2x *bp, int state, int idx,
int *state_p, int flags);
#endif /* bnx2x.h */ #endif /* bnx2x.h */
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
* *
*/ */
#include <linux/etherdevice.h> #include <linux/etherdevice.h>
#include <linux/ip.h> #include <linux/ip.h>
#include <net/ipv6.h> #include <net/ipv6.h>
...@@ -136,7 +135,6 @@ int bnx2x_tx_int(struct bnx2x_fastpath *fp) ...@@ -136,7 +135,6 @@ int bnx2x_tx_int(struct bnx2x_fastpath *fp)
*/ */
smp_mb(); smp_mb();
/* TBD need a thresh? */
if (unlikely(netif_tx_queue_stopped(txq))) { if (unlikely(netif_tx_queue_stopped(txq))) {
/* Taking tx_lock() is needed to prevent reenabling the queue /* Taking tx_lock() is needed to prevent reenabling the queue
* while it's empty. This could have happen if rx_action() gets * while it's empty. This could have happen if rx_action() gets
...@@ -623,6 +621,7 @@ int bnx2x_rx_int(struct bnx2x_fastpath *fp, int budget) ...@@ -623,6 +621,7 @@ int bnx2x_rx_int(struct bnx2x_fastpath *fp, int budget)
bnx2x_set_skb_rxhash(bp, cqe, skb); bnx2x_set_skb_rxhash(bp, cqe, skb);
skb_checksum_none_assert(skb); skb_checksum_none_assert(skb);
if (bp->rx_csum) { if (bp->rx_csum) {
if (likely(BNX2X_RX_CSUM_OK(cqe))) if (likely(BNX2X_RX_CSUM_OK(cqe)))
skb->ip_summed = CHECKSUM_UNNECESSARY; skb->ip_summed = CHECKSUM_UNNECESSARY;
...@@ -704,7 +703,6 @@ static irqreturn_t bnx2x_msix_fp_int(int irq, void *fp_cookie) ...@@ -704,7 +703,6 @@ static irqreturn_t bnx2x_msix_fp_int(int irq, void *fp_cookie)
return IRQ_HANDLED; return IRQ_HANDLED;
} }
/* HW Lock for shared dual port PHYs */ /* HW Lock for shared dual port PHYs */
void bnx2x_acquire_phy_lock(struct bnx2x *bp) void bnx2x_acquire_phy_lock(struct bnx2x *bp)
{ {
...@@ -916,6 +914,7 @@ void bnx2x_init_rx_rings(struct bnx2x *bp) ...@@ -916,6 +914,7 @@ void bnx2x_init_rx_rings(struct bnx2x *bp)
} }
} }
} }
static void bnx2x_free_tx_skbs(struct bnx2x *bp) static void bnx2x_free_tx_skbs(struct bnx2x *bp)
{ {
int i; int i;
...@@ -1185,6 +1184,7 @@ void bnx2x_set_num_queues(struct bnx2x *bp) ...@@ -1185,6 +1184,7 @@ void bnx2x_set_num_queues(struct bnx2x *bp)
case ETH_RSS_MODE_REGULAR: case ETH_RSS_MODE_REGULAR:
bp->num_queues = bnx2x_calc_num_queues(bp); bp->num_queues = bnx2x_calc_num_queues(bp);
break; break;
default: default:
bp->num_queues = 1; bp->num_queues = 1;
break; break;
...@@ -1354,6 +1354,7 @@ int bnx2x_nic_load(struct bnx2x *bp, int load_mode) ...@@ -1354,6 +1354,7 @@ int bnx2x_nic_load(struct bnx2x *bp, int load_mode)
/* Enable Timer scan */ /* Enable Timer scan */
REG_WR(bp, TM_REG_EN_LINEAR0_TIMER + BP_PORT(bp)*4, 1); REG_WR(bp, TM_REG_EN_LINEAR0_TIMER + BP_PORT(bp)*4, 1);
#endif #endif
for_each_nondefault_queue(bp, i) { for_each_nondefault_queue(bp, i) {
rc = bnx2x_setup_client(bp, &bp->fp[i], 0); rc = bnx2x_setup_client(bp, &bp->fp[i], 0);
if (rc) if (rc)
...@@ -1473,11 +1474,13 @@ int bnx2x_nic_unload(struct bnx2x *bp, int unload_mode) ...@@ -1473,11 +1474,13 @@ int bnx2x_nic_unload(struct bnx2x *bp, int unload_mode)
/* Stop Tx */ /* Stop Tx */
bnx2x_tx_disable(bp); bnx2x_tx_disable(bp);
del_timer_sync(&bp->timer); del_timer_sync(&bp->timer);
SHMEM_WR(bp, func_mb[BP_FW_MB_IDX(bp)].drv_pulse_mb, SHMEM_WR(bp, func_mb[BP_FW_MB_IDX(bp)].drv_pulse_mb,
(DRV_PULSE_ALWAYS_ALIVE | bp->fw_drv_pulse_wr_seq)); (DRV_PULSE_ALWAYS_ALIVE | bp->fw_drv_pulse_wr_seq));
bnx2x_stats_handle(bp, STATS_EVENT_STOP);
bnx2x_stats_handle(bp, STATS_EVENT_STOP);
/* Cleanup the chip if needed */ /* Cleanup the chip if needed */
if (unload_mode != UNLOAD_RECOVERY) if (unload_mode != UNLOAD_RECOVERY)
...@@ -1514,6 +1517,7 @@ int bnx2x_nic_unload(struct bnx2x *bp, int unload_mode) ...@@ -1514,6 +1517,7 @@ int bnx2x_nic_unload(struct bnx2x *bp, int unload_mode)
return 0; return 0;
} }
int bnx2x_set_power_state(struct bnx2x *bp, pci_power_t state) int bnx2x_set_power_state(struct bnx2x *bp, pci_power_t state)
{ {
u16 pmcsr; u16 pmcsr;
...@@ -1560,12 +1564,9 @@ int bnx2x_set_power_state(struct bnx2x *bp, pci_power_t state) ...@@ -1560,12 +1564,9 @@ int bnx2x_set_power_state(struct bnx2x *bp, pci_power_t state)
return 0; return 0;
} }
/* /*
* net_device service functions * net_device service functions
*/ */
int bnx2x_poll(struct napi_struct *napi, int budget) int bnx2x_poll(struct napi_struct *napi, int budget)
{ {
int work_done = 0; int work_done = 0;
...@@ -1595,19 +1596,19 @@ int bnx2x_poll(struct napi_struct *napi, int budget) ...@@ -1595,19 +1596,19 @@ int bnx2x_poll(struct napi_struct *napi, int budget)
/* Fall out from the NAPI loop if needed */ /* Fall out from the NAPI loop if needed */
if (!(bnx2x_has_rx_work(fp) || bnx2x_has_tx_work(fp))) { if (!(bnx2x_has_rx_work(fp) || bnx2x_has_tx_work(fp))) {
bnx2x_update_fpsb_idx(fp); bnx2x_update_fpsb_idx(fp);
/* bnx2x_has_rx_work() reads the status block, /* bnx2x_has_rx_work() reads the status block,
* thus we need to ensure that status block indices * thus we need to ensure that status block indices
* have been actually read (bnx2x_update_fpsb_idx) * have been actually read (bnx2x_update_fpsb_idx)
* prior to this check (bnx2x_has_rx_work) so that * prior to this check (bnx2x_has_rx_work) so that
* we won't write the "newer" value of the status block * we won't write the "newer" value of the status block
* to IGU (if there was a DMA right after * to IGU (if there was a DMA right after
* bnx2x_has_rx_work and if there is no rmb, the memory * bnx2x_has_rx_work and if there is no rmb, the memory
* reading (bnx2x_update_fpsb_idx) may be postponed * reading (bnx2x_update_fpsb_idx) may be postponed
* to right before bnx2x_ack_sb). In this case there * to right before bnx2x_ack_sb). In this case there
* will never be another interrupt until there is * will never be another interrupt until there is
* another update of the status block, while there * another update of the status block, while there
* is still unhandled work. * is still unhandled work.
*/ */
rmb(); rmb();
if (!(bnx2x_has_rx_work(fp) || bnx2x_has_tx_work(fp))) { if (!(bnx2x_has_rx_work(fp) || bnx2x_has_tx_work(fp))) {
...@@ -1626,7 +1627,6 @@ int bnx2x_poll(struct napi_struct *napi, int budget) ...@@ -1626,7 +1627,6 @@ int bnx2x_poll(struct napi_struct *napi, int budget)
return work_done; return work_done;
} }
/* we split the first BD into headers and data BDs /* we split the first BD into headers and data BDs
* to ease the pain of our fellow microcode engineers * to ease the pain of our fellow microcode engineers
* we use one mapping for both BDs * we use one mapping for both BDs
...@@ -1842,6 +1842,7 @@ static inline void bnx2x_set_pbd_gso(struct sk_buff *skb, ...@@ -1842,6 +1842,7 @@ static inline void bnx2x_set_pbd_gso(struct sk_buff *skb,
pbd->global_data |= ETH_TX_PARSE_BD_E1X_PSEUDO_CS_WITHOUT_LEN; pbd->global_data |= ETH_TX_PARSE_BD_E1X_PSEUDO_CS_WITHOUT_LEN;
} }
/** /**
* *
* @param skb * @param skb
...@@ -1914,6 +1915,7 @@ static inline u8 bnx2x_set_pbd_csum(struct bnx2x *bp, struct sk_buff *skb, ...@@ -1914,6 +1915,7 @@ static inline u8 bnx2x_set_pbd_csum(struct bnx2x *bp, struct sk_buff *skb,
return hlen; return hlen;
} }
/* called with netif_tx_lock /* called with netif_tx_lock
* bnx2x_tx_int() runs without netif_tx_lock unless it needs to call * bnx2x_tx_int() runs without netif_tx_lock unless it needs to call
* netif_wake_queue() * netif_wake_queue()
...@@ -2003,13 +2005,11 @@ netdev_tx_t bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -2003,13 +2005,11 @@ netdev_tx_t bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev)
tx_start_bd = &fp->tx_desc_ring[bd_prod].start_bd; tx_start_bd = &fp->tx_desc_ring[bd_prod].start_bd;
tx_start_bd->bd_flags.as_bitfield = ETH_TX_BD_FLAGS_START_BD; tx_start_bd->bd_flags.as_bitfield = ETH_TX_BD_FLAGS_START_BD;
SET_FLAG(tx_start_bd->general_data, SET_FLAG(tx_start_bd->general_data, ETH_TX_START_BD_ETH_ADDR_TYPE,
ETH_TX_START_BD_ETH_ADDR_TYPE, mac_type);
mac_type);
/* header nbd */ /* header nbd */
SET_FLAG(tx_start_bd->general_data, SET_FLAG(tx_start_bd->general_data, ETH_TX_START_BD_HDR_NBDS, 1);
ETH_TX_START_BD_HDR_NBDS,
1);
/* remember the first BD of the packet */ /* remember the first BD of the packet */
tx_buf->first_bd = fp->tx_bd_prod; tx_buf->first_bd = fp->tx_bd_prod;
...@@ -2065,9 +2065,11 @@ netdev_tx_t bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -2065,9 +2065,11 @@ netdev_tx_t bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev)
} }
/* Map skb linear data for DMA */
mapping = dma_map_single(&bp->pdev->dev, skb->data, mapping = dma_map_single(&bp->pdev->dev, skb->data,
skb_headlen(skb), DMA_TO_DEVICE); skb_headlen(skb), DMA_TO_DEVICE);
/* Setup the data pointer of the first BD of the packet */
tx_start_bd->addr_hi = cpu_to_le32(U64_HI(mapping)); tx_start_bd->addr_hi = cpu_to_le32(U64_HI(mapping));
tx_start_bd->addr_lo = cpu_to_le32(U64_LO(mapping)); tx_start_bd->addr_lo = cpu_to_le32(U64_LO(mapping));
nbd = skb_shinfo(skb)->nr_frags + 2; /* start_bd + pbd + frags */ nbd = skb_shinfo(skb)->nr_frags + 2; /* start_bd + pbd + frags */
...@@ -2101,6 +2103,7 @@ netdev_tx_t bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -2101,6 +2103,7 @@ netdev_tx_t bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev)
} }
tx_data_bd = (struct eth_tx_bd *)tx_start_bd; tx_data_bd = (struct eth_tx_bd *)tx_start_bd;
/* Handle fragmented skb */
for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
...@@ -2165,6 +2168,7 @@ netdev_tx_t bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -2165,6 +2168,7 @@ netdev_tx_t bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev)
fp->tx_db.data.prod += nbd; fp->tx_db.data.prod += nbd;
barrier(); barrier();
DOORBELL(bp, fp->cid, fp->tx_db.raw); DOORBELL(bp, fp->cid, fp->tx_db.raw);
mmiowb(); mmiowb();
...@@ -2187,6 +2191,7 @@ netdev_tx_t bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -2187,6 +2191,7 @@ netdev_tx_t bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev)
return NETDEV_TX_OK; return NETDEV_TX_OK;
} }
/* called with rtnl_lock */ /* called with rtnl_lock */
int bnx2x_change_mac_addr(struct net_device *dev, void *p) int bnx2x_change_mac_addr(struct net_device *dev, void *p)
{ {
...@@ -2319,6 +2324,7 @@ void bnx2x_vlan_rx_register(struct net_device *dev, ...@@ -2319,6 +2324,7 @@ void bnx2x_vlan_rx_register(struct net_device *dev,
} }
#endif #endif
int bnx2x_suspend(struct pci_dev *pdev, pm_message_t state) int bnx2x_suspend(struct pci_dev *pdev, pm_message_t state)
{ {
struct net_device *dev = pci_get_drvdata(pdev); struct net_device *dev = pci_get_drvdata(pdev);
......
...@@ -63,6 +63,15 @@ u8 bnx2x_link_test(struct bnx2x *bp, u8 is_serdes); ...@@ -63,6 +63,15 @@ u8 bnx2x_link_test(struct bnx2x *bp, u8 is_serdes);
*/ */
void bnx2x__link_status_update(struct bnx2x *bp); void bnx2x__link_status_update(struct bnx2x *bp);
/**
* Report link status to upper layer
*
* @param bp
*
* @return int
*/
void bnx2x_link_report(struct bnx2x *bp);
/** /**
* MSI-X slowpath interrupt handler * MSI-X slowpath interrupt handler
* *
...@@ -234,7 +243,7 @@ int bnx2x_release_hw_lock(struct bnx2x *bp, u32 resource); ...@@ -234,7 +243,7 @@ int bnx2x_release_hw_lock(struct bnx2x *bp, u32 resource);
/** /**
* Configure eth MAC address in the HW according to the value in * Configure eth MAC address in the HW according to the value in
* netdev->dev_addr for 57711 * netdev->dev_addr.
* *
* @param bp driver handle * @param bp driver handle
* @param set * @param set
...@@ -270,10 +279,11 @@ void bnx2x_init_sb(struct bnx2x *bp, dma_addr_t mapping, int vfid, ...@@ -270,10 +279,11 @@ void bnx2x_init_sb(struct bnx2x *bp, dma_addr_t mapping, int vfid,
u8 vf_valid, int fw_sb_id, int igu_sb_id); u8 vf_valid, int fw_sb_id, int igu_sb_id);
/** /**
* Reconfigure FW/HW according to dev->flags rx mode * Set MAC filtering configurations.
* *
* @param dev net_device * @remarks called with netif_tx_lock from dev_mcast.c
* *
* @param dev net_device
*/ */
void bnx2x_set_rx_mode(struct net_device *dev); void bnx2x_set_rx_mode(struct net_device *dev);
...@@ -295,17 +305,17 @@ void bnx2x_disable_close_the_gate(struct bnx2x *bp); ...@@ -295,17 +305,17 @@ void bnx2x_disable_close_the_gate(struct bnx2x *bp);
* Perform statistics handling according to event * Perform statistics handling according to event
* *
* @param bp driver handle * @param bp driver handle
* @param even tbnx2x_stats_event * @param event bnx2x_stats_event
*/ */
void bnx2x_stats_handle(struct bnx2x *bp, enum bnx2x_stats_event event); void bnx2x_stats_handle(struct bnx2x *bp, enum bnx2x_stats_event event);
/** /**
* Handle sp events * Handle ramrods completion
* *
* @param fp fastpath handle for the event * @param fp fastpath handle for the event
* @param rr_cqe eth_rx_cqe * @param rr_cqe eth_rx_cqe
*/ */
void bnx2x_sp_event(struct bnx2x_fastpath *fp, union eth_rx_cqe *rr_cqe); void bnx2x_sp_event(struct bnx2x_fastpath *fp, union eth_rx_cqe *rr_cqe);
/** /**
* Init/halt function before/after sending * Init/halt function before/after sending
...@@ -326,6 +336,46 @@ int bnx2x_func_stop(struct bnx2x *bp); ...@@ -326,6 +336,46 @@ int bnx2x_func_stop(struct bnx2x *bp);
*/ */
void bnx2x_ilt_set_info(struct bnx2x *bp); void bnx2x_ilt_set_info(struct bnx2x *bp);
/**
* Set power state to the requested value. Currently only D0 and
* D3hot are supported.
*
* @param bp
* @param state D0 or D3hot
*
* @return int
*/
int bnx2x_set_power_state(struct bnx2x *bp, pci_power_t state);
/* dev_close main block */
int bnx2x_nic_unload(struct bnx2x *bp, int unload_mode);
/* dev_open main block */
int bnx2x_nic_load(struct bnx2x *bp, int load_mode);
/* hard_xmit callback */
netdev_tx_t bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev);
int bnx2x_change_mac_addr(struct net_device *dev, void *p);
/* NAPI poll Rx part */
int bnx2x_rx_int(struct bnx2x_fastpath *fp, int budget);
/* NAPI poll Tx part */
int bnx2x_tx_int(struct bnx2x_fastpath *fp);
/* suspend/resume callbacks */
int bnx2x_suspend(struct pci_dev *pdev, pm_message_t state);
int bnx2x_resume(struct pci_dev *pdev);
/* Release IRQ vectors */
void bnx2x_free_irq(struct bnx2x *bp);
void bnx2x_init_rx_rings(struct bnx2x *bp);
void bnx2x_free_skbs(struct bnx2x *bp);
void bnx2x_netif_stop(struct bnx2x *bp, int disable_hw);
void bnx2x_netif_start(struct bnx2x *bp);
/** /**
* Fill msix_table, request vectors, update num_queues according * Fill msix_table, request vectors, update num_queues according
* to number of available vectors * to number of available vectors
...@@ -362,6 +412,51 @@ int bnx2x_setup_irqs(struct bnx2x *bp); ...@@ -362,6 +412,51 @@ int bnx2x_setup_irqs(struct bnx2x *bp);
* @return int * @return int
*/ */
int bnx2x_poll(struct napi_struct *napi, int budget); int bnx2x_poll(struct napi_struct *napi, int budget);
/**
* Allocate/release memories outsize main driver structure
*
* @param bp
*
* @return int
*/
int __devinit bnx2x_alloc_mem_bp(struct bnx2x *bp);
void bnx2x_free_mem_bp(struct bnx2x *bp);
/**
* Change mtu netdev callback
*
* @param dev
* @param new_mtu
*
* @return int
*/
int bnx2x_change_mtu(struct net_device *dev, int new_mtu);
/**
* tx timeout netdev callback
*
* @param dev
* @param new_mtu
*
* @return int
*/
void bnx2x_tx_timeout(struct net_device *dev);
#ifdef BCM_VLAN
/**
* vlan rx register netdev callback
*
* @param dev
* @param new_mtu
*
* @return int
*/
void bnx2x_vlan_rx_register(struct net_device *dev,
struct vlan_group *vlgrp);
#endif
static inline void bnx2x_update_fpsb_idx(struct bnx2x_fastpath *fp) static inline void bnx2x_update_fpsb_idx(struct bnx2x_fastpath *fp)
{ {
barrier(); /* status block is written to by the chip */ barrier(); /* status block is written to by the chip */
...@@ -558,9 +653,6 @@ static inline u16 bnx2x_ack_int(struct bnx2x *bp) ...@@ -558,9 +653,6 @@ static inline u16 bnx2x_ack_int(struct bnx2x *bp)
return bnx2x_igu_ack_int(bp); return bnx2x_igu_ack_int(bp);
} }
/*
* fast path service functions
*/
static inline int bnx2x_has_tx_work_unload(struct bnx2x_fastpath *fp) static inline int bnx2x_has_tx_work_unload(struct bnx2x_fastpath *fp)
{ {
/* Tell compiler that consumer and producer can change */ /* Tell compiler that consumer and producer can change */
...@@ -611,6 +703,7 @@ static inline int bnx2x_has_rx_work(struct bnx2x_fastpath *fp) ...@@ -611,6 +703,7 @@ static inline int bnx2x_has_rx_work(struct bnx2x_fastpath *fp)
rx_cons_sb++; rx_cons_sb++;
return (fp->rx_comp_cons != rx_cons_sb); return (fp->rx_comp_cons != rx_cons_sb);
} }
/** /**
* disables tx from stack point of view * disables tx from stack point of view
* *
...@@ -731,6 +824,7 @@ static inline int bnx2x_alloc_rx_sge(struct bnx2x *bp, ...@@ -731,6 +824,7 @@ static inline int bnx2x_alloc_rx_sge(struct bnx2x *bp,
return 0; return 0;
} }
static inline int bnx2x_alloc_rx_skb(struct bnx2x *bp, static inline int bnx2x_alloc_rx_skb(struct bnx2x *bp,
struct bnx2x_fastpath *fp, u16 index) struct bnx2x_fastpath *fp, u16 index)
{ {
...@@ -782,6 +876,7 @@ static inline void bnx2x_reuse_rx_skb(struct bnx2x_fastpath *fp, ...@@ -782,6 +876,7 @@ static inline void bnx2x_reuse_rx_skb(struct bnx2x_fastpath *fp,
dma_unmap_addr(cons_rx_buf, mapping)); dma_unmap_addr(cons_rx_buf, mapping));
*prod_bd = *cons_bd; *prod_bd = *cons_bd;
} }
static inline void bnx2x_free_rx_sge_range(struct bnx2x *bp, static inline void bnx2x_free_rx_sge_range(struct bnx2x *bp,
struct bnx2x_fastpath *fp, int last) struct bnx2x_fastpath *fp, int last)
{ {
...@@ -846,6 +941,7 @@ static inline void bnx2x_init_tx_rings(struct bnx2x *bp) ...@@ -846,6 +941,7 @@ static inline void bnx2x_init_tx_rings(struct bnx2x *bp)
fp->tx_pkt = 0; fp->tx_pkt = 0;
} }
} }
static inline void bnx2x_set_next_page_rx_bd(struct bnx2x_fastpath *fp) static inline void bnx2x_set_next_page_rx_bd(struct bnx2x_fastpath *fp)
{ {
int i; int i;
...@@ -931,40 +1027,11 @@ static inline void storm_memset_cmng(struct bnx2x *bp, ...@@ -931,40 +1027,11 @@ static inline void storm_memset_cmng(struct bnx2x *bp,
__storm_memset_struct(bp, addr, size, (u32 *)cmng); __storm_memset_struct(bp, addr, size, (u32 *)cmng);
} }
/* HW Lock for shared dual port PHYs */ /* HW Lock for shared dual port PHYs */
void bnx2x_acquire_phy_lock(struct bnx2x *bp); void bnx2x_acquire_phy_lock(struct bnx2x *bp);
void bnx2x_release_phy_lock(struct bnx2x *bp); void bnx2x_release_phy_lock(struct bnx2x *bp);
void bnx2x_link_report(struct bnx2x *bp);
int bnx2x_rx_int(struct bnx2x_fastpath *fp, int budget);
int bnx2x_tx_int(struct bnx2x_fastpath *fp);
void bnx2x_init_rx_rings(struct bnx2x *bp);
netdev_tx_t bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev);
int bnx2x_change_mac_addr(struct net_device *dev, void *p);
void bnx2x_tx_timeout(struct net_device *dev);
void bnx2x_vlan_rx_register(struct net_device *dev, struct vlan_group *vlgrp);
void bnx2x_netif_start(struct bnx2x *bp);
void bnx2x_netif_stop(struct bnx2x *bp, int disable_hw);
void bnx2x_free_irq(struct bnx2x *bp);
int bnx2x_suspend(struct pci_dev *pdev, pm_message_t state);
int bnx2x_resume(struct pci_dev *pdev);
void bnx2x_free_skbs(struct bnx2x *bp);
int bnx2x_change_mtu(struct net_device *dev, int new_mtu);
int bnx2x_nic_unload(struct bnx2x *bp, int unload_mode);
int bnx2x_nic_load(struct bnx2x *bp, int load_mode);
int bnx2x_set_power_state(struct bnx2x *bp, pci_power_t state);
/**
* Allocate/release memories outsize main driver structure
*
* @param bp
*
* @return int
*/
int __devinit bnx2x_alloc_mem_bp(struct bnx2x *bp);
void bnx2x_free_mem_bp(struct bnx2x *bp);
#define BNX2X_FW_IP_HDR_ALIGN_PAD 2 /* FW places hdr with this padding */ #define BNX2X_FW_IP_HDR_ALIGN_PAD 2 /* FW places hdr with this padding */
#endif /* BNX2X_CMN_H */ #endif /* BNX2X_CMN_H */
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
#include "bnx2x_cmn.h" #include "bnx2x_cmn.h"
#include "bnx2x_dump.h" #include "bnx2x_dump.h"
static int bnx2x_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) static int bnx2x_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
{ {
struct bnx2x *bp = netdev_priv(dev); struct bnx2x *bp = netdev_priv(dev);
...@@ -963,6 +962,7 @@ static int bnx2x_set_eeprom(struct net_device *dev, ...@@ -963,6 +962,7 @@ static int bnx2x_set_eeprom(struct net_device *dev,
return rc; return rc;
} }
static int bnx2x_get_coalesce(struct net_device *dev, static int bnx2x_get_coalesce(struct net_device *dev,
struct ethtool_coalesce *coal) struct ethtool_coalesce *coal)
{ {
...@@ -1288,6 +1288,7 @@ static int bnx2x_test_registers(struct bnx2x *bp) ...@@ -1288,6 +1288,7 @@ static int bnx2x_test_registers(struct bnx2x *bp)
save_val = REG_RD(bp, offset); save_val = REG_RD(bp, offset);
REG_WR(bp, offset, (wr_val & mask)); REG_WR(bp, offset, (wr_val & mask));
val = REG_RD(bp, offset); val = REG_RD(bp, offset);
/* Restore the original register's value */ /* Restore the original register's value */
...@@ -1471,6 +1472,7 @@ static int bnx2x_run_loopback(struct bnx2x *bp, int loopback_mode, u8 link_up) ...@@ -1471,6 +1472,7 @@ static int bnx2x_run_loopback(struct bnx2x *bp, int loopback_mode, u8 link_up)
/* turn on parsing and get a BD */ /* turn on parsing and get a BD */
bd_prod = TX_BD(NEXT_TX_IDX(bd_prod)); bd_prod = TX_BD(NEXT_TX_IDX(bd_prod));
pbd_e1x = &fp_tx->tx_desc_ring[bd_prod].parse_bd_e1x; pbd_e1x = &fp_tx->tx_desc_ring[bd_prod].parse_bd_e1x;
pbd_e2 = &fp_tx->tx_desc_ring[bd_prod].parse_bd_e2; pbd_e2 = &fp_tx->tx_desc_ring[bd_prod].parse_bd_e2;
...@@ -1714,6 +1716,7 @@ static void bnx2x_self_test(struct net_device *dev, ...@@ -1714,6 +1716,7 @@ static void bnx2x_self_test(struct net_device *dev,
buf[1] = 1; buf[1] = 1;
etest->flags |= ETH_TEST_FL_FAILED; etest->flags |= ETH_TEST_FL_FAILED;
} }
buf[2] = bnx2x_test_loopback(bp, link_up); buf[2] = bnx2x_test_loopback(bp, link_up);
if (buf[2] != 0) if (buf[2] != 0)
etest->flags |= ETH_TEST_FL_FAILED; etest->flags |= ETH_TEST_FL_FAILED;
......
此差异已折叠。
...@@ -14,8 +14,8 @@ ...@@ -14,8 +14,8 @@
* Statistics and Link management by Yitchak Gertner * Statistics and Link management by Yitchak Gertner
* *
*/ */
#include "bnx2x_cmn.h" #include "bnx2x_cmn.h"
#include "bnx2x_stats.h" #include "bnx2x_stats.h"
/* Statistics */ /* Statistics */
......
...@@ -9,6 +9,10 @@ ...@@ -9,6 +9,10 @@
* Maintained by: Eilon Greenstein <eilong@broadcom.com> * Maintained by: Eilon Greenstein <eilong@broadcom.com>
* Written by: Eliezer Tamir * Written by: Eliezer Tamir
* Based on code from Michael Chan's bnx2 driver * Based on code from Michael Chan's bnx2 driver
* UDP CSUM errata workaround by Arik Gendelman
* Slowpath and fastpath rework by Vladislav Zolotarov
* Statistics and Link management by Yitchak Gertner
*
*/ */
#ifndef BNX2X_STATS_H #ifndef BNX2X_STATS_H
...@@ -228,12 +232,8 @@ struct bnx2x_eth_stats { ...@@ -228,12 +232,8 @@ struct bnx2x_eth_stats {
/* Forward declaration */ /* Forward declaration */
struct bnx2x; struct bnx2x;
void bnx2x_stats_init(struct bnx2x *bp); void bnx2x_stats_init(struct bnx2x *bp);
extern const u32 dmae_reg_go_c[]; extern const u32 dmae_reg_go_c[];
extern int bnx2x_sp_post(struct bnx2x *bp, int command, int cid,
u32 data_hi, u32 data_lo, int common);
#endif /* BNX2X_STATS_H */ #endif /* BNX2X_STATS_H */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册