iPXE
Data Structures | Macros | Functions | Variables
bnx2.c File Reference
#include "etherboot.h"
#include "nic.h"
#include <errno.h>
#include <ipxe/pci.h>
#include <ipxe/ethernet.h>
#include "string.h"
#include <mii.h>
#include "bnx2.h"
#include "bnx2_fw.h"

Go to the source code of this file.

Data Structures

struct  bss
 

Macros

#define PHY_RESET_MAX_WAIT   100
 
#define ETHTOOL_ALL_FIBRE_SPEED   (ADVERTISED_1000baseT_Full)
 
#define ETHTOOL_ALL_COPPER_SPEED
 
#define PHY_ALL_10_100_SPEED
 
#define PHY_ALL_1000_SPEED   (ADVERTISE_1000HALF | ADVERTISE_1000FULL)
 

Functions

 FILE_LICENCE (GPL_ANY)
 
static u32 bnx2_reg_rd_ind (struct bnx2 *bp, u32 offset)
 
static void bnx2_reg_wr_ind (struct bnx2 *bp, u32 offset, u32 val)
 
static void bnx2_ctx_wr (struct bnx2 *bp, u32 cid_addr, u32 offset, u32 val)
 
static int bnx2_read_phy (struct bnx2 *bp, u32 reg, u32 *val)
 
static int bnx2_write_phy (struct bnx2 *bp, u32 reg, u32 val)
 
static void bnx2_disable_int (struct bnx2 *bp)
 
static int bnx2_alloc_mem (struct bnx2 *bp)
 
static void bnx2_report_fw_link (struct bnx2 *bp)
 
static void bnx2_report_link (struct bnx2 *bp)
 
static void bnx2_resolve_flow_ctrl (struct bnx2 *bp)
 
static int bnx2_5708s_linkup (struct bnx2 *bp)
 
static int bnx2_5706s_linkup (struct bnx2 *bp)
 
static int bnx2_copper_linkup (struct bnx2 *bp)
 
static int bnx2_set_mac_link (struct bnx2 *bp)
 
static int bnx2_set_link (struct bnx2 *bp)
 
static int bnx2_reset_phy (struct bnx2 *bp)
 
static u32 bnx2_phy_get_pause_adv (struct bnx2 *bp)
 
static int bnx2_setup_serdes_phy (struct bnx2 *bp)
 
static int bnx2_setup_copper_phy (struct bnx2 *bp)
 
static int bnx2_setup_phy (struct bnx2 *bp)
 
static int bnx2_init_5708s_phy (struct bnx2 *bp)
 
static int bnx2_init_5706s_phy (struct bnx2 *bp)
 
static int bnx2_init_copper_phy (struct bnx2 *bp)
 
static int bnx2_init_phy (struct bnx2 *bp)
 
static int bnx2_fw_sync (struct bnx2 *bp, u32 msg_data, int silent)
 
static void bnx2_init_context (struct bnx2 *bp)
 
static int bnx2_alloc_bad_rbuf (struct bnx2 *bp)
 
static void bnx2_set_mac_addr (struct bnx2 *bp)
 
static void bnx2_set_rx_mode (struct nic *nic __unused)
 
static void load_rv2p_fw (struct bnx2 *bp, u32 *rv2p_code, u32 rv2p_code_len, u32 rv2p_proc)
 
static void load_cpu_fw (struct bnx2 *bp, struct cpu_reg *cpu_reg, struct fw_info *fw)
 
static void bnx2_init_cpus (struct bnx2 *bp)
 
static int bnx2_set_power_state_0 (struct bnx2 *bp)
 
static void bnx2_enable_nvram_access (struct bnx2 *bp)
 
static void bnx2_disable_nvram_access (struct bnx2 *bp)
 
static int bnx2_init_nvram (struct bnx2 *bp)
 
static int bnx2_reset_chip (struct bnx2 *bp, u32 reset_code)
 
static void bnx2_disable (struct nic *nic __unused)
 
static int bnx2_init_chip (struct bnx2 *bp)
 
static void bnx2_init_tx_ring (struct bnx2 *bp)
 
static void bnx2_init_rx_ring (struct bnx2 *bp)
 
static int bnx2_reset_nic (struct bnx2 *bp, u32 reset_code)
 
static int bnx2_init_nic (struct bnx2 *bp)
 
static int bnx2_init_board (struct pci_device *pdev, struct nic *nic)
 
static void bnx2_transmit (struct nic *nic, const char *dst_addr, unsigned int type, unsigned int size, const char *packet)
 
static int bnx2_poll_link (struct bnx2 *bp)
 
static int bnx2_poll (struct nic *nic, int retrieve)
 
static void bnx2_irq (struct nic *nic __unused, irq_action_t action __unused)
 
static int bnx2_probe (struct nic *nic, struct pci_device *pdev)
 
 PCI_DRIVER (bnx2_driver, bnx2_nics, PCI_NO_CLASS)
 
 DRIVER ("BNX2", nic_driver, pci_driver, bnx2_driver, bnx2_probe, bnx2_disable)
 

Variables

static struct bss bnx2_bss
 
static struct bnx2 bnx2
 
static struct flash_spec flash_table []
 
static struct nic_operations bnx2_operations
 
static struct pci_device_id bnx2_nics []
 

Macro Definition Documentation

◆ PHY_RESET_MAX_WAIT

#define PHY_RESET_MAX_WAIT   100

◆ ETHTOOL_ALL_FIBRE_SPEED

#define ETHTOOL_ALL_FIBRE_SPEED   (ADVERTISED_1000baseT_Full)

Definition at line 882 of file bnx2.c.

◆ ETHTOOL_ALL_COPPER_SPEED

#define ETHTOOL_ALL_COPPER_SPEED
Value:
ADVERTISED_100baseT_Half | ADVERTISED_100baseT_Full | \
ADVERTISED_1000baseT_Full)
#define ADVERTISED_10baseT_Full
Definition: bnx2.h:43
#define ADVERTISED_100baseT_Full
Definition: bnx2.h:45
#define ADVERTISED_10baseT_Half
Definition: bnx2.h:42

Definition at line 885 of file bnx2.c.

◆ PHY_ALL_10_100_SPEED

#define PHY_ALL_10_100_SPEED
Value:
ADVERTISE_100HALF | ADVERTISE_100FULL | ADVERTISE_CSMA)
#define ADVERTISE_10FULL
Definition: mii.h:76
#define ADVERTISE_100FULL
Definition: mii.h:80
#define ADVERTISE_CSMA
Definition: mii.h:73
#define ADVERTISE_10HALF
Definition: mii.h:74

Definition at line 890 of file bnx2.c.

◆ PHY_ALL_1000_SPEED

#define PHY_ALL_1000_SPEED   (ADVERTISE_1000HALF | ADVERTISE_1000FULL)

Definition at line 893 of file bnx2.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL_ANY  )

◆ bnx2_reg_rd_ind()

static u32 bnx2_reg_rd_ind ( struct bnx2 bp,
u32  offset 
)
static

Definition at line 137 of file bnx2.c.

138 {
140  return (REG_RD(bp, BNX2_PCICFG_REG_WINDOW));
141 }
#define REG_WR(bp, offset, val)
Definition: bnx2.h:4194
uint16_t bp
Definition: registers.h:23
static userptr_t size_t offset
Offset of the first segment within the content.
Definition: deflate.h:259
#define REG_RD(bp, offset)
Definition: bnx2.h:4191
#define BNX2_PCICFG_REG_WINDOW
Definition: bnx2.h:509
#define BNX2_PCICFG_REG_WINDOW_ADDRESS
Definition: bnx2.h:508

References BNX2_PCICFG_REG_WINDOW, BNX2_PCICFG_REG_WINDOW_ADDRESS, bp, offset, REG_RD, and REG_WR.

◆ bnx2_reg_wr_ind()

static void bnx2_reg_wr_ind ( struct bnx2 bp,
u32  offset,
u32  val 
)
static

Definition at line 144 of file bnx2.c.

145 {
148 }
#define REG_WR(bp, offset, val)
Definition: bnx2.h:4194
uint16_t bp
Definition: registers.h:23
static userptr_t size_t offset
Offset of the first segment within the content.
Definition: deflate.h:259
#define BNX2_PCICFG_REG_WINDOW
Definition: bnx2.h:509
void __asmcall int val
Definition: setjmp.h:28
#define BNX2_PCICFG_REG_WINDOW_ADDRESS
Definition: bnx2.h:508

References BNX2_PCICFG_REG_WINDOW, BNX2_PCICFG_REG_WINDOW_ADDRESS, bp, offset, REG_WR, and val.

◆ bnx2_ctx_wr()

static void bnx2_ctx_wr ( struct bnx2 bp,
u32  cid_addr,
u32  offset,
u32  val 
)
static

Definition at line 151 of file bnx2.c.

152 {
153  offset += cid_addr;
156 }
#define BNX2_CTX_DATA
Definition: bnx2.h:1482
#define REG_WR(bp, offset, val)
Definition: bnx2.h:4194
uint16_t bp
Definition: registers.h:23
static userptr_t size_t offset
Offset of the first segment within the content.
Definition: deflate.h:259
void __asmcall int val
Definition: setjmp.h:28
#define BNX2_CTX_DATA_ADR
Definition: bnx2.h:1479

References BNX2_CTX_DATA, BNX2_CTX_DATA_ADR, bp, offset, REG_WR, and val.

◆ bnx2_read_phy()

static int bnx2_read_phy ( struct bnx2 bp,
u32  reg,
u32 val 
)
static

Definition at line 159 of file bnx2.c.

160 {
161  u32 val1;
162  int i, ret;
163 
164  if (bp->phy_flags & PHY_INT_MODE_AUTO_POLLING_FLAG) {
165  val1 = REG_RD(bp, BNX2_EMAC_MDIO_MODE);
167 
168  REG_WR(bp, BNX2_EMAC_MDIO_MODE, val1);
170 
171  udelay(40);
172  }
173 
174  val1 = (bp->phy_addr << 21) | (reg << 16) |
177  REG_WR(bp, BNX2_EMAC_MDIO_COMM, val1);
178 
179  for (i = 0; i < 50; i++) {
180  udelay(10);
181 
182  val1 = REG_RD(bp, BNX2_EMAC_MDIO_COMM);
183  if (!(val1 & BNX2_EMAC_MDIO_COMM_START_BUSY)) {
184  udelay(5);
185 
186  val1 = REG_RD(bp, BNX2_EMAC_MDIO_COMM);
187  val1 &= BNX2_EMAC_MDIO_COMM_DATA;
188 
189  break;
190  }
191  }
192 
193  if (val1 & BNX2_EMAC_MDIO_COMM_START_BUSY) {
194  *val = 0x0;
195  ret = -EBUSY;
196  }
197  else {
198  *val = val1;
199  ret = 0;
200  }
201 
202  if (bp->phy_flags & PHY_INT_MODE_AUTO_POLLING_FLAG) {
203  val1 = REG_RD(bp, BNX2_EMAC_MDIO_MODE);
205 
206  REG_WR(bp, BNX2_EMAC_MDIO_MODE, val1);
208 
209  udelay(40);
210  }
211 
212  return ret;
213 }
#define EBUSY
Device or resource busy.
Definition: errno.h:338
static unsigned int unsigned int reg
Definition: myson.h:162
#define REG_WR(bp, offset, val)
Definition: bnx2.h:4194
uint16_t bp
Definition: registers.h:23
#define BNX2_EMAC_MDIO_COMM_START_BUSY
Definition: bnx2.h:1648
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
#define BNX2_EMAC_MDIO_COMM_COMMAND_READ
Definition: bnx2.h:1645
#define REG_RD(bp, offset)
Definition: bnx2.h:4191
void __asmcall int val
Definition: setjmp.h:28
#define BNX2_EMAC_MDIO_COMM
Definition: bnx2.h:1638
#define BNX2_EMAC_MDIO_MODE_AUTO_POLL
Definition: bnx2.h:1657
#define BNX2_EMAC_MDIO_MODE
Definition: bnx2.h:1655
#define BNX2_EMAC_MDIO_COMM_DISEXT
Definition: bnx2.h:1649
#define BNX2_EMAC_MDIO_COMM_DATA
Definition: bnx2.h:1639
#define PHY_INT_MODE_AUTO_POLLING_FLAG
Definition: bnx2.h:4066
uint32_t u32
Definition: stdint.h:23

References BNX2_EMAC_MDIO_COMM, BNX2_EMAC_MDIO_COMM_COMMAND_READ, BNX2_EMAC_MDIO_COMM_DATA, BNX2_EMAC_MDIO_COMM_DISEXT, BNX2_EMAC_MDIO_COMM_START_BUSY, BNX2_EMAC_MDIO_MODE, BNX2_EMAC_MDIO_MODE_AUTO_POLL, bp, EBUSY, PHY_INT_MODE_AUTO_POLLING_FLAG, reg, REG_RD, REG_WR, udelay(), and val.

Referenced by bnx2_5706s_linkup(), bnx2_5708s_linkup(), bnx2_copper_linkup(), bnx2_init_5706s_phy(), bnx2_init_5708s_phy(), bnx2_init_copper_phy(), bnx2_init_phy(), bnx2_poll_link(), bnx2_report_fw_link(), bnx2_reset_phy(), bnx2_resolve_flow_ctrl(), bnx2_set_link(), bnx2_setup_copper_phy(), and bnx2_setup_serdes_phy().

◆ bnx2_write_phy()

static int bnx2_write_phy ( struct bnx2 bp,
u32  reg,
u32  val 
)
static

Definition at line 216 of file bnx2.c.

217 {
218  u32 val1;
219  int i, ret;
220 
221  if (bp->phy_flags & PHY_INT_MODE_AUTO_POLLING_FLAG) {
222  val1 = REG_RD(bp, BNX2_EMAC_MDIO_MODE);
224 
225  REG_WR(bp, BNX2_EMAC_MDIO_MODE, val1);
227 
228  udelay(40);
229  }
230 
231  val1 = (bp->phy_addr << 21) | (reg << 16) | val |
234  REG_WR(bp, BNX2_EMAC_MDIO_COMM, val1);
235 
236  for (i = 0; i < 50; i++) {
237  udelay(10);
238 
239  val1 = REG_RD(bp, BNX2_EMAC_MDIO_COMM);
240  if (!(val1 & BNX2_EMAC_MDIO_COMM_START_BUSY)) {
241  udelay(5);
242  break;
243  }
244  }
245 
247  ret = -EBUSY;
248  else
249  ret = 0;
250 
251  if (bp->phy_flags & PHY_INT_MODE_AUTO_POLLING_FLAG) {
252  val1 = REG_RD(bp, BNX2_EMAC_MDIO_MODE);
254 
255  REG_WR(bp, BNX2_EMAC_MDIO_MODE, val1);
257 
258  udelay(40);
259  }
260 
261  return ret;
262 }
#define EBUSY
Device or resource busy.
Definition: errno.h:338
static unsigned int unsigned int reg
Definition: myson.h:162
#define REG_WR(bp, offset, val)
Definition: bnx2.h:4194
uint16_t bp
Definition: registers.h:23
#define BNX2_EMAC_MDIO_COMM_COMMAND_WRITE
Definition: bnx2.h:1644
#define BNX2_EMAC_MDIO_COMM_START_BUSY
Definition: bnx2.h:1648
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
#define REG_RD(bp, offset)
Definition: bnx2.h:4191
void __asmcall int val
Definition: setjmp.h:28
#define BNX2_EMAC_MDIO_COMM
Definition: bnx2.h:1638
#define BNX2_EMAC_MDIO_MODE_AUTO_POLL
Definition: bnx2.h:1657
#define BNX2_EMAC_MDIO_MODE
Definition: bnx2.h:1655
#define BNX2_EMAC_MDIO_COMM_DISEXT
Definition: bnx2.h:1649
#define PHY_INT_MODE_AUTO_POLLING_FLAG
Definition: bnx2.h:4066
uint32_t u32
Definition: stdint.h:23

References BNX2_EMAC_MDIO_COMM, BNX2_EMAC_MDIO_COMM_COMMAND_WRITE, BNX2_EMAC_MDIO_COMM_DISEXT, BNX2_EMAC_MDIO_COMM_START_BUSY, BNX2_EMAC_MDIO_MODE, BNX2_EMAC_MDIO_MODE_AUTO_POLL, bp, EBUSY, PHY_INT_MODE_AUTO_POLLING_FLAG, reg, REG_RD, REG_WR, udelay(), and val.

Referenced by bnx2_init_5706s_phy(), bnx2_init_5708s_phy(), bnx2_init_copper_phy(), bnx2_reset_phy(), bnx2_set_link(), bnx2_setup_copper_phy(), and bnx2_setup_serdes_phy().

◆ bnx2_disable_int()

static void bnx2_disable_int ( struct bnx2 bp)
static

Definition at line 265 of file bnx2.c.

266 {
270 
271 }
#define REG_WR(bp, offset, val)
Definition: bnx2.h:4194
uint16_t bp
Definition: registers.h:23
#define REG_RD(bp, offset)
Definition: bnx2.h:4191
#define BNX2_PCICFG_INT_ACK_CMD_MASK_INT
Definition: bnx2.h:514
#define BNX2_PCICFG_INT_ACK_CMD
Definition: bnx2.h:510

References BNX2_PCICFG_INT_ACK_CMD, BNX2_PCICFG_INT_ACK_CMD_MASK_INT, bp, REG_RD, and REG_WR.

Referenced by bnx2_probe().

◆ bnx2_alloc_mem()

static int bnx2_alloc_mem ( struct bnx2 bp)
static

Definition at line 274 of file bnx2.c.

275 {
276  bp->tx_desc_ring = bnx2_bss.tx_desc_ring;
277  bp->tx_desc_mapping = virt_to_bus(bp->tx_desc_ring);
278 
279  bp->rx_desc_ring = bnx2_bss.rx_desc_ring;
280  memset(bp->rx_desc_ring, 0, sizeof(struct rx_bd) * RX_DESC_CNT);
281  bp->rx_desc_mapping = virt_to_bus(bp->rx_desc_ring);
282 
283  memset(&bnx2_bss.status_blk, 0, sizeof(struct status_block));
284  bp->status_blk = &bnx2_bss.status_blk;
285  bp->status_blk_mapping = virt_to_bus(&bnx2_bss.status_blk);
286 
287  bp->stats_blk = &bnx2_bss.stats_blk;
288  memset(&bnx2_bss.stats_blk, 0, sizeof(struct statistics_block));
289  bp->stats_blk_mapping = virt_to_bus(&bnx2_bss.stats_blk);
290 
291  return 0;
292 }
struct statistics_block stats_blk
Definition: bnx2.c:44
struct status_block status_blk
Definition: bnx2.c:43
uint16_t bp
Definition: registers.h:23
struct rx_bd rx_desc_ring[RX_DESC_CNT]
Definition: bnx2.c:41
static struct bss bnx2_bss
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition: io.h:183
#define RX_DESC_CNT
Definition: bnx2.h:3884
Definition: bnx2.h:174
struct tx_bd tx_desc_ring[TX_DESC_CNT]
Definition: bnx2.c:40
void * memset(void *dest, int character, size_t len) __nonnull

References bnx2_bss, bp, memset(), RX_DESC_CNT, bss::rx_desc_ring, bss::stats_blk, bss::status_blk, bss::tx_desc_ring, and virt_to_bus().

Referenced by bnx2_probe().

◆ bnx2_report_fw_link()

static void bnx2_report_fw_link ( struct bnx2 bp)
static

Definition at line 295 of file bnx2.c.

296 {
297  u32 fw_link_status = 0;
298 
299  if (bp->link_up) {
300  u32 bmsr;
301 
302  switch (bp->line_speed) {
303  case SPEED_10:
304  if (bp->duplex == DUPLEX_HALF)
305  fw_link_status = BNX2_LINK_STATUS_10HALF;
306  else
307  fw_link_status = BNX2_LINK_STATUS_10FULL;
308  break;
309  case SPEED_100:
310  if (bp->duplex == DUPLEX_HALF)
311  fw_link_status = BNX2_LINK_STATUS_100HALF;
312  else
313  fw_link_status = BNX2_LINK_STATUS_100FULL;
314  break;
315  case SPEED_1000:
316  if (bp->duplex == DUPLEX_HALF)
317  fw_link_status = BNX2_LINK_STATUS_1000HALF;
318  else
319  fw_link_status = BNX2_LINK_STATUS_1000FULL;
320  break;
321  case SPEED_2500:
322  if (bp->duplex == DUPLEX_HALF)
323  fw_link_status = BNX2_LINK_STATUS_2500HALF;
324  else
325  fw_link_status = BNX2_LINK_STATUS_2500FULL;
326  break;
327  }
328 
329  fw_link_status |= BNX2_LINK_STATUS_LINK_UP;
330 
331  if (bp->autoneg) {
332  fw_link_status |= BNX2_LINK_STATUS_AN_ENABLED;
333 
334  bnx2_read_phy(bp, MII_BMSR, &bmsr);
335  bnx2_read_phy(bp, MII_BMSR, &bmsr);
336 
337  if (!(bmsr & BMSR_ANEGCOMPLETE) ||
338  bp->phy_flags & PHY_PARALLEL_DETECT_FLAG)
339  fw_link_status |= BNX2_LINK_STATUS_PARALLEL_DET;
340  else
341  fw_link_status |= BNX2_LINK_STATUS_AN_COMPLETE;
342  }
343  }
344  else
345  fw_link_status = BNX2_LINK_STATUS_LINK_DOWN;
346 
347  REG_WR_IND(bp, bp->shmem_base + BNX2_LINK_STATUS, fw_link_status);
348 }
#define SPEED_1000
Definition: atl1e.h:52
#define BNX2_LINK_STATUS_1000HALF
Definition: bnx2.h:4327
#define BNX2_LINK_STATUS_AN_ENABLED
Definition: bnx2.h:4331
#define BNX2_LINK_STATUS_10FULL
Definition: bnx2.h:4323
uint16_t bp
Definition: registers.h:23
#define SPEED_10
Definition: atl1e.h:50
#define BNX2_LINK_STATUS_AN_COMPLETE
Definition: bnx2.h:4332
#define SPEED_100
Definition: atl1e.h:51
static int bnx2_read_phy(struct bnx2 *bp, u32 reg, u32 *val)
Definition: bnx2.c:159
#define BNX2_LINK_STATUS_2500FULL
Definition: bnx2.h:4330
#define SPEED_2500
Definition: bnx2.h:105
#define BMSR_ANEGCOMPLETE
Definition: mii.h:60
#define BNX2_LINK_STATUS_10HALF
Definition: bnx2.h:4322
#define BNX2_LINK_STATUS_100FULL
Definition: bnx2.h:4326
#define BNX2_LINK_STATUS_PARALLEL_DET
Definition: bnx2.h:4333
#define BNX2_LINK_STATUS_LINK_UP
Definition: bnx2.h:4318
#define REG_WR_IND(bp, offset, val)
Definition: bnx2.h:4203
#define PHY_PARALLEL_DETECT_FLAG
Definition: bnx2.h:4063
#define BNX2_LINK_STATUS_100HALF
Definition: bnx2.h:4324
#define BNX2_LINK_STATUS_1000FULL
Definition: bnx2.h:4328
#define BNX2_LINK_STATUS_LINK_DOWN
Definition: bnx2.h:4319
#define MII_BMSR
Definition: atl1e.h:872
#define BNX2_LINK_STATUS_2500HALF
Definition: bnx2.h:4329
#define BNX2_LINK_STATUS
Definition: bnx2.h:4316
uint32_t u32
Definition: stdint.h:23
#define DUPLEX_HALF
Definition: bnx2.h:110

References BMSR_ANEGCOMPLETE, BNX2_LINK_STATUS, BNX2_LINK_STATUS_1000FULL, BNX2_LINK_STATUS_1000HALF, BNX2_LINK_STATUS_100FULL, BNX2_LINK_STATUS_100HALF, BNX2_LINK_STATUS_10FULL, BNX2_LINK_STATUS_10HALF, BNX2_LINK_STATUS_2500FULL, BNX2_LINK_STATUS_2500HALF, BNX2_LINK_STATUS_AN_COMPLETE, BNX2_LINK_STATUS_AN_ENABLED, BNX2_LINK_STATUS_LINK_DOWN, BNX2_LINK_STATUS_LINK_UP, BNX2_LINK_STATUS_PARALLEL_DET, bnx2_read_phy(), bp, DUPLEX_HALF, MII_BMSR, PHY_PARALLEL_DETECT_FLAG, REG_WR_IND, SPEED_10, SPEED_100, SPEED_1000, and SPEED_2500.

Referenced by bnx2_report_link().

◆ bnx2_report_link()

static void bnx2_report_link ( struct bnx2 bp)
static

Definition at line 351 of file bnx2.c.

352 {
353  if (bp->link_up) {
354  printf("NIC Link is Up, ");
355 
356  printf("%d Mbps ", bp->line_speed);
357 
358  if (bp->duplex == DUPLEX_FULL)
359  printf("full duplex");
360  else
361  printf("half duplex");
362 
363  if (bp->flow_ctrl) {
364  if (bp->flow_ctrl & FLOW_CTRL_RX) {
365  printf(", receive ");
366  if (bp->flow_ctrl & FLOW_CTRL_TX)
367  printf("& transmit ");
368  }
369  else {
370  printf(", transmit ");
371  }
372  printf("flow control ON");
373  }
374  printf("\n");
375  }
376  else {
377  printf("NIC Link is Down\n");
378  }
379 
381 }
int printf(const char *fmt,...)
Write a formatted string to the console.
Definition: vsprintf.c:464
uint16_t bp
Definition: registers.h:23
#define FLOW_CTRL_TX
Definition: bnx2.h:4152
#define DUPLEX_FULL
Definition: bnx2.h:111
#define FLOW_CTRL_RX
Definition: bnx2.h:4153
static void bnx2_report_fw_link(struct bnx2 *bp)
Definition: bnx2.c:295

References bnx2_report_fw_link(), bp, DUPLEX_FULL, FLOW_CTRL_RX, FLOW_CTRL_TX, and printf().

Referenced by bnx2_set_link().

◆ bnx2_resolve_flow_ctrl()

static void bnx2_resolve_flow_ctrl ( struct bnx2 bp)
static

Definition at line 384 of file bnx2.c.

385 {
386  u32 local_adv, remote_adv;
387 
388  bp->flow_ctrl = 0;
389  if ((bp->autoneg & (AUTONEG_SPEED | AUTONEG_FLOW_CTRL)) !=
391 
392  if (bp->duplex == DUPLEX_FULL) {
393  bp->flow_ctrl = bp->req_flow_ctrl;
394  }
395  return;
396  }
397 
398  if (bp->duplex != DUPLEX_FULL) {
399  return;
400  }
401 
402  if ((bp->phy_flags & PHY_SERDES_FLAG) &&
403  (CHIP_NUM(bp) == CHIP_NUM_5708)) {
404  u32 val;
405 
408  bp->flow_ctrl |= FLOW_CTRL_TX;
410  bp->flow_ctrl |= FLOW_CTRL_RX;
411  return;
412  }
413 
414  bnx2_read_phy(bp, MII_ADVERTISE, &local_adv);
415  bnx2_read_phy(bp, MII_LPA, &remote_adv);
416 
417  if (bp->phy_flags & PHY_SERDES_FLAG) {
418  u32 new_local_adv = 0;
419  u32 new_remote_adv = 0;
420 
421  if (local_adv & ADVERTISE_1000XPAUSE)
422  new_local_adv |= ADVERTISE_PAUSE_CAP;
423  if (local_adv & ADVERTISE_1000XPSE_ASYM)
424  new_local_adv |= ADVERTISE_PAUSE_ASYM;
425  if (remote_adv & ADVERTISE_1000XPAUSE)
426  new_remote_adv |= ADVERTISE_PAUSE_CAP;
427  if (remote_adv & ADVERTISE_1000XPSE_ASYM)
428  new_remote_adv |= ADVERTISE_PAUSE_ASYM;
429 
430  local_adv = new_local_adv;
431  remote_adv = new_remote_adv;
432  }
433 
434  /* See Table 28B-3 of 802.3ab-1999 spec. */
435  if (local_adv & ADVERTISE_PAUSE_CAP) {
436  if(local_adv & ADVERTISE_PAUSE_ASYM) {
437  if (remote_adv & ADVERTISE_PAUSE_CAP) {
438  bp->flow_ctrl = FLOW_CTRL_TX | FLOW_CTRL_RX;
439  }
440  else if (remote_adv & ADVERTISE_PAUSE_ASYM) {
441  bp->flow_ctrl = FLOW_CTRL_RX;
442  }
443  }
444  else {
445  if (remote_adv & ADVERTISE_PAUSE_CAP) {
446  bp->flow_ctrl = FLOW_CTRL_TX | FLOW_CTRL_RX;
447  }
448  }
449  }
450  else if (local_adv & ADVERTISE_PAUSE_ASYM) {
451  if ((remote_adv & ADVERTISE_PAUSE_CAP) &&
452  (remote_adv & ADVERTISE_PAUSE_ASYM)) {
453 
454  bp->flow_ctrl = FLOW_CTRL_TX;
455  }
456  }
457 }
#define MII_ADVERTISE
Definition: atl1e.h:875
#define BCM5708S_1000X_STAT1
Definition: bnx2.h:3843
#define MII_LPA
Definition: atl1e.h:876
#define BCM5708S_1000X_STAT1_TX_PAUSE
Definition: bnx2.h:3853
#define ADVERTISE_1000XPAUSE
Definition: mii.h:79
uint16_t bp
Definition: registers.h:23
#define CHIP_NUM_5708
Definition: bnx2.h:4073
#define FLOW_CTRL_TX
Definition: bnx2.h:4152
static int bnx2_read_phy(struct bnx2 *bp, u32 reg, u32 *val)
Definition: bnx2.c:159
#define CHIP_NUM(bp)
Definition: bnx2.h:4071
#define DUPLEX_FULL
Definition: bnx2.h:111
#define ADVERTISE_1000XPSE_ASYM
Definition: mii.h:81
#define ADVERTISE_PAUSE_ASYM
Definition: mii.h:84
#define AUTONEG_FLOW_CTRL
Definition: bnx2.h:4162
#define PHY_SERDES_FLAG
Definition: bnx2.h:4061
#define FLOW_CTRL_RX
Definition: bnx2.h:4153
void __asmcall int val
Definition: setjmp.h:28
#define BCM5708S_1000X_STAT1_RX_PAUSE
Definition: bnx2.h:3854
#define ADVERTISE_PAUSE_CAP
Definition: mii.h:83
#define AUTONEG_SPEED
Definition: bnx2.h:4161
uint32_t u32
Definition: stdint.h:23

References ADVERTISE_1000XPAUSE, ADVERTISE_1000XPSE_ASYM, ADVERTISE_PAUSE_ASYM, ADVERTISE_PAUSE_CAP, AUTONEG_FLOW_CTRL, AUTONEG_SPEED, BCM5708S_1000X_STAT1, BCM5708S_1000X_STAT1_RX_PAUSE, BCM5708S_1000X_STAT1_TX_PAUSE, bnx2_read_phy(), bp, CHIP_NUM, CHIP_NUM_5708, DUPLEX_FULL, FLOW_CTRL_RX, FLOW_CTRL_TX, MII_ADVERTISE, MII_LPA, PHY_SERDES_FLAG, and val.

Referenced by bnx2_set_link(), and bnx2_setup_copper_phy().

◆ bnx2_5708s_linkup()

static int bnx2_5708s_linkup ( struct bnx2 bp)
static

Definition at line 460 of file bnx2.c.

461 {
462  u32 val;
463 
464  bp->link_up = 1;
468  bp->line_speed = SPEED_10;
469  break;
471  bp->line_speed = SPEED_100;
472  break;
474  bp->line_speed = SPEED_1000;
475  break;
477  bp->line_speed = SPEED_2500;
478  break;
479  }
481  bp->duplex = DUPLEX_FULL;
482  else
483  bp->duplex = DUPLEX_HALF;
484 
485  return 0;
486 }
#define SPEED_1000
Definition: atl1e.h:52
#define BCM5708S_1000X_STAT1
Definition: bnx2.h:3843
#define BCM5708S_1000X_STAT1_SPEED_10
Definition: bnx2.h:3849
uint16_t bp
Definition: registers.h:23
#define SPEED_10
Definition: atl1e.h:50
#define SPEED_100
Definition: atl1e.h:51
static int bnx2_read_phy(struct bnx2 *bp, u32 reg, u32 *val)
Definition: bnx2.c:159
#define SPEED_2500
Definition: bnx2.h:105
#define DUPLEX_FULL
Definition: bnx2.h:111
#define BCM5708S_1000X_STAT1_SPEED_MASK
Definition: bnx2.h:3848
#define BCM5708S_1000X_STAT1_FD
Definition: bnx2.h:3847
void __asmcall int val
Definition: setjmp.h:28
#define BCM5708S_1000X_STAT1_SPEED_100
Definition: bnx2.h:3850
#define BCM5708S_1000X_STAT1_SPEED_2G5
Definition: bnx2.h:3852
uint32_t u32
Definition: stdint.h:23
#define BCM5708S_1000X_STAT1_SPEED_1G
Definition: bnx2.h:3851
#define DUPLEX_HALF
Definition: bnx2.h:110

References BCM5708S_1000X_STAT1, BCM5708S_1000X_STAT1_FD, BCM5708S_1000X_STAT1_SPEED_10, BCM5708S_1000X_STAT1_SPEED_100, BCM5708S_1000X_STAT1_SPEED_1G, BCM5708S_1000X_STAT1_SPEED_2G5, BCM5708S_1000X_STAT1_SPEED_MASK, bnx2_read_phy(), bp, DUPLEX_FULL, DUPLEX_HALF, SPEED_10, SPEED_100, SPEED_1000, SPEED_2500, and val.

Referenced by bnx2_set_link().

◆ bnx2_5706s_linkup()

static int bnx2_5706s_linkup ( struct bnx2 bp)
static

Definition at line 489 of file bnx2.c.

490 {
491  u32 bmcr, local_adv, remote_adv, common;
492 
493  bp->link_up = 1;
494  bp->line_speed = SPEED_1000;
495 
496  bnx2_read_phy(bp, MII_BMCR, &bmcr);
497  if (bmcr & BMCR_FULLDPLX) {
498  bp->duplex = DUPLEX_FULL;
499  }
500  else {
501  bp->duplex = DUPLEX_HALF;
502  }
503 
504  if (!(bmcr & BMCR_ANENABLE)) {
505  return 0;
506  }
507 
508  bnx2_read_phy(bp, MII_ADVERTISE, &local_adv);
509  bnx2_read_phy(bp, MII_LPA, &remote_adv);
510 
511  common = local_adv & remote_adv;
513 
514  if (common & ADVERTISE_1000XFULL) {
515  bp->duplex = DUPLEX_FULL;
516  }
517  else {
518  bp->duplex = DUPLEX_HALF;
519  }
520  }
521 
522  return 0;
523 }
#define SPEED_1000
Definition: atl1e.h:52
#define MII_ADVERTISE
Definition: atl1e.h:875
#define MII_LPA
Definition: atl1e.h:876
uint16_t bp
Definition: registers.h:23
static int bnx2_read_phy(struct bnx2 *bp, u32 reg, u32 *val)
Definition: bnx2.c:159
#define ADVERTISE_1000XHALF
Definition: mii.h:77
#define DUPLEX_FULL
Definition: bnx2.h:111
#define MII_BMCR
Definition: atl1e.h:871
struct ib_cm_common common
Definition: ib_mad.h:11
#define BMCR_ANENABLE
Definition: mii.h:49
uint32_t u32
Definition: stdint.h:23
#define BMCR_FULLDPLX
Definition: mii.h:45
#define ADVERTISE_1000XFULL
Definition: mii.h:75
#define DUPLEX_HALF
Definition: bnx2.h:110

References ADVERTISE_1000XFULL, ADVERTISE_1000XHALF, BMCR_ANENABLE, BMCR_FULLDPLX, bnx2_read_phy(), bp, common, DUPLEX_FULL, DUPLEX_HALF, MII_ADVERTISE, MII_BMCR, MII_LPA, and SPEED_1000.

Referenced by bnx2_set_link().

◆ bnx2_copper_linkup()

static int bnx2_copper_linkup ( struct bnx2 bp)
static

Definition at line 526 of file bnx2.c.

527 {
528  u32 bmcr;
529 
530  bnx2_read_phy(bp, MII_BMCR, &bmcr);
531  if (bmcr & BMCR_ANENABLE) {
532  u32 local_adv, remote_adv, common;
533 
534  bnx2_read_phy(bp, MII_CTRL1000, &local_adv);
535  bnx2_read_phy(bp, MII_STAT1000, &remote_adv);
536 
537  common = local_adv & (remote_adv >> 2);
538  if (common & ADVERTISE_1000FULL) {
539  bp->line_speed = SPEED_1000;
540  bp->duplex = DUPLEX_FULL;
541  }
542  else if (common & ADVERTISE_1000HALF) {
543  bp->line_speed = SPEED_1000;
544  bp->duplex = DUPLEX_HALF;
545  }
546  else {
547  bnx2_read_phy(bp, MII_ADVERTISE, &local_adv);
548  bnx2_read_phy(bp, MII_LPA, &remote_adv);
549 
550  common = local_adv & remote_adv;
551  if (common & ADVERTISE_100FULL) {
552  bp->line_speed = SPEED_100;
553  bp->duplex = DUPLEX_FULL;
554  }
555  else if (common & ADVERTISE_100HALF) {
556  bp->line_speed = SPEED_100;
557  bp->duplex = DUPLEX_HALF;
558  }
559  else if (common & ADVERTISE_10FULL) {
560  bp->line_speed = SPEED_10;
561  bp->duplex = DUPLEX_FULL;
562  }
563  else if (common & ADVERTISE_10HALF) {
564  bp->line_speed = SPEED_10;
565  bp->duplex = DUPLEX_HALF;
566  }
567  else {
568  bp->line_speed = 0;
569  bp->link_up = 0;
570  }
571  }
572  }
573  else {
574  if (bmcr & BMCR_SPEED100) {
575  bp->line_speed = SPEED_100;
576  }
577  else {
578  bp->line_speed = SPEED_10;
579  }
580  if (bmcr & BMCR_FULLDPLX) {
581  bp->duplex = DUPLEX_FULL;
582  }
583  else {
584  bp->duplex = DUPLEX_HALF;
585  }
586  }
587 
588  return 0;
589 }
#define SPEED_1000
Definition: atl1e.h:52
#define MII_ADVERTISE
Definition: atl1e.h:875
#define MII_LPA
Definition: atl1e.h:876
#define ADVERTISE_1000FULL
Definition: mii.h:133
#define ADVERTISE_10FULL
Definition: mii.h:76
uint16_t bp
Definition: registers.h:23
#define ADVERTISE_100FULL
Definition: mii.h:80
#define SPEED_10
Definition: atl1e.h:50
#define SPEED_100
Definition: atl1e.h:51
static int bnx2_read_phy(struct bnx2 *bp, u32 reg, u32 *val)
Definition: bnx2.c:159
#define DUPLEX_FULL
Definition: bnx2.h:111
#define MII_CTRL1000
Definition: mii.h:24
#define MII_BMCR
Definition: atl1e.h:871
#define ADVERTISE_1000HALF
Definition: mii.h:134
struct ib_cm_common common
Definition: ib_mad.h:11
#define ADVERTISE_10HALF
Definition: mii.h:74
#define ADVERTISE_100HALF
Definition: mii.h:78
#define BMCR_ANENABLE
Definition: mii.h:49
#define BMCR_SPEED100
Definition: mii.h:50
uint32_t u32
Definition: stdint.h:23
#define BMCR_FULLDPLX
Definition: mii.h:45
#define DUPLEX_HALF
Definition: bnx2.h:110
#define MII_STAT1000
Definition: mii.h:25

References ADVERTISE_1000FULL, ADVERTISE_1000HALF, ADVERTISE_100FULL, ADVERTISE_100HALF, ADVERTISE_10FULL, ADVERTISE_10HALF, BMCR_ANENABLE, BMCR_FULLDPLX, BMCR_SPEED100, bnx2_read_phy(), bp, common, DUPLEX_FULL, DUPLEX_HALF, MII_ADVERTISE, MII_BMCR, MII_CTRL1000, MII_LPA, MII_STAT1000, SPEED_10, SPEED_100, and SPEED_1000.

Referenced by bnx2_set_link().

◆ bnx2_set_mac_link()

static int bnx2_set_mac_link ( struct bnx2 bp)
static

Definition at line 592 of file bnx2.c.

593 {
594  u32 val;
595 
596  REG_WR(bp, BNX2_EMAC_TX_LENGTHS, 0x2620);
597  if (bp->link_up && (bp->line_speed == SPEED_1000) &&
598  (bp->duplex == DUPLEX_HALF)) {
599  REG_WR(bp, BNX2_EMAC_TX_LENGTHS, 0x26ff);
600  }
601 
602  /* Configure the EMAC mode register. */
604 
608 
609  if (bp->link_up) {
610  switch (bp->line_speed) {
611  case SPEED_10:
612  if (CHIP_NUM(bp) == CHIP_NUM_5708) {
614  break;
615  }
616  /* fall through */
617  case SPEED_100:
619  break;
620  case SPEED_2500:
622  /* fall through */
623  case SPEED_1000:
625  break;
626  }
627  }
628  else {
630  }
631 
632  /* Set the MAC to operate in the appropriate duplex mode. */
633  if (bp->duplex == DUPLEX_HALF)
636 
637  /* Enable/disable rx PAUSE. */
638  bp->rx_mode &= ~BNX2_EMAC_RX_MODE_FLOW_EN;
639 
640  if (bp->flow_ctrl & FLOW_CTRL_RX)
641  bp->rx_mode |= BNX2_EMAC_RX_MODE_FLOW_EN;
642  REG_WR(bp, BNX2_EMAC_RX_MODE, bp->rx_mode);
643 
644  /* Enable/disable tx PAUSE. */
647 
648  if (bp->flow_ctrl & FLOW_CTRL_TX)
651 
652  /* Acknowledge the interrupt. */
654 
655  return 0;
656 }
#define SPEED_1000
Definition: atl1e.h:52
#define BNX2_EMAC_TX_MODE
Definition: bnx2.h:1668
#define BNX2_EMAC_RX_MODE
Definition: bnx2.h:1688
#define BNX2_EMAC_MODE_PORT_MII
Definition: bnx2.h:1534
#define REG_WR(bp, offset, val)
Definition: bnx2.h:4194
#define BNX2_EMAC_RX_MODE_FLOW_EN
Definition: bnx2.h:1690
uint16_t bp
Definition: registers.h:23
#define BNX2_EMAC_MODE_PORT_GMII
Definition: bnx2.h:1535
#define SPEED_10
Definition: atl1e.h:50
#define CHIP_NUM_5708
Definition: bnx2.h:4073
#define BNX2_EMAC_STATUS
Definition: bnx2.h:1548
#define FLOW_CTRL_TX
Definition: bnx2.h:4152
#define SPEED_100
Definition: atl1e.h:51
#define CHIP_NUM(bp)
Definition: bnx2.h:4071
#define SPEED_2500
Definition: bnx2.h:105
#define BNX2_EMAC_MODE_PORT_MII_10
Definition: bnx2.h:1536
#define BNX2_EMAC_STATUS_LINK_CHANGE
Definition: bnx2.h:1550
#define REG_RD(bp, offset)
Definition: bnx2.h:4191
#define BNX2_EMAC_MODE_FORCE_LINK
Definition: bnx2.h:1543
#define BNX2_EMAC_TX_MODE_FLOW_EN
Definition: bnx2.h:1671
#define FLOW_CTRL_RX
Definition: bnx2.h:4153
void __asmcall int val
Definition: setjmp.h:28
#define BNX2_EMAC_MODE
Definition: bnx2.h:1529
#define BNX2_EMAC_MODE_PORT
Definition: bnx2.h:1532
#define BNX2_EMAC_TX_LENGTHS
Definition: bnx2.h:1683
#define BNX2_EMAC_MODE_HALF_DUPLEX
Definition: bnx2.h:1531
#define BNX2_EMAC_MODE_25G
Definition: bnx2.h:1538
uint32_t u32
Definition: stdint.h:23
#define BNX2_EMAC_MODE_MAC_LOOP
Definition: bnx2.h:1537
#define DUPLEX_HALF
Definition: bnx2.h:110

References BNX2_EMAC_MODE, BNX2_EMAC_MODE_25G, BNX2_EMAC_MODE_FORCE_LINK, BNX2_EMAC_MODE_HALF_DUPLEX, BNX2_EMAC_MODE_MAC_LOOP, BNX2_EMAC_MODE_PORT, BNX2_EMAC_MODE_PORT_GMII, BNX2_EMAC_MODE_PORT_MII, BNX2_EMAC_MODE_PORT_MII_10, BNX2_EMAC_RX_MODE, BNX2_EMAC_RX_MODE_FLOW_EN, BNX2_EMAC_STATUS, BNX2_EMAC_STATUS_LINK_CHANGE, BNX2_EMAC_TX_LENGTHS, BNX2_EMAC_TX_MODE, BNX2_EMAC_TX_MODE_FLOW_EN, bp, CHIP_NUM, CHIP_NUM_5708, DUPLEX_HALF, FLOW_CTRL_RX, FLOW_CTRL_TX, REG_RD, REG_WR, SPEED_10, SPEED_100, SPEED_1000, SPEED_2500, and val.

Referenced by bnx2_set_link(), and bnx2_setup_copper_phy().

◆ bnx2_set_link()

static int bnx2_set_link ( struct bnx2 bp)
static

Definition at line 659 of file bnx2.c.

660 {
661  u32 bmsr;
662  u8 link_up;
663 
664  if (bp->loopback == MAC_LOOPBACK) {
665  bp->link_up = 1;
666  return 0;
667  }
668 
669  link_up = bp->link_up;
670 
671  bnx2_read_phy(bp, MII_BMSR, &bmsr);
672  bnx2_read_phy(bp, MII_BMSR, &bmsr);
673 
674  if ((bp->phy_flags & PHY_SERDES_FLAG) &&
675  (CHIP_NUM(bp) == CHIP_NUM_5706)) {
676  u32 val;
677 
680  bmsr |= BMSR_LSTATUS;
681  else
682  bmsr &= ~BMSR_LSTATUS;
683  }
684 
685  if (bmsr & BMSR_LSTATUS) {
686  bp->link_up = 1;
687 
688  if (bp->phy_flags & PHY_SERDES_FLAG) {
689  if (CHIP_NUM(bp) == CHIP_NUM_5706)
691  else if (CHIP_NUM(bp) == CHIP_NUM_5708)
693  }
694  else {
696  }
698  }
699  else {
700  if ((bp->phy_flags & PHY_SERDES_FLAG) &&
701  (bp->autoneg & AUTONEG_SPEED)) {
702 
703  u32 bmcr;
704 
705  bnx2_read_phy(bp, MII_BMCR, &bmcr);
706  if (!(bmcr & BMCR_ANENABLE)) {
707  bnx2_write_phy(bp, MII_BMCR, bmcr |
708  BMCR_ANENABLE);
709  }
710  }
711  bp->phy_flags &= ~PHY_PARALLEL_DETECT_FLAG;
712  bp->link_up = 0;
713  }
714 
715  if (bp->link_up != link_up) {
717  }
718 
720 
721  return 0;
722 }
static void bnx2_report_link(struct bnx2 *bp)
Definition: bnx2.c:351
static int bnx2_5708s_linkup(struct bnx2 *bp)
Definition: bnx2.c:460
uint16_t bp
Definition: registers.h:23
static int bnx2_copper_linkup(struct bnx2 *bp)
Definition: bnx2.c:526
#define MAC_LOOPBACK
Definition: bnx2.h:4165
#define CHIP_NUM_5708
Definition: bnx2.h:4073
#define BNX2_EMAC_STATUS
Definition: bnx2.h:1548
static int bnx2_read_phy(struct bnx2 *bp, u32 reg, u32 *val)
Definition: bnx2.c:159
#define BNX2_EMAC_STATUS_LINK
Definition: bnx2.h:1549
static int bnx2_5706s_linkup(struct bnx2 *bp)
Definition: bnx2.c:489
#define CHIP_NUM(bp)
Definition: bnx2.h:4071
#define BMSR_LSTATUS
Definition: mii.h:57
#define PHY_SERDES_FLAG
Definition: bnx2.h:4061
#define REG_RD(bp, offset)
Definition: bnx2.h:4191
#define MII_BMCR
Definition: atl1e.h:871
void __asmcall int val
Definition: setjmp.h:28
static int bnx2_write_phy(struct bnx2 *bp, u32 reg, u32 val)
Definition: bnx2.c:216
#define CHIP_NUM_5706
Definition: bnx2.h:4072
static int bnx2_set_mac_link(struct bnx2 *bp)
Definition: bnx2.c:592
#define PHY_PARALLEL_DETECT_FLAG
Definition: bnx2.h:4063
static void bnx2_resolve_flow_ctrl(struct bnx2 *bp)
Definition: bnx2.c:384
#define BMCR_ANENABLE
Definition: mii.h:49
#define MII_BMSR
Definition: atl1e.h:872
#define AUTONEG_SPEED
Definition: bnx2.h:4161
uint8_t u8
Definition: stdint.h:19
uint32_t u32
Definition: stdint.h:23

References AUTONEG_SPEED, BMCR_ANENABLE, BMSR_LSTATUS, bnx2_5706s_linkup(), bnx2_5708s_linkup(), bnx2_copper_linkup(), BNX2_EMAC_STATUS, BNX2_EMAC_STATUS_LINK, bnx2_read_phy(), bnx2_report_link(), bnx2_resolve_flow_ctrl(), bnx2_set_mac_link(), bnx2_write_phy(), bp, CHIP_NUM, CHIP_NUM_5706, CHIP_NUM_5708, MAC_LOOPBACK, MII_BMCR, MII_BMSR, PHY_PARALLEL_DETECT_FLAG, PHY_SERDES_FLAG, REG_RD, and val.

Referenced by bnx2_init_nic(), and bnx2_poll_link().

◆ bnx2_reset_phy()

static int bnx2_reset_phy ( struct bnx2 bp)
static

Definition at line 725 of file bnx2.c.

726 {
727  int i;
728  u32 reg;
729 
731 
732 #define PHY_RESET_MAX_WAIT 100
733  for (i = 0; i < PHY_RESET_MAX_WAIT; i++) {
734  udelay(10);
735 
737  if (!(reg & BMCR_RESET)) {
738  udelay(20);
739  break;
740  }
741  }
742  if (i == PHY_RESET_MAX_WAIT) {
743  return -EBUSY;
744  }
745  return 0;
746 }
#define PHY_RESET_MAX_WAIT
#define EBUSY
Device or resource busy.
Definition: errno.h:338
static unsigned int unsigned int reg
Definition: myson.h:162
uint16_t bp
Definition: registers.h:23
static int bnx2_read_phy(struct bnx2 *bp, u32 reg, u32 *val)
Definition: bnx2.c:159
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
#define MII_BMCR
Definition: atl1e.h:871
static int bnx2_write_phy(struct bnx2 *bp, u32 reg, u32 val)
Definition: bnx2.c:216
#define BMCR_RESET
Definition: mii.h:52
uint32_t u32
Definition: stdint.h:23

References BMCR_RESET, bnx2_read_phy(), bnx2_write_phy(), bp, EBUSY, MII_BMCR, PHY_RESET_MAX_WAIT, reg, and udelay().

Referenced by bnx2_init_phy().

◆ bnx2_phy_get_pause_adv()

static u32 bnx2_phy_get_pause_adv ( struct bnx2 bp)
static

Definition at line 749 of file bnx2.c.

750 {
751  u32 adv = 0;
752 
753  if ((bp->req_flow_ctrl & (FLOW_CTRL_RX | FLOW_CTRL_TX)) ==
755 
756  if (bp->phy_flags & PHY_SERDES_FLAG) {
757  adv = ADVERTISE_1000XPAUSE;
758  }
759  else {
760  adv = ADVERTISE_PAUSE_CAP;
761  }
762  }
763  else if (bp->req_flow_ctrl & FLOW_CTRL_TX) {
764  if (bp->phy_flags & PHY_SERDES_FLAG) {
766  }
767  else {
768  adv = ADVERTISE_PAUSE_ASYM;
769  }
770  }
771  else if (bp->req_flow_ctrl & FLOW_CTRL_RX) {
772  if (bp->phy_flags & PHY_SERDES_FLAG) {
774  }
775  else {
777  }
778  }
779  return adv;
780 }
#define ADVERTISE_1000XPAUSE
Definition: mii.h:79
uint16_t bp
Definition: registers.h:23
#define FLOW_CTRL_TX
Definition: bnx2.h:4152
#define ADVERTISE_1000XPSE_ASYM
Definition: mii.h:81
#define ADVERTISE_PAUSE_ASYM
Definition: mii.h:84
#define PHY_SERDES_FLAG
Definition: bnx2.h:4061
#define FLOW_CTRL_RX
Definition: bnx2.h:4153
#define ADVERTISE_PAUSE_CAP
Definition: mii.h:83
uint32_t u32
Definition: stdint.h:23

References ADVERTISE_1000XPAUSE, ADVERTISE_1000XPSE_ASYM, ADVERTISE_PAUSE_ASYM, ADVERTISE_PAUSE_CAP, bp, FLOW_CTRL_RX, FLOW_CTRL_TX, and PHY_SERDES_FLAG.

Referenced by bnx2_setup_copper_phy(), and bnx2_setup_serdes_phy().

◆ bnx2_setup_serdes_phy()

static int bnx2_setup_serdes_phy ( struct bnx2 bp)
static

Definition at line 783 of file bnx2.c.

784 {
785  u32 adv, bmcr, up1;
786  u32 new_adv = 0;
787 
788  if (!(bp->autoneg & AUTONEG_SPEED)) {
789  u32 new_bmcr;
790  int force_link_down = 0;
791 
792  if (CHIP_NUM(bp) == CHIP_NUM_5708) {
793  bnx2_read_phy(bp, BCM5708S_UP1, &up1);
794  if (up1 & BCM5708S_UP1_2G5) {
795  up1 &= ~BCM5708S_UP1_2G5;
797  force_link_down = 1;
798  }
799  }
800 
803 
804  bnx2_read_phy(bp, MII_BMCR, &bmcr);
805  new_bmcr = bmcr & ~BMCR_ANENABLE;
806  new_bmcr |= BMCR_SPEED1000;
807  if (bp->req_duplex == DUPLEX_FULL) {
808  adv |= ADVERTISE_1000XFULL;
809  new_bmcr |= BMCR_FULLDPLX;
810  }
811  else {
812  adv |= ADVERTISE_1000XHALF;
813  new_bmcr &= ~BMCR_FULLDPLX;
814  }
815  if ((new_bmcr != bmcr) || (force_link_down)) {
816  /* Force a link down visible on the other side */
817  if (bp->link_up) {
821  bnx2_write_phy(bp, MII_BMCR, bmcr |
823 
824  bp->link_up = 0;
825  bnx2_write_phy(bp, MII_BMCR, new_bmcr);
826  }
828  bnx2_write_phy(bp, MII_BMCR, new_bmcr);
829  }
830  return 0;
831  }
832 
833  if (bp->phy_flags & PHY_2_5G_CAPABLE_FLAG) {
834  bnx2_read_phy(bp, BCM5708S_UP1, &up1);
835  up1 |= BCM5708S_UP1_2G5;
837  }
838 
839  if (bp->advertising & ADVERTISED_1000baseT_Full)
840  new_adv |= ADVERTISE_1000XFULL;
841 
842  new_adv |= bnx2_phy_get_pause_adv(bp);
843 
845  bnx2_read_phy(bp, MII_BMCR, &bmcr);
846 
847  bp->serdes_an_pending = 0;
848  if ((adv != new_adv) || ((bmcr & BMCR_ANENABLE) == 0)) {
849  /* Force a link down visible on the other side */
850  if (bp->link_up) {
851  int i;
852 
854  for (i = 0; i < 110; i++) {
855  udelay(100);
856  }
857  }
858 
859  bnx2_write_phy(bp, MII_ADVERTISE, new_adv);
861  BMCR_ANENABLE);
862 #if 0
863  if (CHIP_NUM(bp) == CHIP_NUM_5706) {
864  /* Speed up link-up time when the link partner
865  * does not autonegotiate which is very common
866  * in blade servers. Some blade servers use
867  * IPMI for kerboard input and it's important
868  * to minimize link disruptions. Autoneg. involves
869  * exchanging base pages plus 3 next pages and
870  * normally completes in about 120 msec.
871  */
872  bp->current_interval = SERDES_AN_TIMEOUT;
873  bp->serdes_an_pending = 1;
874  mod_timer(&bp->timer, jiffies + bp->current_interval);
875  }
876 #endif
877  }
878 
879  return 0;
880 }
#define MII_ADVERTISE
Definition: atl1e.h:875
#define PHY_2_5G_CAPABLE_FLAG
Definition: bnx2.h:4064
#define BMCR_ANRESTART
Definition: mii.h:46
uint16_t bp
Definition: registers.h:23
#define CHIP_NUM_5708
Definition: bnx2.h:4073
#define BMCR_LOOPBACK
Definition: mii.h:51
#define BMCR_SPEED1000
Definition: mii.h:43
static int bnx2_read_phy(struct bnx2 *bp, u32 reg, u32 *val)
Definition: bnx2.c:159
#define ADVERTISE_1000XHALF
Definition: mii.h:77
#define BCM5708S_UP1_2G5
Definition: bnx2.h:3825
#define CHIP_NUM(bp)
Definition: bnx2.h:4071
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
#define DUPLEX_FULL
Definition: bnx2.h:111
static u32 bnx2_phy_get_pause_adv(struct bnx2 *bp)
Definition: bnx2.c:749
#define MII_BMCR
Definition: atl1e.h:871
#define SERDES_AN_TIMEOUT
Definition: bnx2.h:4169
static int bnx2_write_phy(struct bnx2 *bp, u32 reg, u32 val)
Definition: bnx2.c:216
#define CHIP_NUM_5706
Definition: bnx2.h:4072
#define BCM5708S_UP1
Definition: bnx2.h:3823
#define BMCR_ANENABLE
Definition: mii.h:49
#define AUTONEG_SPEED
Definition: bnx2.h:4161
#define ADVERTISED_1000baseT_Full
Definition: bnx2.h:47
uint32_t u32
Definition: stdint.h:23
#define BMCR_FULLDPLX
Definition: mii.h:45
#define ADVERTISE_1000XFULL
Definition: mii.h:75

References ADVERTISE_1000XFULL, ADVERTISE_1000XHALF, ADVERTISED_1000baseT_Full, AUTONEG_SPEED, BCM5708S_UP1, BCM5708S_UP1_2G5, BMCR_ANENABLE, BMCR_ANRESTART, BMCR_FULLDPLX, BMCR_LOOPBACK, BMCR_SPEED1000, bnx2_phy_get_pause_adv(), bnx2_read_phy(), bnx2_write_phy(), bp, CHIP_NUM, CHIP_NUM_5706, CHIP_NUM_5708, DUPLEX_FULL, MII_ADVERTISE, MII_BMCR, PHY_2_5G_CAPABLE_FLAG, SERDES_AN_TIMEOUT, and udelay().

Referenced by bnx2_setup_phy().

◆ bnx2_setup_copper_phy()

static int bnx2_setup_copper_phy ( struct bnx2 bp)
static

Definition at line 896 of file bnx2.c.

897 {
898  u32 bmcr;
899  u32 new_bmcr;
900 
901  bnx2_read_phy(bp, MII_BMCR, &bmcr);
902 
903  if (bp->autoneg & AUTONEG_SPEED) {
904  u32 adv_reg, adv1000_reg;
905  u32 new_adv_reg = 0;
906  u32 new_adv1000_reg = 0;
907 
908  bnx2_read_phy(bp, MII_ADVERTISE, &adv_reg);
911 
912  bnx2_read_phy(bp, MII_CTRL1000, &adv1000_reg);
913  adv1000_reg &= PHY_ALL_1000_SPEED;
914 
915  if (bp->advertising & ADVERTISED_10baseT_Half)
916  new_adv_reg |= ADVERTISE_10HALF;
917  if (bp->advertising & ADVERTISED_10baseT_Full)
918  new_adv_reg |= ADVERTISE_10FULL;
919  if (bp->advertising & ADVERTISED_100baseT_Half)
920  new_adv_reg |= ADVERTISE_100HALF;
921  if (bp->advertising & ADVERTISED_100baseT_Full)
922  new_adv_reg |= ADVERTISE_100FULL;
923  if (bp->advertising & ADVERTISED_1000baseT_Full)
924  new_adv1000_reg |= ADVERTISE_1000FULL;
925 
926  new_adv_reg |= ADVERTISE_CSMA;
927 
928  new_adv_reg |= bnx2_phy_get_pause_adv(bp);
929 
930  if ((adv1000_reg != new_adv1000_reg) ||
931  (adv_reg != new_adv_reg) ||
932  ((bmcr & BMCR_ANENABLE) == 0)) {
933 
934  bnx2_write_phy(bp, MII_ADVERTISE, new_adv_reg);
935  bnx2_write_phy(bp, MII_CTRL1000, new_adv1000_reg);
937  BMCR_ANENABLE);
938  }
939  else if (bp->link_up) {
940  /* Flow ctrl may have changed from auto to forced */
941  /* or vice-versa. */
942 
945  }
946  return 0;
947  }
948 
949  new_bmcr = 0;
950  if (bp->req_line_speed == SPEED_100) {
951  new_bmcr |= BMCR_SPEED100;
952  }
953  if (bp->req_duplex == DUPLEX_FULL) {
954  new_bmcr |= BMCR_FULLDPLX;
955  }
956  if (new_bmcr != bmcr) {
957  u32 bmsr;
958  int i = 0;
959 
960  bnx2_read_phy(bp, MII_BMSR, &bmsr);
961  bnx2_read_phy(bp, MII_BMSR, &bmsr);
962 
963  if (bmsr & BMSR_LSTATUS) {
964  /* Force link down */
966  do {
967  udelay(100);
968  bnx2_read_phy(bp, MII_BMSR, &bmsr);
969  bnx2_read_phy(bp, MII_BMSR, &bmsr);
970  i++;
971  } while ((bmsr & BMSR_LSTATUS) && (i < 620));
972  }
973 
974  bnx2_write_phy(bp, MII_BMCR, new_bmcr);
975 
976  /* Normally, the new speed is setup after the link has
977  * gone down and up again. In some cases, link will not go
978  * down so we need to set up the new speed here.
979  */
980  if (bmsr & BMSR_LSTATUS) {
981  bp->line_speed = bp->req_line_speed;
982  bp->duplex = bp->req_duplex;
985  }
986  }
987  return 0;
988 }
#define MII_ADVERTISE
Definition: atl1e.h:875
#define ADVERTISE_1000FULL
Definition: mii.h:133
#define ADVERTISE_10FULL
Definition: mii.h:76
#define PHY_ALL_1000_SPEED
Definition: bnx2.c:893
#define ADVERTISED_100baseT_Half
Definition: bnx2.h:44
#define BMCR_ANRESTART
Definition: mii.h:46
uint16_t bp
Definition: registers.h:23
#define ADVERTISE_100FULL
Definition: mii.h:80
#define BMCR_LOOPBACK
Definition: mii.h:51
#define SPEED_100
Definition: atl1e.h:51
static int bnx2_read_phy(struct bnx2 *bp, u32 reg, u32 *val)
Definition: bnx2.c:159
#define PHY_ALL_10_100_SPEED
Definition: bnx2.c:890
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
#define DUPLEX_FULL
Definition: bnx2.h:111
#define MII_CTRL1000
Definition: mii.h:24
#define ADVERTISE_PAUSE_ASYM
Definition: mii.h:84
static u32 bnx2_phy_get_pause_adv(struct bnx2 *bp)
Definition: bnx2.c:749
#define BMSR_LSTATUS
Definition: mii.h:57
#define MII_BMCR
Definition: atl1e.h:871
#define ADVERTISE_CSMA
Definition: mii.h:73
static int bnx2_write_phy(struct bnx2 *bp, u32 reg, u32 val)
Definition: bnx2.c:216
#define ADVERTISE_10HALF
Definition: mii.h:74
static int bnx2_set_mac_link(struct bnx2 *bp)
Definition: bnx2.c:592
#define ADVERTISED_10baseT_Full
Definition: bnx2.h:43
#define ADVERTISE_PAUSE_CAP
Definition: mii.h:83
static void bnx2_resolve_flow_ctrl(struct bnx2 *bp)
Definition: bnx2.c:384
#define ADVERTISE_100HALF
Definition: mii.h:78
#define BMCR_ANENABLE
Definition: mii.h:49
#define MII_BMSR
Definition: atl1e.h:872
#define AUTONEG_SPEED
Definition: bnx2.h:4161
#define ADVERTISED_1000baseT_Full
Definition: bnx2.h:47
#define BMCR_SPEED100
Definition: mii.h:50
#define ADVERTISED_100baseT_Full
Definition: bnx2.h:45
#define ADVERTISED_10baseT_Half
Definition: bnx2.h:42
uint32_t u32
Definition: stdint.h:23
#define BMCR_FULLDPLX
Definition: mii.h:45

References ADVERTISE_1000FULL, ADVERTISE_100FULL, ADVERTISE_100HALF, ADVERTISE_10FULL, ADVERTISE_10HALF, ADVERTISE_CSMA, ADVERTISE_PAUSE_ASYM, ADVERTISE_PAUSE_CAP, ADVERTISED_1000baseT_Full, ADVERTISED_100baseT_Full, ADVERTISED_100baseT_Half, ADVERTISED_10baseT_Full, ADVERTISED_10baseT_Half, AUTONEG_SPEED, BMCR_ANENABLE, BMCR_ANRESTART, BMCR_FULLDPLX, BMCR_LOOPBACK, BMCR_SPEED100, BMSR_LSTATUS, bnx2_phy_get_pause_adv(), bnx2_read_phy(), bnx2_resolve_flow_ctrl(), bnx2_set_mac_link(), bnx2_write_phy(), bp, DUPLEX_FULL, MII_ADVERTISE, MII_BMCR, MII_BMSR, MII_CTRL1000, PHY_ALL_1000_SPEED, PHY_ALL_10_100_SPEED, SPEED_100, and udelay().

Referenced by bnx2_setup_phy().

◆ bnx2_setup_phy()

static int bnx2_setup_phy ( struct bnx2 bp)
static

Definition at line 991 of file bnx2.c.

992 {
993  if (bp->loopback == MAC_LOOPBACK)
994  return 0;
995 
996  if (bp->phy_flags & PHY_SERDES_FLAG) {
997  return (bnx2_setup_serdes_phy(bp));
998  }
999  else {
1000  return (bnx2_setup_copper_phy(bp));
1001  }
1002 }
uint16_t bp
Definition: registers.h:23
#define MAC_LOOPBACK
Definition: bnx2.h:4165
static int bnx2_setup_serdes_phy(struct bnx2 *bp)
Definition: bnx2.c:783
#define PHY_SERDES_FLAG
Definition: bnx2.h:4061
static int bnx2_setup_copper_phy(struct bnx2 *bp)
Definition: bnx2.c:896

References bnx2_setup_copper_phy(), bnx2_setup_serdes_phy(), bp, MAC_LOOPBACK, and PHY_SERDES_FLAG.

Referenced by bnx2_init_phy().

◆ bnx2_init_5708s_phy()

static int bnx2_init_5708s_phy ( struct bnx2 bp)
static

Definition at line 1005 of file bnx2.c.

1006 {
1007  u32 val;
1008 
1012 
1016 
1020 
1021  if (bp->phy_flags & PHY_2_5G_CAPABLE_FLAG) {
1023  val |= BCM5708S_UP1_2G5;
1025  }
1026 
1027  if ((CHIP_ID(bp) == CHIP_ID_5708_A0) ||
1028  (CHIP_ID(bp) == CHIP_ID_5708_B0) ||
1029  (CHIP_ID(bp) == CHIP_ID_5708_B1)) {
1030  /* increase tx signal amplitude */
1037  }
1038 
1039  val = REG_RD_IND(bp, bp->shmem_base + BNX2_PORT_HW_CFG_CONFIG) &
1041 
1042  if (val) {
1043  u32 is_backplane;
1044 
1045  is_backplane = REG_RD_IND(bp, bp->shmem_base +
1047  if (is_backplane & BNX2_SHARED_HW_CFG_PHY_BACKPLANE) {
1053  }
1054  }
1055  return 0;
1056 }
#define BCM5708S_1000X_CTL2
Definition: bnx2.h:3839
#define CHIP_ID_5708_B1
Definition: bnx2.h:4089
#define BCM5708S_1000X_CTL1_AUTODET_EN
Definition: bnx2.h:3837
#define BCM5708S_BLK_ADDR_DIG
Definition: bnx2.h:3829
#define PHY_2_5G_CAPABLE_FLAG
Definition: bnx2.h:4064
uint16_t bp
Definition: registers.h:23
#define BCM5708S_1000X_CTL2_PLLEL_DET_EN
Definition: bnx2.h:3841
#define REG_RD_IND(bp, offset)
Definition: bnx2.h:4200
static int bnx2_read_phy(struct bnx2 *bp, u32 reg, u32 *val)
Definition: bnx2.c:159
#define BCM5708S_1000X_CTL1
Definition: bnx2.h:3834
#define BNX2_SHARED_HW_CFG_CONFIG
Definition: bnx2.h:4374
#define BCM5708S_UP1_2G5
Definition: bnx2.h:3825
#define BCM5708S_TX_ACTL1_DRIVER_VCM
Definition: bnx2.h:3864
#define BCM5708S_BLK_ADDR_TX_MISC
Definition: bnx2.h:3831
#define BCM5708S_BLK_ADDR
Definition: bnx2.h:3827
#define BCM5708S_1000X_CTL1_FIBER_MODE
Definition: bnx2.h:3836
#define BCM5708S_BLK_ADDR_DIG3
Definition: bnx2.h:3830
#define BCM5708S_TX_ACTL3
Definition: bnx2.h:3866
#define CHIP_ID_5708_B0
Definition: bnx2.h:4088
#define BNX2_SHARED_HW_CFG_PHY_BACKPLANE
Definition: bnx2.h:4380
void __asmcall int val
Definition: setjmp.h:28
static int bnx2_write_phy(struct bnx2 *bp, u32 reg, u32 val)
Definition: bnx2.c:216
#define BCM5708S_DIG_3_0
Definition: bnx2.h:3857
#define BNX2_PORT_HW_CFG_CFG_TXCTL3_MASK
Definition: bnx2.h:4397
#define BCM5708S_UP1
Definition: bnx2.h:3823
#define CHIP_ID(bp)
Definition: bnx2.h:4083
#define BCM5708S_TX_ACTL1
Definition: bnx2.h:3862
#define BCM5708S_DIG_3_0_USE_IEEE
Definition: bnx2.h:3859
#define CHIP_ID_5708_A0
Definition: bnx2.h:4087
#define BNX2_PORT_HW_CFG_CONFIG
Definition: bnx2.h:4396
uint32_t u32
Definition: stdint.h:23

References BCM5708S_1000X_CTL1, BCM5708S_1000X_CTL1_AUTODET_EN, BCM5708S_1000X_CTL1_FIBER_MODE, BCM5708S_1000X_CTL2, BCM5708S_1000X_CTL2_PLLEL_DET_EN, BCM5708S_BLK_ADDR, BCM5708S_BLK_ADDR_DIG, BCM5708S_BLK_ADDR_DIG3, BCM5708S_BLK_ADDR_TX_MISC, BCM5708S_DIG_3_0, BCM5708S_DIG_3_0_USE_IEEE, BCM5708S_TX_ACTL1, BCM5708S_TX_ACTL1_DRIVER_VCM, BCM5708S_TX_ACTL3, BCM5708S_UP1, BCM5708S_UP1_2G5, BNX2_PORT_HW_CFG_CFG_TXCTL3_MASK, BNX2_PORT_HW_CFG_CONFIG, bnx2_read_phy(), BNX2_SHARED_HW_CFG_CONFIG, BNX2_SHARED_HW_CFG_PHY_BACKPLANE, bnx2_write_phy(), bp, CHIP_ID, CHIP_ID_5708_A0, CHIP_ID_5708_B0, CHIP_ID_5708_B1, PHY_2_5G_CAPABLE_FLAG, REG_RD_IND, and val.

Referenced by bnx2_init_phy().

◆ bnx2_init_5706s_phy()

static int bnx2_init_5706s_phy ( struct bnx2 bp)
static

Definition at line 1059 of file bnx2.c.

1060 {
1061  u32 val;
1062 
1063  bp->phy_flags &= ~PHY_PARALLEL_DETECT_FLAG;
1064 
1065  if (CHIP_NUM(bp) == CHIP_NUM_5706) {
1066  REG_WR(bp, BNX2_MISC_UNUSED0, 0x300);
1067  }
1068 
1069 
1070  bnx2_write_phy(bp, 0x18, 0x7);
1071  bnx2_read_phy(bp, 0x18, &val);
1072  bnx2_write_phy(bp, 0x18, val & ~0x4007);
1073 
1074  bnx2_write_phy(bp, 0x1c, 0x6c00);
1075  bnx2_read_phy(bp, 0x1c, &val);
1076  bnx2_write_phy(bp, 0x1c, (val & 0x3fd) | 0xec00);
1077 
1078  return 0;
1079 }
#define REG_WR(bp, offset, val)
Definition: bnx2.h:4194
uint16_t bp
Definition: registers.h:23
static int bnx2_read_phy(struct bnx2 *bp, u32 reg, u32 *val)
Definition: bnx2.c:159
#define CHIP_NUM(bp)
Definition: bnx2.h:4071
#define BNX2_MISC_UNUSED0
Definition: bnx2.h:1141
void __asmcall int val
Definition: setjmp.h:28
static int bnx2_write_phy(struct bnx2 *bp, u32 reg, u32 val)
Definition: bnx2.c:216
#define CHIP_NUM_5706
Definition: bnx2.h:4072
#define PHY_PARALLEL_DETECT_FLAG
Definition: bnx2.h:4063
uint32_t u32
Definition: stdint.h:23

References BNX2_MISC_UNUSED0, bnx2_read_phy(), bnx2_write_phy(), bp, CHIP_NUM, CHIP_NUM_5706, PHY_PARALLEL_DETECT_FLAG, REG_WR, and val.

Referenced by bnx2_init_phy().

◆ bnx2_init_copper_phy()

static int bnx2_init_copper_phy ( struct bnx2 bp)
static

Definition at line 1082 of file bnx2.c.

1083 {
1084  u32 val;
1085 
1086  bp->phy_flags |= PHY_CRC_FIX_FLAG;
1087 
1088  if (bp->phy_flags & PHY_CRC_FIX_FLAG) {
1089  bnx2_write_phy(bp, 0x18, 0x0c00);
1090  bnx2_write_phy(bp, 0x17, 0x000a);
1091  bnx2_write_phy(bp, 0x15, 0x310b);
1092  bnx2_write_phy(bp, 0x17, 0x201f);
1093  bnx2_write_phy(bp, 0x15, 0x9506);
1094  bnx2_write_phy(bp, 0x17, 0x401f);
1095  bnx2_write_phy(bp, 0x15, 0x14e2);
1096  bnx2_write_phy(bp, 0x18, 0x0400);
1097  }
1098 
1099  bnx2_write_phy(bp, 0x18, 0x7);
1100  bnx2_read_phy(bp, 0x18, &val);
1101  bnx2_write_phy(bp, 0x18, val & ~0x4007);
1102 
1103  bnx2_read_phy(bp, 0x10, &val);
1104  bnx2_write_phy(bp, 0x10, val & ~0x1);
1105 
1106  /* ethernet@wirespeed */
1107  bnx2_write_phy(bp, 0x18, 0x7007);
1108  bnx2_read_phy(bp, 0x18, &val);
1109  bnx2_write_phy(bp, 0x18, val | (1 << 15) | (1 << 4));
1110  return 0;
1111 }
uint16_t bp
Definition: registers.h:23
static int bnx2_read_phy(struct bnx2 *bp, u32 reg, u32 *val)
Definition: bnx2.c:159
void __asmcall int val
Definition: setjmp.h:28
static int bnx2_write_phy(struct bnx2 *bp, u32 reg, u32 val)
Definition: bnx2.c:216
#define PHY_CRC_FIX_FLAG
Definition: bnx2.h:4062
uint32_t u32
Definition: stdint.h:23

References bnx2_read_phy(), bnx2_write_phy(), bp, PHY_CRC_FIX_FLAG, and val.

Referenced by bnx2_init_phy().

◆ bnx2_init_phy()

static int bnx2_init_phy ( struct bnx2 bp)
static

Definition at line 1114 of file bnx2.c.

1115 {
1116  u32 val;
1117  int rc = 0;
1118 
1119  bp->phy_flags &= ~PHY_INT_MODE_MASK_FLAG;
1120  bp->phy_flags |= PHY_INT_MODE_LINK_READY_FLAG;
1121 
1123 
1124  bnx2_reset_phy(bp);
1125 
1127  bp->phy_id = val << 16;
1129  bp->phy_id |= val & 0xffff;
1130 
1131  if (bp->phy_flags & PHY_SERDES_FLAG) {
1132  if (CHIP_NUM(bp) == CHIP_NUM_5706)
1134  else if (CHIP_NUM(bp) == CHIP_NUM_5708)
1136  }
1137  else {
1139  }
1140 
1141  bnx2_setup_phy(bp);
1142 
1143  return rc;
1144 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static int bnx2_setup_phy(struct bnx2 *bp)
Definition: bnx2.c:991
#define REG_WR(bp, offset, val)
Definition: bnx2.h:4194
uint16_t bp
Definition: registers.h:23
#define PHY_INT_MODE_MASK_FLAG
Definition: bnx2.h:4065
static int bnx2_init_5708s_phy(struct bnx2 *bp)
Definition: bnx2.c:1005
#define CHIP_NUM_5708
Definition: bnx2.h:4073
static int bnx2_read_phy(struct bnx2 *bp, u32 reg, u32 *val)
Definition: bnx2.c:159
static int bnx2_reset_phy(struct bnx2 *bp)
Definition: bnx2.c:725
#define PHY_INT_MODE_LINK_READY_FLAG
Definition: bnx2.h:4067
#define CHIP_NUM(bp)
Definition: bnx2.h:4071
#define BNX2_EMAC_ATTENTION_ENA_LINK
Definition: bnx2.h:1557
#define PHY_SERDES_FLAG
Definition: bnx2.h:4061
void __asmcall int val
Definition: setjmp.h:28
static int bnx2_init_copper_phy(struct bnx2 *bp)
Definition: bnx2.c:1082
static int bnx2_init_5706s_phy(struct bnx2 *bp)
Definition: bnx2.c:1059
#define CHIP_NUM_5706
Definition: bnx2.h:4072
#define MII_PHYSID2
Definition: atl1e.h:874
#define BNX2_EMAC_ATTENTION_ENA
Definition: bnx2.h:1556
#define MII_PHYSID1
Definition: atl1e.h:873
uint32_t u32
Definition: stdint.h:23

References BNX2_EMAC_ATTENTION_ENA, BNX2_EMAC_ATTENTION_ENA_LINK, bnx2_init_5706s_phy(), bnx2_init_5708s_phy(), bnx2_init_copper_phy(), bnx2_read_phy(), bnx2_reset_phy(), bnx2_setup_phy(), bp, CHIP_NUM, CHIP_NUM_5706, CHIP_NUM_5708, MII_PHYSID1, MII_PHYSID2, PHY_INT_MODE_LINK_READY_FLAG, PHY_INT_MODE_MASK_FLAG, PHY_SERDES_FLAG, rc, REG_WR, and val.

Referenced by bnx2_init_nic().

◆ bnx2_fw_sync()

static int bnx2_fw_sync ( struct bnx2 bp,
u32  msg_data,
int  silent 
)
static

Definition at line 1147 of file bnx2.c.

1148 {
1149  int i;
1150  u32 val;
1151 
1152  bp->fw_wr_seq++;
1153  msg_data |= bp->fw_wr_seq;
1154 
1155  REG_WR_IND(bp, bp->shmem_base + BNX2_DRV_MB, msg_data);
1156 
1157  /* wait for an acknowledgement. */
1158  for (i = 0; i < (FW_ACK_TIME_OUT_MS / 50); i++) {
1159  mdelay(50);
1160 
1161  val = REG_RD_IND(bp, bp->shmem_base + BNX2_FW_MB);
1162 
1163  if ((val & BNX2_FW_MSG_ACK) == (msg_data & BNX2_DRV_MSG_SEQ))
1164  break;
1165  }
1166  if ((msg_data & BNX2_DRV_MSG_DATA) == BNX2_DRV_MSG_DATA_WAIT0)
1167  return 0;
1168 
1169  /* If we timed out, inform the firmware that this is the case. */
1170  if ((val & BNX2_FW_MSG_ACK) != (msg_data & BNX2_DRV_MSG_SEQ)) {
1171  if (!silent)
1172  printf("fw sync timeout, reset code = %x\n", (unsigned int) msg_data);
1173 
1174  msg_data &= ~BNX2_DRV_MSG_CODE;
1175  msg_data |= BNX2_DRV_MSG_CODE_FW_TIMEOUT;
1176 
1177  REG_WR_IND(bp, bp->shmem_base + BNX2_DRV_MB, msg_data);
1178 
1179  return -EBUSY;
1180  }
1181 
1183  return -EIO;
1184 
1185  return 0;
1186 }
#define BNX2_FW_MSG_STATUS_MASK
Definition: bnx2.h:4312
int printf(const char *fmt,...)
Write a formatted string to the console.
Definition: vsprintf.c:464
#define EBUSY
Device or resource busy.
Definition: errno.h:338
#define BNX2_DRV_MSG_CODE
Definition: bnx2.h:4292
#define BNX2_DRV_MSG_DATA_WAIT0
Definition: bnx2.h:4303
uint16_t bp
Definition: registers.h:23
#define REG_RD_IND(bp, offset)
Definition: bnx2.h:4200
#define BNX2_DRV_MSG_DATA
Definition: bnx2.h:4302
#define BNX2_DRV_MSG_CODE_FW_TIMEOUT
Definition: bnx2.h:4297
#define BNX2_DRV_MSG_SEQ
Definition: bnx2.h:4308
void __asmcall int val
Definition: setjmp.h:28
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition: timer.c:78
#define BNX2_DRV_MB
Definition: bnx2.h:4291
#define FW_ACK_TIME_OUT_MS
Definition: bnx2.h:4284
#define EIO
Input/output error.
Definition: errno.h:433
#define BNX2_FW_MB
Definition: bnx2.h:4310
#define BNX2_FW_MSG_ACK
Definition: bnx2.h:4311
#define BNX2_FW_MSG_STATUS_OK
Definition: bnx2.h:4313
#define REG_WR_IND(bp, offset, val)
Definition: bnx2.h:4203
uint32_t u32
Definition: stdint.h:23

References BNX2_DRV_MB, BNX2_DRV_MSG_CODE, BNX2_DRV_MSG_CODE_FW_TIMEOUT, BNX2_DRV_MSG_DATA, BNX2_DRV_MSG_DATA_WAIT0, BNX2_DRV_MSG_SEQ, BNX2_FW_MB, BNX2_FW_MSG_ACK, BNX2_FW_MSG_STATUS_MASK, BNX2_FW_MSG_STATUS_OK, bp, EBUSY, EIO, FW_ACK_TIME_OUT_MS, mdelay(), printf(), REG_RD_IND, REG_WR_IND, and val.

Referenced by bnx2_init_chip(), and bnx2_reset_chip().

◆ bnx2_init_context()

static void bnx2_init_context ( struct bnx2 bp)
static

Definition at line 1189 of file bnx2.c.

1190 {
1191  u32 vcid;
1192 
1193  vcid = 96;
1194  while (vcid) {
1195  u32 vcid_addr, pcid_addr, offset;
1196 
1197  vcid--;
1198 
1199  if (CHIP_ID(bp) == CHIP_ID_5706_A0) {
1200  u32 new_vcid;
1201 
1202  vcid_addr = GET_PCID_ADDR(vcid);
1203  if (vcid & 0x8) {
1204  new_vcid = 0x60 + (vcid & 0xf0) + (vcid & 0x7);
1205  }
1206  else {
1207  new_vcid = vcid;
1208  }
1209  pcid_addr = GET_PCID_ADDR(new_vcid);
1210  }
1211  else {
1212  vcid_addr = GET_CID_ADDR(vcid);
1213  pcid_addr = vcid_addr;
1214  }
1215 
1216  REG_WR(bp, BNX2_CTX_VIRT_ADDR, 0x00);
1217  REG_WR(bp, BNX2_CTX_PAGE_TBL, pcid_addr);
1218 
1219  /* Zero out the context. */
1220  for (offset = 0; offset < PHY_CTX_SIZE; offset += 4) {
1221  CTX_WR(bp, 0x00, offset, 0);
1222  }
1223 
1224  REG_WR(bp, BNX2_CTX_VIRT_ADDR, vcid_addr);
1225  REG_WR(bp, BNX2_CTX_PAGE_TBL, pcid_addr);
1226  }
1227 }
#define REG_WR(bp, offset, val)
Definition: bnx2.h:4194
uint16_t bp
Definition: registers.h:23
#define CHIP_ID_5706_A0
Definition: bnx2.h:4084
#define BNX2_CTX_PAGE_TBL
Definition: bnx2.h:1476
static userptr_t size_t offset
Offset of the first segment within the content.
Definition: deflate.h:259
#define GET_PCID_ADDR(_pcid)
Definition: bnx2.h:3917
#define GET_CID_ADDR(_cid)
Definition: bnx2.h:3911
#define BNX2_CTX_VIRT_ADDR
Definition: bnx2.h:1473
#define CTX_WR(bp, cid_addr, offset, val)
Definition: bnx2.h:4210
#define PHY_CTX_SIZE
Definition: bnx2.h:3915
#define CHIP_ID(bp)
Definition: bnx2.h:4083
uint32_t u32
Definition: stdint.h:23

References BNX2_CTX_PAGE_TBL, BNX2_CTX_VIRT_ADDR, bp, CHIP_ID, CHIP_ID_5706_A0, CTX_WR, GET_CID_ADDR, GET_PCID_ADDR, offset, PHY_CTX_SIZE, and REG_WR.

Referenced by bnx2_init_chip().

◆ bnx2_alloc_bad_rbuf()

static int bnx2_alloc_bad_rbuf ( struct bnx2 bp)
static

Definition at line 1230 of file bnx2.c.

1231 {
1232  u16 good_mbuf[512];
1233  u32 good_mbuf_cnt;
1234  u32 val;
1235 
1238 
1239  good_mbuf_cnt = 0;
1240 
1241  /* Allocate a bunch of mbufs and save the good ones in an array. */
1243  while (val & BNX2_RBUF_STATUS1_FREE_COUNT) {
1245 
1247 
1249 
1250  /* The addresses with Bit 9 set are bad memory blocks. */
1251  if (!(val & (1 << 9))) {
1252  good_mbuf[good_mbuf_cnt] = (u16) val;
1253  good_mbuf_cnt++;
1254  }
1255 
1257  }
1258 
1259  /* Free the good ones back to the mbuf pool thus discarding
1260  * all the bad ones. */
1261  while (good_mbuf_cnt) {
1262  good_mbuf_cnt--;
1263 
1264  val = good_mbuf[good_mbuf_cnt];
1265  val = (val << 9) | val | 1;
1266 
1268  }
1269  return 0;
1270 }
#define u16
Definition: vga.h:20
uint16_t u16
Definition: stdint.h:21
#define BNX2_RBUF_COMMAND
Definition: bnx2.h:2388
#define BNX2_RBUF_FW_BUF_ALLOC
Definition: bnx2.h:2406
#define BNX2_RBUF_STATUS1
Definition: bnx2.h:2395
#define REG_WR(bp, offset, val)
Definition: bnx2.h:4194
uint16_t bp
Definition: registers.h:23
#define BNX2_RBUF_FW_BUF_ALLOC_VALUE
Definition: bnx2.h:2407
#define REG_RD_IND(bp, offset)
Definition: bnx2.h:4200
void __asmcall int val
Definition: setjmp.h:28
#define BNX2_RBUF_COMMAND_ALLOC_REQ
Definition: bnx2.h:2393
#define BNX2_MISC_ENABLE_SET_BITS
Definition: bnx2.h:769
#define BNX2_MISC_ENABLE_SET_BITS_RX_MBUF_ENABLE
Definition: bnx2.h:782
#define REG_WR_IND(bp, offset, val)
Definition: bnx2.h:4203
#define BNX2_RBUF_STATUS1_FREE_COUNT
Definition: bnx2.h:2396
#define BNX2_RBUF_FW_BUF_FREE
Definition: bnx2.h:2409
uint32_t u32
Definition: stdint.h:23

References BNX2_MISC_ENABLE_SET_BITS, BNX2_MISC_ENABLE_SET_BITS_RX_MBUF_ENABLE, BNX2_RBUF_COMMAND, BNX2_RBUF_COMMAND_ALLOC_REQ, BNX2_RBUF_FW_BUF_ALLOC, BNX2_RBUF_FW_BUF_ALLOC_VALUE, BNX2_RBUF_FW_BUF_FREE, BNX2_RBUF_STATUS1, BNX2_RBUF_STATUS1_FREE_COUNT, bp, REG_RD_IND, REG_WR, REG_WR_IND, u16, and val.

Referenced by bnx2_reset_chip().

◆ bnx2_set_mac_addr()

static void bnx2_set_mac_addr ( struct bnx2 bp)
static

Definition at line 1273 of file bnx2.c.

1274 {
1275  u32 val;
1276  u8 *mac_addr = bp->nic->node_addr;
1277 
1278  val = (mac_addr[0] << 8) | mac_addr[1];
1279 
1281 
1282  val = (mac_addr[2] << 24) | (mac_addr[3] << 16) |
1283  (mac_addr[4] << 8) | mac_addr[5];
1284 
1286 }
#define REG_WR(bp, offset, val)
Definition: bnx2.h:4194
uint16_t bp
Definition: registers.h:23
#define BNX2_EMAC_MAC_MATCH1
Definition: bnx2.h:1578
#define BNX2_EMAC_MAC_MATCH0
Definition: bnx2.h:1577
void __asmcall int val
Definition: setjmp.h:28
uint8_t u8
Definition: stdint.h:19
uint32_t u32
Definition: stdint.h:23

References BNX2_EMAC_MAC_MATCH0, BNX2_EMAC_MAC_MATCH1, bp, REG_WR, and val.

Referenced by bnx2_init_chip().

◆ bnx2_set_rx_mode()

static void bnx2_set_rx_mode ( struct nic *nic  __unused)
static

Definition at line 1289 of file bnx2.c.

1290 {
1291  struct bnx2 *bp = &bnx2;
1292  u32 rx_mode, sort_mode;
1293  int i;
1294 
1295  rx_mode = bp->rx_mode & ~(BNX2_EMAC_RX_MODE_PROMISCUOUS |
1297  sort_mode = 1 | BNX2_RPM_SORT_USER0_BC_EN;
1298 
1299  if (!(bp->flags & ASF_ENABLE_FLAG)) {
1301  }
1302 
1303  /* Accept all multicasts */
1304  for (i = 0; i < NUM_MC_HASH_REGISTERS; i++) {
1305  REG_WR(bp, BNX2_EMAC_MULTICAST_HASH0 + (i * 4),
1306  0xffffffff);
1307  }
1308  sort_mode |= BNX2_RPM_SORT_USER0_MC_EN;
1309 
1310  if (rx_mode != bp->rx_mode) {
1311  bp->rx_mode = rx_mode;
1313  }
1314 
1315  REG_WR(bp, BNX2_RPM_SORT_USER0, 0x0);
1316  REG_WR(bp, BNX2_RPM_SORT_USER0, sort_mode);
1318 }
#define BNX2_RPM_SORT_USER0_MC_EN
Definition: bnx2.h:2055
#define BNX2_EMAC_MULTICAST_HASH0
Definition: bnx2.h:1707
#define BNX2_EMAC_RX_MODE
Definition: bnx2.h:1688
#define REG_WR(bp, offset, val)
Definition: bnx2.h:4194
uint16_t bp
Definition: registers.h:23
#define BNX2_EMAC_RX_MODE_PROMISCUOUS
Definition: bnx2.h:1696
#define BNX2_RPM_SORT_USER0_BC_EN
Definition: bnx2.h:2054
#define ASF_ENABLE_FLAG
Definition: bnx2.h:4011
u32 rx_mode
Definition: bnx2.h:4140
#define NUM_MC_HASH_REGISTERS
Definition: bnx2.h:3812
Definition: bnx2.h:3991
#define BNX2_EMAC_RX_MODE_KEEP_VLAN_TAG
Definition: bnx2.h:1698
static struct bnx2 bnx2
Definition: bnx2.c:47
#define BNX2_RPM_SORT_USER0_ENA
Definition: bnx2.h:2060
#define BNX2_RPM_SORT_USER0
Definition: bnx2.h:2052
uint32_t u32
Definition: stdint.h:23

References ASF_ENABLE_FLAG, bnx2, BNX2_EMAC_MULTICAST_HASH0, BNX2_EMAC_RX_MODE, BNX2_EMAC_RX_MODE_KEEP_VLAN_TAG, BNX2_EMAC_RX_MODE_PROMISCUOUS, BNX2_RPM_SORT_USER0, BNX2_RPM_SORT_USER0_BC_EN, BNX2_RPM_SORT_USER0_ENA, BNX2_RPM_SORT_USER0_MC_EN, bp, NUM_MC_HASH_REGISTERS, REG_WR, and bnx2::rx_mode.

Referenced by bnx2_init_chip().

◆ load_rv2p_fw()

static void load_rv2p_fw ( struct bnx2 bp,
u32 rv2p_code,
u32  rv2p_code_len,
u32  rv2p_proc 
)
static

Definition at line 1321 of file bnx2.c.

1322 {
1323  unsigned int i;
1324  u32 val;
1325 
1326 
1327  for (i = 0; i < rv2p_code_len; i += 8) {
1328  REG_WR(bp, BNX2_RV2P_INSTR_HIGH, *rv2p_code);
1329  rv2p_code++;
1330  REG_WR(bp, BNX2_RV2P_INSTR_LOW, *rv2p_code);
1331  rv2p_code++;
1332 
1333  if (rv2p_proc == RV2P_PROC1) {
1334  val = (i / 8) | BNX2_RV2P_PROC1_ADDR_CMD_RDWR;
1336  }
1337  else {
1338  val = (i / 8) | BNX2_RV2P_PROC2_ADDR_CMD_RDWR;
1340  }
1341  }
1342 
1343  /* Reset the processor, un-stall is done later. */
1344  if (rv2p_proc == RV2P_PROC1) {
1346  }
1347  else {
1349  }
1350 }
#define BNX2_RV2P_PROC1_ADDR_CMD
Definition: bnx2.h:2505
#define BNX2_RV2P_PROC1_ADDR_CMD_RDWR
Definition: bnx2.h:2507
#define REG_WR(bp, offset, val)
Definition: bnx2.h:4194
uint16_t bp
Definition: registers.h:23
#define BNX2_RV2P_COMMAND_PROC2_RESET
Definition: bnx2.h:2447
#define BNX2_RV2P_PROC2_ADDR_CMD
Definition: bnx2.h:2509
#define BNX2_RV2P_INSTR_HIGH
Definition: bnx2.h:2501
#define BNX2_RV2P_PROC2_ADDR_CMD_RDWR
Definition: bnx2.h:2511
#define BNX2_RV2P_INSTR_LOW
Definition: bnx2.h:2504
#define RV2P_PROC1
Definition: bnx2.h:4270
#define BNX2_RV2P_COMMAND_PROC1_RESET
Definition: bnx2.h:2446
void __asmcall int val
Definition: setjmp.h:28
#define BNX2_RV2P_COMMAND
Definition: bnx2.h:2436
uint32_t u32
Definition: stdint.h:23

References BNX2_RV2P_COMMAND, BNX2_RV2P_COMMAND_PROC1_RESET, BNX2_RV2P_COMMAND_PROC2_RESET, BNX2_RV2P_INSTR_HIGH, BNX2_RV2P_INSTR_LOW, BNX2_RV2P_PROC1_ADDR_CMD, BNX2_RV2P_PROC1_ADDR_CMD_RDWR, BNX2_RV2P_PROC2_ADDR_CMD, BNX2_RV2P_PROC2_ADDR_CMD_RDWR, bp, REG_WR, RV2P_PROC1, and val.

Referenced by bnx2_init_cpus().

◆ load_cpu_fw()

static void load_cpu_fw ( struct bnx2 bp,
struct cpu_reg cpu_reg,
struct fw_info fw 
)
static

Definition at line 1353 of file bnx2.c.

1354 {
1355  u32 offset;
1356  u32 val;
1357 
1358  /* Halt the CPU. */
1359  val = REG_RD_IND(bp, cpu_reg->mode);
1363 
1364  /* Load the Text area. */
1366  if (fw->text) {
1367  unsigned int j;
1368 
1369  for (j = 0; j < (fw->text_len / 4); j++, offset += 4) {
1370  REG_WR_IND(bp, offset, fw->text[j]);
1371  }
1372  }
1373 
1374  /* Load the Data area. */
1376  if (fw->data) {
1377  unsigned int j;
1378 
1379  for (j = 0; j < (fw->data_len / 4); j++, offset += 4) {
1380  REG_WR_IND(bp, offset, fw->data[j]);
1381  }
1382  }
1383 
1384  /* Load the SBSS area. */
1386  if (fw->sbss) {
1387  unsigned int j;
1388 
1389  for (j = 0; j < (fw->sbss_len / 4); j++, offset += 4) {
1390  REG_WR_IND(bp, offset, fw->sbss[j]);
1391  }
1392  }
1393 
1394  /* Load the BSS area. */
1396  if (fw->bss) {
1397  unsigned int j;
1398 
1399  for (j = 0; j < (fw->bss_len/4); j++, offset += 4) {
1400  REG_WR_IND(bp, offset, fw->bss[j]);
1401  }
1402  }
1403 
1404  /* Load the Read-Only area. */
1405  offset = cpu_reg->spad_base +
1407  if (fw->rodata) {
1408  unsigned int j;
1409 
1410  for (j = 0; j < (fw->rodata_len / 4); j++, offset += 4) {
1411  REG_WR_IND(bp, offset, fw->rodata[j]);
1412  }
1413  }
1414 
1415  /* Clear the pre-fetch instruction. */
1416  REG_WR_IND(bp, cpu_reg->inst, 0);
1417  REG_WR_IND(bp, cpu_reg->pc, fw->start_addr);
1418 
1419  /* Start the CPU. */
1420  val = REG_RD_IND(bp, cpu_reg->mode);
1424 }
u32 * text
Definition: bnx2.h:4243
u32 data_addr
Definition: bnx2.h:4246
u32 sbss_addr
Definition: bnx2.h:4252
u32 sbss_len
Definition: bnx2.h:4253
u32 state_value_clear
Definition: bnx2.h:4219
u32 start_addr
Definition: bnx2.h:4237
Definition: bnx2.h:4213
u32 text_len
Definition: bnx2.h:4241
uint16_t bp
Definition: registers.h:23
u32 * rodata
Definition: bnx2.h:4267
u32 text_addr
Definition: bnx2.h:4240
u32 mode
Definition: bnx2.h:4214
#define REG_RD_IND(bp, offset)
Definition: bnx2.h:4200
static userptr_t size_t offset
Offset of the first segment within the content.
Definition: deflate.h:259
u32 inst
Definition: bnx2.h:4224
u32 pc
Definition: bnx2.h:4223
u32 bss_len
Definition: bnx2.h:4259
u32 * bss
Definition: bnx2.h:4261
u32 data_len
Definition: bnx2.h:4247
u32 state
Definition: bnx2.h:4218
void __asmcall int val
Definition: setjmp.h:28
u32 rodata_len
Definition: bnx2.h:4265
u32 rodata_addr
Definition: bnx2.h:4264
#define REG_WR_IND(bp, offset, val)
Definition: bnx2.h:4203
u32 spad_base
Definition: bnx2.h:4227
u32 * sbss
Definition: bnx2.h:4255
u32 * data
Definition: bnx2.h:4249
u32 mode_value_halt
Definition: bnx2.h:4215
u32 bss_addr
Definition: bnx2.h:4258
uint32_t u32
Definition: stdint.h:23
u32 mips_view_base
Definition: bnx2.h:4229

References bp, fw_info::bss, fw_info::bss_addr, fw_info::bss_len, fw_info::data, fw_info::data_addr, fw_info::data_len, cpu_reg::inst, cpu_reg::mips_view_base, cpu_reg::mode, cpu_reg::mode_value_halt, offset, cpu_reg::pc, REG_RD_IND, REG_WR_IND, fw_info::rodata, fw_info::rodata_addr, fw_info::rodata_len, fw_info::sbss, fw_info::sbss_addr, fw_info::sbss_len, cpu_reg::spad_base, fw_info::start_addr, cpu_reg::state, cpu_reg::state_value_clear, fw_info::text, fw_info::text_addr, fw_info::text_len, and val.

Referenced by bnx2_init_cpus().

◆ bnx2_init_cpus()

static void bnx2_init_cpus ( struct bnx2 bp)
static

Definition at line 1427 of file bnx2.c.

1428 {
1429  struct cpu_reg cpu_reg;
1430  struct fw_info fw;
1431 
1432  /* Unfortunately, it looks like we need to load the firmware
1433  * before the card will work properly. That means this driver
1434  * will be huge by Etherboot standards (approx. 50K compressed).
1435  */
1436 
1437  /* Initialize the RV2P processor. */
1440 
1441  /* Initialize the RX Processor. */
1446  cpu_reg.state_value_clear = 0xffffff;
1453  cpu_reg.mips_view_base = 0x8000000;
1454 
1455  fw.ver_major = bnx2_RXP_b06FwReleaseMajor;
1456  fw.ver_minor = bnx2_RXP_b06FwReleaseMinor;
1457  fw.ver_fix = bnx2_RXP_b06FwReleaseFix;
1458  fw.start_addr = bnx2_RXP_b06FwStartAddr;
1459 
1460  fw.text_addr = bnx2_RXP_b06FwTextAddr;
1461  fw.text_len = bnx2_RXP_b06FwTextLen;
1462  fw.text_index = 0;
1463  fw.text = bnx2_RXP_b06FwText;
1464 
1465  fw.data_addr = bnx2_RXP_b06FwDataAddr;
1466  fw.data_len = bnx2_RXP_b06FwDataLen;
1467  fw.data_index = 0;
1468  fw.data = bnx2_RXP_b06FwData;
1469 
1470  fw.sbss_addr = bnx2_RXP_b06FwSbssAddr;
1471  fw.sbss_len = bnx2_RXP_b06FwSbssLen;
1472  fw.sbss_index = 0;
1473  fw.sbss = bnx2_RXP_b06FwSbss;
1474 
1475  fw.bss_addr = bnx2_RXP_b06FwBssAddr;
1476  fw.bss_len = bnx2_RXP_b06FwBssLen;
1477  fw.bss_index = 0;
1478  fw.bss = bnx2_RXP_b06FwBss;
1479 
1480  fw.rodata_addr = bnx2_RXP_b06FwRodataAddr;
1481  fw.rodata_len = bnx2_RXP_b06FwRodataLen;
1482  fw.rodata_index = 0;
1483  fw.rodata = bnx2_RXP_b06FwRodata;
1484 
1485  load_cpu_fw(bp, &cpu_reg, &fw);
1486 
1487  /* Initialize the TX Processor. */
1492  cpu_reg.state_value_clear = 0xffffff;
1499  cpu_reg.mips_view_base = 0x8000000;
1500 
1501  fw.ver_major = bnx2_TXP_b06FwReleaseMajor;
1502  fw.ver_minor = bnx2_TXP_b06FwReleaseMinor;
1503  fw.ver_fix = bnx2_TXP_b06FwReleaseFix;
1504  fw.start_addr = bnx2_TXP_b06FwStartAddr;
1505 
1506  fw.text_addr = bnx2_TXP_b06FwTextAddr;
1507  fw.text_len = bnx2_TXP_b06FwTextLen;
1508  fw.text_index = 0;
1509  fw.text = bnx2_TXP_b06FwText;
1510 
1511  fw.data_addr = bnx2_TXP_b06FwDataAddr;
1512  fw.data_len = bnx2_TXP_b06FwDataLen;
1513  fw.data_index = 0;
1514  fw.data = bnx2_TXP_b06FwData;
1515 
1516  fw.sbss_addr = bnx2_TXP_b06FwSbssAddr;
1517  fw.sbss_len = bnx2_TXP_b06FwSbssLen;
1518  fw.sbss_index = 0;
1519  fw.sbss = bnx2_TXP_b06FwSbss;
1520 
1521  fw.bss_addr = bnx2_TXP_b06FwBssAddr;
1522  fw.bss_len = bnx2_TXP_b06FwBssLen;
1523  fw.bss_index = 0;
1524  fw.bss = bnx2_TXP_b06FwBss;
1525 
1526  fw.rodata_addr = bnx2_TXP_b06FwRodataAddr;
1527  fw.rodata_len = bnx2_TXP_b06FwRodataLen;
1528  fw.rodata_index = 0;
1529  fw.rodata = bnx2_TXP_b06FwRodata;
1530 
1531  load_cpu_fw(bp, &cpu_reg, &fw);
1532 
1533  /* Initialize the TX Patch-up Processor. */
1538  cpu_reg.state_value_clear = 0xffffff;
1545  cpu_reg.mips_view_base = 0x8000000;
1546 
1547  fw.ver_major = bnx2_TPAT_b06FwReleaseMajor;
1548  fw.ver_minor = bnx2_TPAT_b06FwReleaseMinor;
1549  fw.ver_fix = bnx2_TPAT_b06FwReleaseFix;
1550  fw.start_addr = bnx2_TPAT_b06FwStartAddr;
1551 
1552  fw.text_addr = bnx2_TPAT_b06FwTextAddr;
1553  fw.text_len = bnx2_TPAT_b06FwTextLen;
1554  fw.text_index = 0;
1555  fw.text = bnx2_TPAT_b06FwText;
1556 
1557  fw.data_addr = bnx2_TPAT_b06FwDataAddr;
1558  fw.data_len = bnx2_TPAT_b06FwDataLen;
1559  fw.data_index = 0;
1560  fw.data = bnx2_TPAT_b06FwData;
1561 
1562  fw.sbss_addr = bnx2_TPAT_b06FwSbssAddr;
1563  fw.sbss_len = bnx2_TPAT_b06FwSbssLen;
1564  fw.sbss_index = 0;
1565  fw.sbss = bnx2_TPAT_b06FwSbss;
1566 
1567  fw.bss_addr = bnx2_TPAT_b06FwBssAddr;
1568  fw.bss_len = bnx2_TPAT_b06FwBssLen;
1569  fw.bss_index = 0;
1570  fw.bss = bnx2_TPAT_b06FwBss;
1571 
1572  fw.rodata_addr = bnx2_TPAT_b06FwRodataAddr;
1573  fw.rodata_len = bnx2_TPAT_b06FwRodataLen;
1574  fw.rodata_index = 0;
1575  fw.rodata = bnx2_TPAT_b06FwRodata;
1576 
1577  load_cpu_fw(bp, &cpu_reg, &fw);
1578 
1579  /* Initialize the Completion Processor. */
1584  cpu_reg.state_value_clear = 0xffffff;
1591  cpu_reg.mips_view_base = 0x8000000;
1592 
1593  fw.ver_major = bnx2_COM_b06FwReleaseMajor;
1594  fw.ver_minor = bnx2_COM_b06FwReleaseMinor;
1595  fw.ver_fix = bnx2_COM_b06FwReleaseFix;
1596  fw.start_addr = bnx2_COM_b06FwStartAddr;
1597 
1598  fw.text_addr = bnx2_COM_b06FwTextAddr;
1599  fw.text_len = bnx2_COM_b06FwTextLen;
1600  fw.text_index = 0;
1601  fw.text = bnx2_COM_b06FwText;
1602 
1603  fw.data_addr = bnx2_COM_b06FwDataAddr;
1604  fw.data_len = bnx2_COM_b06FwDataLen;
1605  fw.data_index = 0;
1606  fw.data = bnx2_COM_b06FwData;
1607 
1608  fw.sbss_addr = bnx2_COM_b06FwSbssAddr;
1609  fw.sbss_len = bnx2_COM_b06FwSbssLen;
1610  fw.sbss_index = 0;
1611  fw.sbss = bnx2_COM_b06FwSbss;
1612 
1613  fw.bss_addr = bnx2_COM_b06FwBssAddr;
1614  fw.bss_len = bnx2_COM_b06FwBssLen;
1615  fw.bss_index = 0;
1616  fw.bss = bnx2_COM_b06FwBss;
1617 
1618  fw.rodata_addr = bnx2_COM_b06FwRodataAddr;
1619  fw.rodata_len = bnx2_COM_b06FwRodataLen;
1620  fw.rodata_index = 0;
1621  fw.rodata = bnx2_COM_b06FwRodata;
1622 
1623  load_cpu_fw(bp, &cpu_reg, &fw);
1624 
1625 }
static const u32 bnx2_COM_b06FwDataAddr
Definition: bnx2_fw.h:23
static const int bnx2_TXP_b06FwReleaseMajor
Definition: bnx2_fw.h:2543
#define BNX2_TPAT_CPU_PROGRAM_COUNTER
Definition: bnx2.h:3310
static u32 bnx2_RXP_b06FwSbssAddr
Definition: bnx2_fw.h:990
static const u32 bnx2_TPAT_b06FwTextAddr
Definition: bnx2_fw.h:2332
#define BNX2_RXP_CPU_MODE
Definition: bnx2.h:3363
static const int bnx2_TPAT_b06FwTextLen
Definition: bnx2_fw.h:2333
u32 state_value_clear
Definition: bnx2.h:4219
static const int bnx2_TXP_b06FwSbssLen
Definition: bnx2_fw.h:2556
#define BNX2_TPAT_CPU_MODE
Definition: bnx2.h:3268
#define BNX2_TPAT_CPU_INSTRUCTION
Definition: bnx2.h:3311
#define BNX2_COM_CPU_MODE_SOFT_HALT
Definition: bnx2.h:3486
#define BNX2_COM_CPU_MODE_STEP_ENA
Definition: bnx2.h:3481
static int bnx2_RXP_b06FwRodataLen
Definition: bnx2_fw.h:987
static u32 bnx2_COM_b06FwRodata[(0x58/4)+1]
Definition: bnx2_fw.h:970
static const int bnx2_COM_b06FwRodataLen
Definition: bnx2_fw.h:26
#define BNX2_RXP_CPU_INSTRUCTION
Definition: bnx2.h:3406
static const u32 bnx2_COM_b06FwRodataAddr
Definition: bnx2_fw.h:25
Definition: bnx2.h:4213
#define BNX2_TXP_CPU_REG_FILE
Definition: bnx2.h:3239
static int bnx2_RXP_b06FwTextLen
Definition: bnx2_fw.h:983
#define BNX2_TXP_CPU_MODE
Definition: bnx2.h:3173
static const int bnx2_COM_b06FwReleaseMajor
Definition: bnx2_fw.h:17
static const u32 bnx2_COM_b06FwStartAddr
Definition: bnx2_fw.h:20
static const int bnx2_TPAT_b06FwReleaseFix
Definition: bnx2_fw.h:2330
#define BNX2_RXP_CPU_EVENT_MASK
Definition: bnx2.h:3392
static const u32 bnx2_COM_b06FwBssAddr
Definition: bnx2_fw.h:27
uint16_t bp
Definition: registers.h:23
static u32 bnx2_TPAT_b06FwBss[(0x250/4)+1]
Definition: bnx2_fw.h:2540
static const u32 bnx2_COM_b06FwTextAddr
Definition: bnx2_fw.h:21
static const u32 bnx2_TXP_b06FwDataAddr
Definition: bnx2_fw.h:2549
static int bnx2_RXP_b06FwDataLen
Definition: bnx2_fw.h:985
#define BNX2_RXP_CPU_MODE_SOFT_HALT
Definition: bnx2.h:3370
#define BNX2_TPAT_CPU_HW_BREAKPOINT
Definition: bnx2.h:3316
static void load_cpu_fw(struct bnx2 *bp, struct cpu_reg *cpu_reg, struct fw_info *fw)
Definition: bnx2.c:1353
u32 mode
Definition: bnx2.h:4214
#define BNX2_TPAT_CPU_MODE_SOFT_HALT
Definition: bnx2.h:3275
static u32 bnx2_RXP_b06FwTextAddr
Definition: bnx2_fw.h:982
static const int bnx2_TPAT_b06FwSbssLen
Definition: bnx2_fw.h:2341
static const u32 bnx2_COM_b06FwSbssAddr
Definition: bnx2_fw.h:29
static u32 bnx2_TXP_b06FwRodata[(0x0/4)+1]
Definition: bnx2_fw.h:3492
#define BNX2_TXP_CPU_EVENT_MASK
Definition: bnx2.h:3202
static const int bnx2_COM_b06FwReleaseMinor
Definition: bnx2_fw.h:18
static const int bnx2_COM_b06FwBssLen
Definition: bnx2_fw.h:28
static u32 bnx2_TPAT_b06FwRodata[(0x0/4)+1]
Definition: bnx2_fw.h:2539
static u32 bnx2_TXP_b06FwSbss[(0x38/4)+1]
Definition: bnx2_fw.h:3494
static const u32 bnx2_TPAT_b06FwDataAddr
Definition: bnx2_fw.h:2334
static int bnx2_RXP_b06FwSbssLen
Definition: bnx2_fw.h:991
static const int bnx2_COM_b06FwTextLen
Definition: bnx2_fw.h:22
static const u32 bnx2_TPAT_b06FwBssAddr
Definition: bnx2_fw.h:2338
#define BNX2_TPAT_CPU_MODE_STEP_ENA
Definition: bnx2.h:3270
static u32 bnx2_TXP_b06FwBss[(0x1c4/4)+1]
Definition: bnx2_fw.h:3493
#define BNX2_TXP_CPU_INSTRUCTION
Definition: bnx2.h:3216
#define BNX2_RXP_SCRATCH
Definition: bnx2.h:3472
static u32 bnx2_TXP_b06FwText[(0x5748/4)+1]
Definition: bnx2_fw.h:2557
#define BNX2_COM_CPU_STATE
Definition: bnx2.h:3492
static u32 bnx2_RXP_b06FwRodataAddr
Definition: bnx2_fw.h:986
#define BNX2_COM_CPU_INSTRUCTION
Definition: bnx2.h:3522
u32 inst
Definition: bnx2.h:4224
u32 pc
Definition: bnx2.h:4223
static const int bnx2_TPAT_b06FwBssLen
Definition: bnx2_fw.h:2339
#define BNX2_RXP_CPU_PROGRAM_COUNTER
Definition: bnx2.h:3405
static const int bnx2_TPAT_b06FwReleaseMajor
Definition: bnx2_fw.h:2328
#define BNX2_TPAT_CPU_STATE
Definition: bnx2.h:3281
#define RV2P_PROC1
Definition: bnx2.h:4270
u32 evmask
Definition: bnx2.h:4222
#define BNX2_COM_CPU_REG_FILE
Definition: bnx2.h:3545
static const int bnx2_TXP_b06FwDataLen
Definition: bnx2_fw.h:2550
static u32 bnx2_COM_b06FwBss[(0x88/4)+1]
Definition: bnx2_fw.h:975
static u32 bnx2_TXP_b06FwData[(0x0/4)+1]
Definition: bnx2_fw.h:3491
static const int bnx2_TXP_b06FwRodataLen
Definition: bnx2_fw.h:2552
#define BNX2_TXP_CPU_HW_BREAKPOINT
Definition: bnx2.h:3221
#define BNX2_COM_SCRATCH
Definition: bnx2.h:3609
static u32 bnx2_RXP_b06FwSbss[(0x1c/4)+1]
Definition: bnx2_fw.h:1944
static const int bnx2_COM_b06FwDataLen
Definition: bnx2_fw.h:24
static int bnx2_RXP_b06FwReleaseMajor
Definition: bnx2_fw.h:978
#define BNX2_TXP_CPU_MODE_STEP_ENA
Definition: bnx2.h:3175
static const int bnx2_TPAT_b06FwRodataLen
Definition: bnx2_fw.h:2337
Definition: bnx2.h:4232
#define BNX2_TPAT_CPU_EVENT_MASK
Definition: bnx2.h:3297
static const u32 bnx2_TXP_b06FwRodataAddr
Definition: bnx2_fw.h:2551
#define BNX2_TXP_CPU_PROGRAM_COUNTER
Definition: bnx2.h:3215
u32 gpr0
Definition: bnx2.h:4221
static u32 bnx2_RXP_b06FwRodata[(0x28/4)+1]
Definition: bnx2_fw.h:1940
static u32 bnx2_RXP_b06FwBssAddr
Definition: bnx2_fw.h:988
static u32 bnx2_COM_b06FwSbss[(0x1c/4)+1]
Definition: bnx2_fw.h:976
static const u32 bnx2_TXP_b06FwBssAddr
Definition: bnx2_fw.h:2553
static u32 bnx2_rv2p_proc1[]
Definition: bnx2_fw.h:1946
static const int bnx2_COM_b06FwReleaseFix
Definition: bnx2_fw.h:19
u32 state
Definition: bnx2.h:4218
static const int bnx2_TPAT_b06FwReleaseMinor
Definition: bnx2_fw.h:2329
static void load_rv2p_fw(struct bnx2 *bp, u32 *rv2p_code, u32 rv2p_code_len, u32 rv2p_proc)
Definition: bnx2.c:1321
static const int bnx2_COM_b06FwSbssLen
Definition: bnx2_fw.h:30
static u32 bnx2_RXP_b06FwStartAddr
Definition: bnx2_fw.h:981
static u32 bnx2_rv2p_proc2[]
Definition: bnx2_fw.h:2071
#define BNX2_TXP_SCRATCH
Definition: bnx2.h:3261
static u32 bnx2_COM_b06FwText[(0x57bc/4)+1]
Definition: bnx2_fw.h:31
#define BNX2_TPAT_CPU_REG_FILE
Definition: bnx2.h:3334
u32 mode_value_sstep
Definition: bnx2.h:4216
#define BNX2_RXP_CPU_HW_BREAKPOINT
Definition: bnx2.h:3411
#define RV2P_PROC2
Definition: bnx2.h:4271
#define BNX2_TXP_CPU_STATE
Definition: bnx2.h:3186
static u32 bnx2_RXP_b06FwData[(0x0/4)+1]
Definition: bnx2_fw.h:1939
#define BNX2_TPAT_SCRATCH
Definition: bnx2.h:3356
static const int bnx2_TXP_b06FwReleaseFix
Definition: bnx2_fw.h:2545
static u32 bnx2_RXP_b06FwBss[(0x13a4/4)+1]
Definition: bnx2_fw.h:1943
u32 bp
Definition: bnx2.h:4225
static const u32 bnx2_TXP_b06FwSbssAddr
Definition: bnx2_fw.h:2555
#define BNX2_COM_CPU_MODE
Definition: bnx2.h:3479
static u32 bnx2_TPAT_b06FwText[(0x122c/4)+1]
Definition: bnx2_fw.h:2342
static const int bnx2_TXP_b06FwReleaseMinor
Definition: bnx2_fw.h:2544
u32 spad_base
Definition: bnx2.h:4227
#define BNX2_COM_CPU_EVENT_MASK
Definition: bnx2.h:3508
static const int bnx2_TXP_b06FwBssLen
Definition: bnx2_fw.h:2554
#define BNX2_RXP_CPU_STATE
Definition: bnx2.h:3376
static u32 bnx2_RXP_b06FwDataAddr
Definition: bnx2_fw.h:984
static int bnx2_RXP_b06FwReleaseMinor
Definition: bnx2_fw.h:979
static const u32 bnx2_TPAT_b06FwStartAddr
Definition: bnx2_fw.h:2331
#define BNX2_RXP_CPU_REG_FILE
Definition: bnx2.h:3429
u32 mode_value_halt
Definition: bnx2.h:4215
static const int bnx2_TXP_b06FwTextLen
Definition: bnx2_fw.h:2548
static const u32 bnx2_TPAT_b06FwRodataAddr
Definition: bnx2_fw.h:2336
static const u32 bnx2_TPAT_b06FwSbssAddr
Definition: bnx2_fw.h:2340
#define BNX2_COM_CPU_HW_BREAKPOINT
Definition: bnx2.h:3527
static int bnx2_RXP_b06FwReleaseFix
Definition: bnx2_fw.h:980
static u32 bnx2_TPAT_b06FwData[(0x0/4)+1]
Definition: bnx2_fw.h:2538
#define BNX2_RXP_CPU_MODE_STEP_ENA
Definition: bnx2.h:3365
#define BNX2_TXP_CPU_MODE_SOFT_HALT
Definition: bnx2.h:3180
static u32 bnx2_RXP_b06FwText[(0x588c/4)+1]
Definition: bnx2_fw.h:992
static int bnx2_RXP_b06FwBssLen
Definition: bnx2_fw.h:989
static const int bnx2_TPAT_b06FwDataLen
Definition: bnx2_fw.h:2335
u32 mips_view_base
Definition: bnx2.h:4229
static u32 bnx2_COM_b06FwData[(0x0/4)+1]
Definition: bnx2_fw.h:969
static u32 bnx2_TPAT_b06FwSbss[(0x34/4)+1]
Definition: bnx2_fw.h:2541
static const u32 bnx2_TXP_b06FwStartAddr
Definition: bnx2_fw.h:2546
static const u32 bnx2_TXP_b06FwTextAddr
Definition: bnx2_fw.h:2547
#define BNX2_COM_CPU_PROGRAM_COUNTER
Definition: bnx2.h:3521

References bnx2_COM_b06FwBss, bnx2_COM_b06FwBssAddr, bnx2_COM_b06FwBssLen, bnx2_COM_b06FwData, bnx2_COM_b06FwDataAddr, bnx2_COM_b06FwDataLen, bnx2_COM_b06FwReleaseFix, bnx2_COM_b06FwReleaseMajor, bnx2_COM_b06FwReleaseMinor, bnx2_COM_b06FwRodata, bnx2_COM_b06FwRodataAddr, bnx2_COM_b06FwRodataLen, bnx2_COM_b06FwSbss, bnx2_COM_b06FwSbssAddr, bnx2_COM_b06FwSbssLen, bnx2_COM_b06FwStartAddr, bnx2_COM_b06FwText, bnx2_COM_b06FwTextAddr, bnx2_COM_b06FwTextLen, BNX2_COM_CPU_EVENT_MASK, BNX2_COM_CPU_HW_BREAKPOINT, BNX2_COM_CPU_INSTRUCTION, BNX2_COM_CPU_MODE, BNX2_COM_CPU_MODE_SOFT_HALT, BNX2_COM_CPU_MODE_STEP_ENA, BNX2_COM_CPU_PROGRAM_COUNTER, BNX2_COM_CPU_REG_FILE, BNX2_COM_CPU_STATE, BNX2_COM_SCRATCH, bnx2_rv2p_proc1, bnx2_rv2p_proc2, bnx2_RXP_b06FwBss, bnx2_RXP_b06FwBssAddr, bnx2_RXP_b06FwBssLen, bnx2_RXP_b06FwData, bnx2_RXP_b06FwDataAddr, bnx2_RXP_b06FwDataLen, bnx2_RXP_b06FwReleaseFix, bnx2_RXP_b06FwReleaseMajor, bnx2_RXP_b06FwReleaseMinor, bnx2_RXP_b06FwRodata, bnx2_RXP_b06FwRodataAddr, bnx2_RXP_b06FwRodataLen, bnx2_RXP_b06FwSbss, bnx2_RXP_b06FwSbssAddr, bnx2_RXP_b06FwSbssLen, bnx2_RXP_b06FwStartAddr, bnx2_RXP_b06FwText, bnx2_RXP_b06FwTextAddr, bnx2_RXP_b06FwTextLen, BNX2_RXP_CPU_EVENT_MASK, BNX2_RXP_CPU_HW_BREAKPOINT, BNX2_RXP_CPU_INSTRUCTION, BNX2_RXP_CPU_MODE, BNX2_RXP_CPU_MODE_SOFT_HALT, BNX2_RXP_CPU_MODE_STEP_ENA, BNX2_RXP_CPU_PROGRAM_COUNTER, BNX2_RXP_CPU_REG_FILE, BNX2_RXP_CPU_STATE, BNX2_RXP_SCRATCH, bnx2_TPAT_b06FwBss, bnx2_TPAT_b06FwBssAddr, bnx2_TPAT_b06FwBssLen, bnx2_TPAT_b06FwData, bnx2_TPAT_b06FwDataAddr, bnx2_TPAT_b06FwDataLen, bnx2_TPAT_b06FwReleaseFix, bnx2_TPAT_b06FwReleaseMajor, bnx2_TPAT_b06FwReleaseMinor, bnx2_TPAT_b06FwRodata, bnx2_TPAT_b06FwRodataAddr, bnx2_TPAT_b06FwRodataLen, bnx2_TPAT_b06FwSbss, bnx2_TPAT_b06FwSbssAddr, bnx2_TPAT_b06FwSbssLen, bnx2_TPAT_b06FwStartAddr, bnx2_TPAT_b06FwText, bnx2_TPAT_b06FwTextAddr, bnx2_TPAT_b06FwTextLen, BNX2_TPAT_CPU_EVENT_MASK, BNX2_TPAT_CPU_HW_BREAKPOINT, BNX2_TPAT_CPU_INSTRUCTION, BNX2_TPAT_CPU_MODE, BNX2_TPAT_CPU_MODE_SOFT_HALT, BNX2_TPAT_CPU_MODE_STEP_ENA, BNX2_TPAT_CPU_PROGRAM_COUNTER, BNX2_TPAT_CPU_REG_FILE, BNX2_TPAT_CPU_STATE, BNX2_TPAT_SCRATCH, bnx2_TXP_b06FwBss, bnx2_TXP_b06FwBssAddr, bnx2_TXP_b06FwBssLen, bnx2_TXP_b06FwData, bnx2_TXP_b06FwDataAddr, bnx2_TXP_b06FwDataLen, bnx2_TXP_b06FwReleaseFix, bnx2_TXP_b06FwReleaseMajor, bnx2_TXP_b06FwReleaseMinor, bnx2_TXP_b06FwRodata, bnx2_TXP_b06FwRodataAddr, bnx2_TXP_b06FwRodataLen, bnx2_TXP_b06FwSbss, bnx2_TXP_b06FwSbssAddr, bnx2_TXP_b06FwSbssLen, bnx2_TXP_b06FwStartAddr, bnx2_TXP_b06FwText, bnx2_TXP_b06FwTextAddr, bnx2_TXP_b06FwTextLen, BNX2_TXP_CPU_EVENT_MASK, BNX2_TXP_CPU_HW_BREAKPOINT, BNX2_TXP_CPU_INSTRUCTION, BNX2_TXP_CPU_MODE, BNX2_TXP_CPU_MODE_SOFT_HALT, BNX2_TXP_CPU_MODE_STEP_ENA, BNX2_TXP_CPU_PROGRAM_COUNTER, BNX2_TXP_CPU_REG_FILE, BNX2_TXP_CPU_STATE, BNX2_TXP_SCRATCH, bp, cpu_reg::bp, fw_info::bss, fw_info::bss_addr, fw_info::bss_index, fw_info::bss_len, fw_info::data, fw_info::data_addr, fw_info::data_index, fw_info::data_len, cpu_reg::evmask, cpu_reg::gpr0, cpu_reg::inst, load_cpu_fw(), load_rv2p_fw(), cpu_reg::mips_view_base, cpu_reg::mode, cpu_reg::mode_value_halt, cpu_reg::mode_value_sstep, cpu_reg::pc, fw_info::rodata, fw_info::rodata_addr, fw_info::rodata_index, fw_info::rodata_len, RV2P_PROC1, RV2P_PROC2, fw_info::sbss, fw_info::sbss_addr, fw_info::sbss_index, fw_info::sbss_len, cpu_reg::spad_base, fw_info::start_addr, cpu_reg::state, cpu_reg::state_value_clear, fw_info::text, fw_info::text_addr, fw_info::text_index, fw_info::text_len, fw_info::ver_fix, fw_info::ver_major, and fw_info::ver_minor.

Referenced by bnx2_init_chip().

◆ bnx2_set_power_state_0()

static int bnx2_set_power_state_0 ( struct bnx2 bp)
static

Definition at line 1628 of file bnx2.c.

1629 {
1630  u16 pmcsr;
1631  u32 val;
1632 
1633  pci_read_config_word(bp->pdev, bp->pm_cap + PCI_PM_CTRL, &pmcsr);
1634 
1635  pci_write_config_word(bp->pdev, bp->pm_cap + PCI_PM_CTRL,
1636  (pmcsr & ~PCI_PM_CTRL_STATE_MASK) |
1638 
1639  if (pmcsr & PCI_PM_CTRL_STATE_MASK)
1640  /* delay required during transition out of D3hot */
1641  mdelay(20);
1642 
1647 
1651 
1652  return 0;
1653 }
uint16_t u16
Definition: stdint.h:21
#define BNX2_EMAC_MODE_MPKT
Definition: bnx2.h:1544
#define BNX2_RPM_CONFIG
Definition: bnx2.h:2032
#define PCI_PM_CTRL_PME_STATUS
PME pin status.
Definition: pci.h:108
int pci_write_config_word(struct pci_device *pci, unsigned int where, uint16_t value)
Write 16-bit word to PCI configuration space.
#define REG_WR(bp, offset, val)
Definition: bnx2.h:4194
uint16_t bp
Definition: registers.h:23
int pci_read_config_word(struct pci_device *pci, unsigned int where, uint16_t *value)
Read 16-bit word from PCI configuration space.
#define PCI_PM_CTRL_STATE_MASK
Current power state.
Definition: pci.h:106
#define PCI_PM_CTRL
Power management control and status.
Definition: pci.h:105
#define REG_RD(bp, offset)
Definition: bnx2.h:4191
#define BNX2_EMAC_MODE_ACPI_RCVD
Definition: bnx2.h:1546
void __asmcall int val
Definition: setjmp.h:28
#define BNX2_RPM_CONFIG_ACPI_ENA
Definition: bnx2.h:2034
#define BNX2_EMAC_MODE
Definition: bnx2.h:1529
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition: timer.c:78
#define BNX2_EMAC_MODE_MPKT_RCVD
Definition: bnx2.h:1545
uint32_t u32
Definition: stdint.h:23

References BNX2_EMAC_MODE, BNX2_EMAC_MODE_ACPI_RCVD, BNX2_EMAC_MODE_MPKT, BNX2_EMAC_MODE_MPKT_RCVD, BNX2_RPM_CONFIG, BNX2_RPM_CONFIG_ACPI_ENA, bp, mdelay(), PCI_PM_CTRL, PCI_PM_CTRL_PME_STATUS, PCI_PM_CTRL_STATE_MASK, pci_read_config_word(), pci_write_config_word(), REG_RD, REG_WR, and val.

Referenced by bnx2_init_board(), and bnx2_probe().

◆ bnx2_enable_nvram_access()

static void bnx2_enable_nvram_access ( struct bnx2 bp)
static

Definition at line 1656 of file bnx2.c.

1657 {
1658  u32 val;
1659 
1661  /* Enable both bits, even on read. */
1664 }
#define BNX2_NVM_ACCESS_ENABLE_EN
Definition: bnx2.h:1240
#define REG_WR(bp, offset, val)
Definition: bnx2.h:4194
#define BNX2_NVM_ACCESS_ENABLE
Definition: bnx2.h:1239
uint16_t bp
Definition: registers.h:23
#define BNX2_NVM_ACCESS_ENABLE_WR_EN
Definition: bnx2.h:1241
#define REG_RD(bp, offset)
Definition: bnx2.h:4191
void __asmcall int val
Definition: setjmp.h:28
uint32_t u32
Definition: stdint.h:23

References BNX2_NVM_ACCESS_ENABLE, BNX2_NVM_ACCESS_ENABLE_EN, BNX2_NVM_ACCESS_ENABLE_WR_EN, bp, REG_RD, REG_WR, and val.

Referenced by bnx2_init_nvram().

◆ bnx2_disable_nvram_access()

static void bnx2_disable_nvram_access ( struct bnx2 bp)
static

Definition at line 1667 of file bnx2.c.

1668 {
1669  u32 val;
1670 
1672  /* Disable both bits, even after read. */
1676 }
#define BNX2_NVM_ACCESS_ENABLE_EN
Definition: bnx2.h:1240
#define REG_WR(bp, offset, val)
Definition: bnx2.h:4194
#define BNX2_NVM_ACCESS_ENABLE
Definition: bnx2.h:1239
uint16_t bp
Definition: registers.h:23
#define BNX2_NVM_ACCESS_ENABLE_WR_EN
Definition: bnx2.h:1241
#define REG_RD(bp, offset)
Definition: bnx2.h:4191
void __asmcall int val
Definition: setjmp.h:28
uint32_t u32
Definition: stdint.h:23

References BNX2_NVM_ACCESS_ENABLE, BNX2_NVM_ACCESS_ENABLE_EN, BNX2_NVM_ACCESS_ENABLE_WR_EN, bp, REG_RD, REG_WR, and val.

Referenced by bnx2_init_nvram().

◆ bnx2_init_nvram()

static int bnx2_init_nvram ( struct bnx2 bp)
static

Definition at line 1679 of file bnx2.c.

1680 {
1681  u32 val;
1682  int j, entry_count, rc;
1683  struct flash_spec *flash;
1684 
1685  /* Determine the selected interface. */
1686  val = REG_RD(bp, BNX2_NVM_CFG1);
1687 
1688  entry_count = sizeof(flash_table) / sizeof(struct flash_spec);
1689 
1690  rc = 0;
1691  if (val & 0x40000000) {
1692  /* Flash interface has been reconfigured */
1693  for (j = 0, flash = &flash_table[0]; j < entry_count;
1694  j++, flash++) {
1695  if ((val & FLASH_BACKUP_STRAP_MASK) ==
1696  (flash->config1 & FLASH_BACKUP_STRAP_MASK)) {
1697  bp->flash_info = flash;
1698  break;
1699  }
1700  }
1701  }
1702  else {
1703  u32 mask;
1704  /* Not yet been reconfigured */
1705 
1706  if (val & (1 << 23))
1707  mask = FLASH_BACKUP_STRAP_MASK;
1708  else
1709  mask = FLASH_STRAP_MASK;
1710 
1711  for (j = 0, flash = &flash_table[0]; j < entry_count;
1712  j++, flash++) {
1713 
1714  if ((val & mask) == (flash->strapping & mask)) {
1715  bp->flash_info = flash;
1716 
1717  /* Enable access to flash interface */
1719 
1720  /* Reconfigure the flash interface */
1721  REG_WR(bp, BNX2_NVM_CFG1, flash->config1);
1722  REG_WR(bp, BNX2_NVM_CFG2, flash->config2);
1723  REG_WR(bp, BNX2_NVM_CFG3, flash->config3);
1724  REG_WR(bp, BNX2_NVM_WRITE1, flash->write1);
1725 
1726  /* Disable access to flash interface */
1728 
1729  break;
1730  }
1731  }
1732  } /* if (val & 0x40000000) */
1733 
1734  if (j == entry_count) {
1735  bp->flash_info = NULL;
1736  printf("Unknown flash/EEPROM type.\n");
1737  return -ENODEV;
1738  }
1739 
1740  val = REG_RD_IND(bp, bp->shmem_base + BNX2_SHARED_HW_CFG_CONFIG2);
1742  if (val) {
1743  bp->flash_size = val;
1744  }
1745  else {
1746  bp->flash_size = bp->flash_info->total_size;
1747  }
1748 
1749  return rc;
1750 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
int printf(const char *fmt,...)
Write a formatted string to the console.
Definition: vsprintf.c:464
#define REG_WR(bp, offset, val)
Definition: bnx2.h:4194
uint16_t bp
Definition: registers.h:23
#define BNX2_NVM_CFG1
Definition: bnx2.h:1196
#define BNX2_NVM_CFG2
Definition: bnx2.h:1210
#define BNX2_SHARED_HW_CFG2_NVM_SIZE_MASK
Definition: bnx2.h:4388
#define REG_RD_IND(bp, offset)
Definition: bnx2.h:4200
static void bnx2_enable_nvram_access(struct bnx2 *bp)
Definition: bnx2.c:1656
#define BNX2_NVM_WRITE1
Definition: bnx2.h:1243
static void bnx2_disable_nvram_access(struct bnx2 *bp)
Definition: bnx2.c:1667
#define FLASH_BACKUP_STRAP_MASK
Definition: bnx2.h:3975
#define REG_RD(bp, offset)
Definition: bnx2.h:4191
#define BNX2_NVM_CFG3
Definition: bnx2.h:1215
#define ENODEV
No such device.
Definition: errno.h:509
void __asmcall int val
Definition: setjmp.h:28
#define BNX2_SHARED_HW_CFG_CONFIG2
Definition: bnx2.h:4387
int flash(void)
static struct flash_spec flash_table[]
Definition: bnx2.c:49
#define FLASH_STRAP_MASK
Definition: bnx2.h:3970
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
uint32_t u32
Definition: stdint.h:23

References bnx2_disable_nvram_access(), bnx2_enable_nvram_access(), BNX2_NVM_CFG1, BNX2_NVM_CFG2, BNX2_NVM_CFG3, BNX2_NVM_WRITE1, BNX2_SHARED_HW_CFG2_NVM_SIZE_MASK, BNX2_SHARED_HW_CFG_CONFIG2, bp, ENODEV, flash(), FLASH_BACKUP_STRAP_MASK, FLASH_STRAP_MASK, flash_table, NULL, printf(), rc, REG_RD, REG_RD_IND, REG_WR, and val.

Referenced by bnx2_init_board(), and bnx2_init_chip().

◆ bnx2_reset_chip()

static int bnx2_reset_chip ( struct bnx2 bp,
u32  reset_code 
)
static

Definition at line 1753 of file bnx2.c.

1754 {
1755  u32 val;
1756  int i, rc = 0;
1757 
1758  /* Wait for the current PCI transaction to complete before
1759  * issuing a reset. */
1766  udelay(5);
1767 
1768 
1769  /* Wait for the firmware to tell us it is ok to issue a reset. */
1770  bnx2_fw_sync(bp, BNX2_DRV_MSG_DATA_WAIT0 | reset_code, 1);
1771 
1772  /* Deposit a driver reset signature so the firmware knows that
1773  * this is a soft reset. */
1774  REG_WR_IND(bp, bp->shmem_base + BNX2_DRV_RESET_SIGNATURE,
1776 
1777  /* Do a dummy read to force the chip to complete all current transaction
1778  * before we issue a reset. */
1779  val = REG_RD(bp, BNX2_MISC_ID);
1780 
1784 
1785  /* Chip reset. */
1787 
1788  if ((CHIP_ID(bp) == CHIP_ID_5706_A0) ||
1789  (CHIP_ID(bp) == CHIP_ID_5706_A1))
1790  mdelay(15);
1791 
1792  /* Reset takes approximate 30 usec */
1793  for (i = 0; i < 10; i++) {
1797  break;
1798  }
1799  udelay(10);
1800  }
1801 
1804  printf("Chip reset did not complete\n");
1805  return -EBUSY;
1806  }
1807 
1808  /* Make sure byte swapping is properly configured. */
1810  if (val != 0x01020304) {
1811  printf("Chip not in correct endian mode\n");
1812  return -ENODEV;
1813  }
1814 
1815  /* Wait for the firmware to finish its initialization. */
1816  rc = bnx2_fw_sync(bp, BNX2_DRV_MSG_DATA_WAIT1 | reset_code, 0);
1817  if (rc) {
1818  return rc;
1819  }
1820 
1821  if (CHIP_ID(bp) == CHIP_ID_5706_A0) {
1822  /* Adjust the voltage regular to two steps lower. The default
1823  * of this register is 0x0000000e. */
1824  REG_WR(bp, BNX2_MISC_VREG_CONTROL, 0x000000fa);
1825 
1826  /* Remove bad rbuf memory from the free pool. */
1828  }
1829 
1830  return rc;
1831 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
int printf(const char *fmt,...)
Write a formatted string to the console.
Definition: vsprintf.c:464
#define BNX2_PCICFG_MISC_CONFIG_REG_WINDOW_ENA
Definition: bnx2.h:459
#define BNX2_PCICFG_MISC_CONFIG_TARGET_MB_WORD_SWAP
Definition: bnx2.h:456
#define EBUSY
Device or resource busy.
Definition: errno.h:338
#define BNX2_DRV_MSG_DATA_WAIT0
Definition: bnx2.h:4303
#define BNX2_DRV_MSG_DATA_WAIT1
Definition: bnx2.h:4304
#define REG_WR(bp, offset, val)
Definition: bnx2.h:4194
uint16_t bp
Definition: registers.h:23
#define BNX2_PCICFG_MISC_CONFIG
Definition: bnx2.h:454
#define CHIP_ID_5706_A0
Definition: bnx2.h:4084
static int bnx2_alloc_bad_rbuf(struct bnx2 *bp)
Definition: bnx2.c:1230
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
#define BNX2_MISC_ENABLE_CLR_BITS_DMA_ENGINE_ENABLE
Definition: bnx2.h:826
#define BNX2_MISC_ENABLE_CLR_BITS
Definition: bnx2.h:799
#define REG_RD(bp, offset)
Definition: bnx2.h:4191
#define BNX2_DRV_RESET_SIGNATURE
Definition: bnx2.h:4287
static int bnx2_fw_sync(struct bnx2 *bp, u32 msg_data, int silent)
Definition: bnx2.c:1147
#define ENODEV
No such device.
Definition: errno.h:509
#define BNX2_PCICFG_MISC_CONFIG_CORE_RST_BSY
Definition: bnx2.h:461
#define BNX2_PCICFG_MISC_CONFIG_CORE_RST_REQ
Definition: bnx2.h:460
void __asmcall int val
Definition: setjmp.h:28
#define BNX2_MISC_ENABLE_CLR_BITS_HOST_COALESCE_ENABLE
Definition: bnx2.h:819
#define BNX2_MISC_ENABLE_CLR_BITS_TX_DMA_ENABLE
Definition: bnx2.h:804
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition: timer.c:78
#define BNX2_DRV_RESET_SIGNATURE_MAGIC
Definition: bnx2.h:4288
#define REG_WR_IND(bp, offset, val)
Definition: bnx2.h:4203
#define BNX2_MISC_VREG_CONTROL
Definition: bnx2.h:1134
#define CHIP_ID_5706_A1
Definition: bnx2.h:4085
#define CHIP_ID(bp)
Definition: bnx2.h:4083
#define BNX2_MISC_ENABLE_CLR_BITS_RX_DMA_ENABLE
Definition: bnx2.h:817
#define BNX2_MISC_ID
Definition: bnx2.h:733
uint32_t u32
Definition: stdint.h:23
#define BNX2_PCI_SWAP_DIAG0
Definition: bnx2.h:619

References bnx2_alloc_bad_rbuf(), BNX2_DRV_MSG_DATA_WAIT0, BNX2_DRV_MSG_DATA_WAIT1, BNX2_DRV_RESET_SIGNATURE, BNX2_DRV_RESET_SIGNATURE_MAGIC, bnx2_fw_sync(), BNX2_MISC_ENABLE_CLR_BITS, BNX2_MISC_ENABLE_CLR_BITS_DMA_ENGINE_ENABLE, BNX2_MISC_ENABLE_CLR_BITS_HOST_COALESCE_ENABLE, BNX2_MISC_ENABLE_CLR_BITS_RX_DMA_ENABLE, BNX2_MISC_ENABLE_CLR_BITS_TX_DMA_ENABLE, BNX2_MISC_ID, BNX2_MISC_VREG_CONTROL, BNX2_PCI_SWAP_DIAG0, BNX2_PCICFG_MISC_CONFIG, BNX2_PCICFG_MISC_CONFIG_CORE_RST_BSY, BNX2_PCICFG_MISC_CONFIG_CORE_RST_REQ, BNX2_PCICFG_MISC_CONFIG_REG_WINDOW_ENA, BNX2_PCICFG_MISC_CONFIG_TARGET_MB_WORD_SWAP, bp, CHIP_ID, CHIP_ID_5706_A0, CHIP_ID_5706_A1, EBUSY, ENODEV, mdelay(), printf(), rc, REG_RD, REG_WR, REG_WR_IND, udelay(), and val.

Referenced by bnx2_disable(), and bnx2_reset_nic().

◆ bnx2_disable()

static void bnx2_disable ( struct nic *nic  __unused)
static

Definition at line 1834 of file bnx2.c.

1835 {
1836  struct bnx2* bp = &bnx2;
1837 
1838  if (bp->regview) {
1840  iounmap(bp->regview);
1841  }
1842 }
static int bnx2_reset_chip(struct bnx2 *bp, u32 reset_code)
Definition: bnx2.c:1753
uint16_t bp
Definition: registers.h:23
Definition: bnx2.h:3991
#define BNX2_DRV_MSG_CODE_UNLOAD
Definition: bnx2.h:4294
static struct bnx2 bnx2
Definition: bnx2.c:47
void iounmap(volatile const void *io_addr)
Unmap I/O address.

References bnx2, BNX2_DRV_MSG_CODE_UNLOAD, bnx2_reset_chip(), bp, and iounmap().

Referenced by bnx2_init_board(), bnx2_probe(), and bnx2_transmit().

◆ bnx2_init_chip()

static int bnx2_init_chip ( struct bnx2 bp)
static

Definition at line 1845 of file bnx2.c.

1846 {
1847  u32 val;
1848  int rc;
1849 
1850  /* Make sure the interrupt is not active. */
1852 
1855 #if __BYTE_ORDER == __BIG_ENDIAN
1857 #endif
1859  DMA_READ_CHANS << 12 |
1860  DMA_WRITE_CHANS << 16;
1861 
1862  val |= (0x2 << 20) | (1 << 11);
1863 
1864  if ((bp->flags & PCIX_FLAG) && (bp->bus_speed_mhz == 133))
1865  val |= (1 << 23);
1866 
1867  if ((CHIP_NUM(bp) == CHIP_NUM_5706) &&
1868  (CHIP_ID(bp) != CHIP_ID_5706_A0) && !(bp->flags & PCIX_FLAG))
1870 
1872 
1873  if (CHIP_ID(bp) == CHIP_ID_5706_A0) {
1877  }
1878 
1879  if (bp->flags & PCIX_FLAG) {
1880  u16 val16;
1881 
1882  pci_read_config_word(bp->pdev, bp->pcix_cap + PCI_X_CMD,
1883  &val16);
1884  pci_write_config_word(bp->pdev, bp->pcix_cap + PCI_X_CMD,
1885  val16 & ~PCI_X_CMD_ERO);
1886  }
1887 
1892 
1893  /* Initialize context mapping and zero out the quick contexts. The
1894  * context block must have already been enabled. */
1896 
1898  bnx2_init_cpus(bp);
1899 
1901 
1906 
1907  val = 0x10000 + (MAX_CID_CNT * MB_KERNEL_CTX_SIZE);
1910 
1911  val = (BCM_PAGE_BITS - 8) << 24;
1913 
1914  /* Configure page size. */
1917  val |= (BCM_PAGE_BITS - 8) << 24 | 0x40;
1919 
1920  val = bp->mac_addr[0] +
1921  (bp->mac_addr[1] << 8) +
1922  (bp->mac_addr[2] << 16) +
1923  bp->mac_addr[3] +
1924  (bp->mac_addr[4] << 8) +
1925  (bp->mac_addr[5] << 16);
1927 
1928  /* Program the MTU. Also include 4 bytes for CRC32. */
1929  val = ETH_MAX_MTU + ETH_HLEN + 4;
1930  if (val > (MAX_ETHERNET_PACKET_SIZE + 4))
1933 
1934  bp->last_status_idx = 0;
1935  bp->rx_mode = BNX2_EMAC_RX_MODE_SORT_MODE;
1936 
1937  /* Set up how to generate a link change interrupt. */
1939 
1941  (u64) bp->status_blk_mapping & 0xffffffff);
1942  REG_WR(bp, BNX2_HC_STATUS_ADDR_H, (u64) bp->status_blk_mapping >> 32);
1943 
1945  (u64) bp->stats_blk_mapping & 0xffffffff);
1947  (u64) bp->stats_blk_mapping >> 32);
1948 
1950  (bp->tx_quick_cons_trip_int << 16) | bp->tx_quick_cons_trip);
1951 
1953  (bp->rx_quick_cons_trip_int << 16) | bp->rx_quick_cons_trip);
1954 
1956  (bp->comp_prod_trip_int << 16) | bp->comp_prod_trip);
1957 
1958  REG_WR(bp, BNX2_HC_TX_TICKS, (bp->tx_ticks_int << 16) | bp->tx_ticks);
1959 
1960  REG_WR(bp, BNX2_HC_RX_TICKS, (bp->rx_ticks_int << 16) | bp->rx_ticks);
1961 
1963  (bp->com_ticks_int << 16) | bp->com_ticks);
1964 
1966  (bp->cmd_ticks_int << 16) | bp->cmd_ticks);
1967 
1968  REG_WR(bp, BNX2_HC_STATS_TICKS, bp->stats_ticks & 0xffff00);
1969  REG_WR(bp, BNX2_HC_STAT_COLLECT_TICKS, 0xbb8); /* 3ms */
1970 
1971  if (CHIP_ID(bp) == CHIP_ID_5706_A1)
1973  else {
1977  }
1978 
1979  /* Clear internal stats counters. */
1981 
1983 
1984  if (REG_RD_IND(bp, bp->shmem_base + BNX2_PORT_FEATURE) &
1986  bp->flags |= ASF_ENABLE_FLAG;
1987 
1988  /* Initialize the receive filter. */
1989  bnx2_set_rx_mode(bp->nic);
1990 
1992  0);
1993 
1994  REG_WR(bp, BNX2_MISC_ENABLE_SET_BITS, 0x5ffffff);
1996 
1997  udelay(20);
1998 
1999  bp->hc_cmd = REG_RD(bp, BNX2_HC_COMMAND);
2000 
2001  return rc;
2002 }
uint16_t u16
Definition: stdint.h:21
#define PCIX_FLAG
Definition: bnx2.h:4005
#define BNX2_TBDR_CONFIG
Definition: bnx2.h:2695
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define BNX2_HC_RX_TICKS
Definition: bnx2.h:2893
#define BNX2_DMA_CONFIG
Definition: bnx2.h:1270
#define BNX2_DRV_MSG_CODE_RESET
Definition: bnx2.h:4293
int pci_write_config_word(struct pci_device *pci, unsigned int where, uint16_t value)
Write 16-bit word to PCI configuration space.
#define REG_WR(bp, offset, val)
Definition: bnx2.h:4194
#define BNX2_HC_TX_QUICK_CONS_TRIP
Definition: bnx2.h:2881
#define BNX2_EMAC_BACKOFF_SEED
Definition: bnx2.h:1609
uint16_t bp
Definition: registers.h:23
int pci_read_config_word(struct pci_device *pci, unsigned int where, uint16_t *value)
Read 16-bit word from PCI configuration space.
#define ETH_MAX_MTU
Definition: if_ether.h:14
#define BNX2_HC_TX_TICKS
Definition: bnx2.h:2897
#define CHIP_ID_5706_A0
Definition: bnx2.h:4084
#define ASF_ENABLE_FLAG
Definition: bnx2.h:4011
#define BNX2_PORT_FEATURE_ASF_ENABLED
Definition: bnx2.h:4423
#define BNX2_EMAC_RX_MODE_SORT_MODE
Definition: bnx2.h:1700
#define BNX2_HC_STATUS_ADDR_H
Definition: bnx2.h:2878
#define MB_KERNEL_CTX_SIZE
Definition: bnx2.h:3921
#define REG_RD_IND(bp, offset)
Definition: bnx2.h:4200
#define DMA_READ_CHANS
Definition: bnx2.h:3874
static void bnx2_set_mac_addr(struct bnx2 *bp)
Definition: bnx2.c:1273
#define BNX2_HC_CMD_TICKS
Definition: bnx2.h:2905
#define BNX2_MQ_KNL_BYP_WIND_START
Definition: bnx2.h:2625
#define PCI_X_CMD_ERO
Definition: bnx2.h:37
#define ETH_HLEN
Definition: if_ether.h:9
#define BNX2_DMA_CONFIG_CNTL_BYTE_SWAP
Definition: bnx2.h:1273
#define STATUS_ATTN_BITS_LINK_STATE
Definition: bnx2.h:192
#define BNX2_HC_COMP_PROD_TRIP
Definition: bnx2.h:2885
#define BNX2_RV2P_CONFIG
Definition: bnx2.h:2459
#define MAX_CID_CNT
Definition: bnx2.h:3925
#define BNX2_MQ_CONFIG_KNL_BYP_BLK_SIZE
Definition: bnx2.h:2607
#define BNX2_DMA_CONFIG_DATA_BYTE_SWAP
Definition: bnx2.h:1271
#define CHIP_NUM(bp)
Definition: bnx2.h:4071
#define BNX2_DRV_MSG_DATA_WAIT2
Definition: bnx2.h:4305
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
uint64_t u64
Definition: stdint.h:25
#define DMA_WRITE_CHANS
Definition: bnx2.h:3875
#define MAX_ETHERNET_PACKET_SIZE
Definition: bnx2.h:3869
#define BNX2_HC_STATISTICS_ADDR_H
Definition: bnx2.h:2880
#define BNX2_EMAC_ATTENTION_ENA_LINK
Definition: bnx2.h:1557
#define BNX2_HC_STATS_TICKS
Definition: bnx2.h:2915
#define BNX2_HC_STATISTICS_ADDR_L
Definition: bnx2.h:2879
#define BNX2_HC_CONFIG_TX_TMR_MODE
Definition: bnx2.h:2869
static void bnx2_init_cpus(struct bnx2 *bp)
Definition: bnx2.c:1427
#define BNX2_HC_RX_QUICK_CONS_TRIP
Definition: bnx2.h:2889
#define REG_RD(bp, offset)
Definition: bnx2.h:4191
#define BNX2_HC_COM_TICKS
Definition: bnx2.h:2901
#define BNX2_HC_COMMAND_CLR_STAT_NOW
Definition: bnx2.h:2852
#define BNX2_PORT_FEATURE
Definition: bnx2.h:4419
#define BNX2_PCICFG_INT_ACK_CMD_MASK_INT
Definition: bnx2.h:514
static int bnx2_fw_sync(struct bnx2 *bp, u32 msg_data, int silent)
Definition: bnx2.c:1147
#define BNX2_HC_STATUS_ADDR_L
Definition: bnx2.h:2877
#define BNX2_DMA_CONFIG_DATA_WORD_SWAP
Definition: bnx2.h:1272
#define BNX2_TDMA_CONFIG_ONE_DMA
Definition: bnx2.h:2764
void __asmcall int val
Definition: setjmp.h:28
#define BNX2_HC_COMMAND
Definition: bnx2.h:2841
static void bnx2_init_context(struct bnx2 *bp)
Definition: bnx2.c:1189
#define BNX2_MISC_ENABLE_STATUS_BITS_RX_V2P_ENABLE
Definition: bnx2.h:755
#define CHIP_NUM_5706
Definition: bnx2.h:4072
#define PCI_X_CMD
Definition: bnx2.h:36
#define BNX2_MISC_ENABLE_SET_BITS_HOST_COALESCE_ENABLE
Definition: bnx2.h:789
#define BNX2_HC_CONFIG_COLLECT_STATS
Definition: bnx2.h:2867
#define BNX2_PCICFG_INT_ACK_CMD
Definition: bnx2.h:510
#define BCM_PAGE_BITS
Definition: bnx2.h:3877
#define BNX2_EMAC_RX_MTU_SIZE
Definition: bnx2.h:1612
#define BNX2_MQ_CONFIG
Definition: bnx2.h:2604
#define BNX2_MISC_ENABLE_SET_BITS
Definition: bnx2.h:769
#define BNX2_EMAC_ATTENTION_ENA
Definition: bnx2.h:1556
#define BNX2_DMA_CONFIG_CNTL_PING_PONG_DMA
Definition: bnx2.h:1278
#define BNX2_MQ_CONFIG_KNL_BYP_BLK_SIZE_256
Definition: bnx2.h:2608
#define BNX2_MQ_KNL_WIND_END
Definition: bnx2.h:2628
#define CHIP_ID_5706_A1
Definition: bnx2.h:4085
#define BNX2_HC_CONFIG_RX_TMR_MODE
Definition: bnx2.h:2868
#define CHIP_ID(bp)
Definition: bnx2.h:4083
static int bnx2_init_nvram(struct bnx2 *bp)
Definition: bnx2.c:1679
#define BNX2_MISC_ENABLE_STATUS_BITS_CONTEXT_ENABLE
Definition: bnx2.h:761
uint32_t u32
Definition: stdint.h:23
static void bnx2_set_rx_mode(struct nic *nic __unused)
Definition: bnx2.c:1289
#define BNX2_TDMA_CONFIG
Definition: bnx2.h:2763
#define BNX2_HC_STAT_COLLECT_TICKS
Definition: bnx2.h:2912
#define BNX2_HC_ATTN_BITS_ENABLE
Definition: bnx2.h:2876
#define BNX2_DMA_CONFIG_CNTL_WORD_SWAP
Definition: bnx2.h:1274
#define BNX2_TBDR_CONFIG_PAGE_SIZE
Definition: bnx2.h:2700
#define BNX2_HC_CONFIG
Definition: bnx2.h:2866
#define BNX2_EMAC_RX_MTU_SIZE_JUMBO_ENA
Definition: bnx2.h:1614

References ASF_ENABLE_FLAG, BCM_PAGE_BITS, BNX2_DMA_CONFIG, BNX2_DMA_CONFIG_CNTL_BYTE_SWAP, BNX2_DMA_CONFIG_CNTL_PING_PONG_DMA, BNX2_DMA_CONFIG_CNTL_WORD_SWAP, BNX2_DMA_CONFIG_DATA_BYTE_SWAP, BNX2_DMA_CONFIG_DATA_WORD_SWAP, BNX2_DRV_MSG_CODE_RESET, BNX2_DRV_MSG_DATA_WAIT2, BNX2_EMAC_ATTENTION_ENA, BNX2_EMAC_ATTENTION_ENA_LINK, BNX2_EMAC_BACKOFF_SEED, BNX2_EMAC_RX_MODE_SORT_MODE, BNX2_EMAC_RX_MTU_SIZE, BNX2_EMAC_RX_MTU_SIZE_JUMBO_ENA, bnx2_fw_sync(), BNX2_HC_ATTN_BITS_ENABLE, BNX2_HC_CMD_TICKS, BNX2_HC_COM_TICKS, BNX2_HC_COMMAND, BNX2_HC_COMMAND_CLR_STAT_NOW, BNX2_HC_COMP_PROD_TRIP, BNX2_HC_CONFIG, BNX2_HC_CONFIG_COLLECT_STATS, BNX2_HC_CONFIG_RX_TMR_MODE, BNX2_HC_CONFIG_TX_TMR_MODE, BNX2_HC_RX_QUICK_CONS_TRIP, BNX2_HC_RX_TICKS, BNX2_HC_STAT_COLLECT_TICKS, BNX2_HC_STATISTICS_ADDR_H, BNX2_HC_STATISTICS_ADDR_L, BNX2_HC_STATS_TICKS, BNX2_HC_STATUS_ADDR_H, BNX2_HC_STATUS_ADDR_L, BNX2_HC_TX_QUICK_CONS_TRIP, BNX2_HC_TX_TICKS, bnx2_init_context(), bnx2_init_cpus(), bnx2_init_nvram(), BNX2_MISC_ENABLE_SET_BITS, BNX2_MISC_ENABLE_SET_BITS_HOST_COALESCE_ENABLE, BNX2_MISC_ENABLE_STATUS_BITS_CONTEXT_ENABLE, BNX2_MISC_ENABLE_STATUS_BITS_RX_V2P_ENABLE, BNX2_MQ_CONFIG, BNX2_MQ_CONFIG_KNL_BYP_BLK_SIZE, BNX2_MQ_CONFIG_KNL_BYP_BLK_SIZE_256, BNX2_MQ_KNL_BYP_WIND_START, BNX2_MQ_KNL_WIND_END, BNX2_PCICFG_INT_ACK_CMD, BNX2_PCICFG_INT_ACK_CMD_MASK_INT, BNX2_PORT_FEATURE, BNX2_PORT_FEATURE_ASF_ENABLED, BNX2_RV2P_CONFIG, bnx2_set_mac_addr(), bnx2_set_rx_mode(), BNX2_TBDR_CONFIG, BNX2_TBDR_CONFIG_PAGE_SIZE, BNX2_TDMA_CONFIG, BNX2_TDMA_CONFIG_ONE_DMA, bp, CHIP_ID, CHIP_ID_5706_A0, CHIP_ID_5706_A1, CHIP_NUM, CHIP_NUM_5706, DMA_READ_CHANS, DMA_WRITE_CHANS, ETH_HLEN, ETH_MAX_MTU, MAX_CID_CNT, MAX_ETHERNET_PACKET_SIZE, MB_KERNEL_CTX_SIZE, pci_read_config_word(), pci_write_config_word(), PCI_X_CMD, PCI_X_CMD_ERO, PCIX_FLAG, rc, REG_RD, REG_RD_IND, REG_WR, STATUS_ATTN_BITS_LINK_STATE, udelay(), and val.

Referenced by bnx2_reset_nic().

◆ bnx2_init_tx_ring()

static void bnx2_init_tx_ring ( struct bnx2 bp)
static

Definition at line 2005 of file bnx2.c.

2006 {
2007  struct tx_bd *txbd;
2008  u32 val;
2009 
2010  txbd = &bp->tx_desc_ring[MAX_TX_DESC_CNT];
2011 
2012  /* Etherboot lives below 4GB, so hi is always 0 */
2013  txbd->tx_bd_haddr_hi = 0;
2014  txbd->tx_bd_haddr_lo = bp->tx_desc_mapping;
2015 
2016  bp->tx_prod = 0;
2017  bp->tx_cons = 0;
2018  bp->hw_tx_cons = 0;
2019  bp->tx_prod_bseq = 0;
2020 
2024 
2026  val |= 8 << 16;
2028 
2029  /* Etherboot lives below 4GB, so hi is always 0 */
2031 
2032  val = (u64) bp->tx_desc_mapping & 0xffffffff;
2034 }
#define BNX2_L2CTX_TBDR_BHADDR_LO
Definition: bnx2.h:425
uint16_t bp
Definition: registers.h:23
u32 tx_bd_haddr_lo
Definition: bnx2.h:152
Definition: bnx2.h:150
#define BNX2_L2CTX_TBDR_BHADDR_HI
Definition: bnx2.h:424
uint64_t u64
Definition: stdint.h:25
#define BNX2_L2CTX_TYPE
Definition: bnx2.h:406
#define GET_CID_ADDR(_cid)
Definition: bnx2.h:3911
#define BNX2_L2CTX_CMD_TYPE
Definition: bnx2.h:414
void __asmcall int val
Definition: setjmp.h:28
#define TX_CID
Definition: bnx2.h:3929
#define MAX_TX_DESC_CNT
Definition: bnx2.h:3881
#define CTX_WR(bp, cid_addr, offset, val)
Definition: bnx2.h:4210
#define BNX2_L2CTX_CMD_TYPE_TYPE_L2
Definition: bnx2.h:416
#define BNX2_L2CTX_TYPE_SIZE_L2
Definition: bnx2.h:407
#define BNX2_L2CTX_TYPE_TYPE_L2
Definition: bnx2.h:410
uint32_t u32
Definition: stdint.h:23
u32 tx_bd_haddr_hi
Definition: bnx2.h:151

References BNX2_L2CTX_CMD_TYPE, BNX2_L2CTX_CMD_TYPE_TYPE_L2, BNX2_L2CTX_TBDR_BHADDR_HI, BNX2_L2CTX_TBDR_BHADDR_LO, BNX2_L2CTX_TYPE, BNX2_L2CTX_TYPE_SIZE_L2, BNX2_L2CTX_TYPE_TYPE_L2, bp, CTX_WR, GET_CID_ADDR, MAX_TX_DESC_CNT, tx_bd::tx_bd_haddr_hi, tx_bd::tx_bd_haddr_lo, TX_CID, and val.

Referenced by bnx2_reset_nic().

◆ bnx2_init_rx_ring()

static void bnx2_init_rx_ring ( struct bnx2 bp)
static

Definition at line 2037 of file bnx2.c.

2038 {
2039  struct rx_bd *rxbd;
2040  unsigned int i;
2041  u16 prod, ring_prod;
2042  u32 val;
2043 
2044  bp->rx_buf_use_size = RX_BUF_USE_SIZE;
2045  bp->rx_buf_size = RX_BUF_SIZE;
2046 
2047  ring_prod = prod = bp->rx_prod = 0;
2048  bp->rx_cons = 0;
2049  bp->hw_rx_cons = 0;
2050  bp->rx_prod_bseq = 0;
2051 
2052  memset(bnx2_bss.rx_buf, 0, sizeof(bnx2_bss.rx_buf));
2053 
2054  rxbd = &bp->rx_desc_ring[0];
2055  for (i = 0; i < MAX_RX_DESC_CNT; i++, rxbd++) {
2056  rxbd->rx_bd_len = bp->rx_buf_use_size;
2058  }
2059  rxbd->rx_bd_haddr_hi = 0;
2060  rxbd->rx_bd_haddr_lo = (u64) bp->rx_desc_mapping & 0xffffffff;
2061 
2064  val |= 0x02 << 8;
2066 
2067  /* Etherboot doesn't use memory above 4GB, so this is always 0 */
2069 
2070  val = bp->rx_desc_mapping & 0xffffffff;
2072 
2073  for (i = 0; (int) i < bp->rx_ring_size; i++) {
2074  rxbd = &bp->rx_desc_ring[RX_RING_IDX(ring_prod)];
2075  rxbd->rx_bd_haddr_hi = 0;
2076  rxbd->rx_bd_haddr_lo = virt_to_bus(&bnx2_bss.rx_buf[ring_prod][0]);
2077  bp->rx_prod_bseq += bp->rx_buf_use_size;
2078  prod = NEXT_RX_BD(prod);
2079  ring_prod = RX_RING_IDX(prod);
2080  }
2081  bp->rx_prod = prod;
2082 
2084 
2085  REG_WR(bp, MB_RX_CID_ADDR + BNX2_L2CTX_HOST_BSEQ, bp->rx_prod_bseq);
2086 }
u32 rx_bd_flags
Definition: bnx2.h:178
uint16_t u16
Definition: stdint.h:21
unsigned char rx_buf[RX_BUF_CNT][RX_BUF_SIZE]
Definition: bnx2.c:42
#define RX_BUF_SIZE
Definition: 3c90x.h:269
#define REG_WR(bp, offset, val)
Definition: bnx2.h:4194
uint16_t bp
Definition: registers.h:23
#define BNX2_L2CTX_CTX_TYPE
Definition: bnx2.h:436
#define BNX2_L2CTX_CTX_TYPE_SIZE_L2
Definition: bnx2.h:437
u32 rx_bd_haddr_lo
Definition: bnx2.h:176
#define MB_RX_CID_ADDR
Definition: bnx2.h:3933
#define BNX2_L2CTX_CTX_TYPE_CTX_BD_CHN_TYPE_VALUE
Definition: bnx2.h:440
static struct bss bnx2_bss
#define BNX2_L2CTX_HOST_BDIDX
Definition: bnx2.h:442
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition: io.h:183
#define MAX_RX_DESC_CNT
Definition: bnx2.h:3885
#define RX_BD_FLAGS_END
Definition: bnx2.h:181
#define BNX2_L2CTX_NX_BDHADDR_HI
Definition: bnx2.h:445
uint64_t u64
Definition: stdint.h:25
Definition: bnx2.h:174
u32 rx_bd_haddr_hi
Definition: bnx2.h:175
#define GET_CID_ADDR(_cid)
Definition: bnx2.h:3911
#define RX_BD_FLAGS_START
Definition: bnx2.h:182
#define RX_RING_IDX(x)
Definition: bnx2.h:3902
void __asmcall int val
Definition: setjmp.h:28
#define REG_WR16(bp, offset, val)
Definition: bnx2.h:4197
#define CTX_WR(bp, cid_addr, offset, val)
Definition: bnx2.h:4210
#define RX_CID
Definition: bnx2.h:3930
u32 rx_bd_len
Definition: bnx2.h:177
#define BNX2_L2CTX_HOST_BSEQ
Definition: bnx2.h:443
#define RX_BUF_USE_SIZE
Definition: bnx2.h:4591
uint32_t u32
Definition: stdint.h:23
#define BNX2_L2CTX_NX_BDHADDR_LO
Definition: bnx2.h:446
#define NEXT_RX_BD(x)
Definition: bnx2.h:3898
void * memset(void *dest, int character, size_t len) __nonnull

References bnx2_bss, BNX2_L2CTX_CTX_TYPE, BNX2_L2CTX_CTX_TYPE_CTX_BD_CHN_TYPE_VALUE, BNX2_L2CTX_CTX_TYPE_SIZE_L2, BNX2_L2CTX_HOST_BDIDX, BNX2_L2CTX_HOST_BSEQ, BNX2_L2CTX_NX_BDHADDR_HI, BNX2_L2CTX_NX_BDHADDR_LO, bp, CTX_WR, GET_CID_ADDR, MAX_RX_DESC_CNT, MB_RX_CID_ADDR, memset(), NEXT_RX_BD, REG_WR, REG_WR16, rx_bd::rx_bd_flags, RX_BD_FLAGS_END, RX_BD_FLAGS_START, rx_bd::rx_bd_haddr_hi, rx_bd::rx_bd_haddr_lo, rx_bd::rx_bd_len, bss::rx_buf, RX_BUF_SIZE, RX_BUF_USE_SIZE, RX_CID, RX_RING_IDX, val, and virt_to_bus().

Referenced by bnx2_reset_nic().

◆ bnx2_reset_nic()

static int bnx2_reset_nic ( struct bnx2 bp,
u32  reset_code 
)
static

Definition at line 2089 of file bnx2.c.

2090 {
2091  int rc;
2092 
2093  rc = bnx2_reset_chip(bp, reset_code);
2094  if (rc) {
2095  return rc;
2096  }
2097 
2098  bnx2_init_chip(bp);
2101  return 0;
2102 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static int bnx2_reset_chip(struct bnx2 *bp, u32 reset_code)
Definition: bnx2.c:1753
static int bnx2_init_chip(struct bnx2 *bp)
Definition: bnx2.c:1845
uint16_t bp
Definition: registers.h:23
static void bnx2_init_rx_ring(struct bnx2 *bp)
Definition: bnx2.c:2037
static void bnx2_init_tx_ring(struct bnx2 *bp)
Definition: bnx2.c:2005

References bnx2_init_chip(), bnx2_init_rx_ring(), bnx2_init_tx_ring(), bnx2_reset_chip(), bp, and rc.

Referenced by bnx2_init_nic().

◆ bnx2_init_nic()

static int bnx2_init_nic ( struct bnx2 bp)
static

Definition at line 2105 of file bnx2.c.

2106 {
2107  int rc;
2108 
2110  return rc;
2111 
2112  bnx2_init_phy(bp);
2113  bnx2_set_link(bp);
2114  return 0;
2115 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static int bnx2_set_link(struct bnx2 *bp)
Definition: bnx2.c:659
#define BNX2_DRV_MSG_CODE_RESET
Definition: bnx2.h:4293
uint16_t bp
Definition: registers.h:23
static int bnx2_reset_nic(struct bnx2 *bp, u32 reset_code)
Definition: bnx2.c:2089
static int bnx2_init_phy(struct bnx2 *bp)
Definition: bnx2.c:1114

References BNX2_DRV_MSG_CODE_RESET, bnx2_init_phy(), bnx2_reset_nic(), bnx2_set_link(), bp, and rc.

Referenced by bnx2_probe().

◆ bnx2_init_board()

static int bnx2_init_board ( struct pci_device pdev,
struct nic nic 
)
static

Definition at line 2118 of file bnx2.c.

2119 {
2120  unsigned long bnx2reg_base, bnx2reg_len;
2121  struct bnx2 *bp = &bnx2;
2122  int rc;
2123  u32 reg;
2124 
2125  bp->flags = 0;
2126  bp->phy_flags = 0;
2127 
2128  /* enable device (incl. PCI PM wakeup), and bus-mastering */
2130 
2131  nic->ioaddr = pdev->ioaddr & ~3;
2132  nic->irqno = 0;
2133 
2134  rc = 0;
2136  if (bp->pm_cap == 0) {
2137  printf("Cannot find power management capability, aborting.\n");
2138  rc = -EIO;
2139  goto err_out_disable;
2140  }
2141 
2143  if (bp->pcix_cap == 0) {
2144  printf("Cannot find PCIX capability, aborting.\n");
2145  rc = -EIO;
2146  goto err_out_disable;
2147  }
2148 
2149  bp->pdev = pdev;
2150  bp->nic = nic;
2151 
2152  bnx2reg_base = pci_bar_start(pdev, PCI_BASE_ADDRESS_0);
2153  bnx2reg_len = MB_GET_CID_ADDR(17);
2154 
2155  bp->regview = pci_ioremap(pdev, bnx2reg_base, bnx2reg_len);
2156 
2157  if (!bp->regview) {
2158  printf("Cannot map register space, aborting.\n");
2159  rc = -EIO;
2160  goto err_out_disable;
2161  }
2162 
2163  /* Configure byte swap and enable write to the reg_window registers.
2164  * Rely on CPU to do target byte swapping on big endian systems
2165  * The chip's target access swapping will not swap all accesses
2166  */
2170 
2172 
2173  bp->chip_id = REG_RD(bp, BNX2_MISC_ID);
2174 
2175  /* Get bus information. */
2178  u32 clkreg;
2179 
2180  bp->flags |= PCIX_FLAG;
2181 
2183 
2185  switch (clkreg) {
2187  bp->bus_speed_mhz = 133;
2188  break;
2189 
2191  bp->bus_speed_mhz = 100;
2192  break;
2193 
2196  bp->bus_speed_mhz = 66;
2197  break;
2198 
2201  bp->bus_speed_mhz = 50;
2202  break;
2203 
2207  bp->bus_speed_mhz = 33;
2208  break;
2209  }
2210  }
2211  else {
2213  bp->bus_speed_mhz = 66;
2214  else
2215  bp->bus_speed_mhz = 33;
2216  }
2217 
2219  bp->flags |= PCI_32BIT_FLAG;
2220 
2221  /* 5706A0 may falsely detect SERR and PERR. */
2222  if (CHIP_ID(bp) == CHIP_ID_5706_A0) {
2223  reg = REG_RD(bp, PCI_COMMAND);
2225  REG_WR(bp, PCI_COMMAND, reg);
2226  }
2227  else if ((CHIP_ID(bp) == CHIP_ID_5706_A1) &&
2228  !(bp->flags & PCIX_FLAG)) {
2229 
2230  printf("5706 A1 can only be used in a PCIX bus, aborting.\n");
2231  goto err_out_disable;
2232  }
2233 
2235 
2237 
2240  bp->shmem_base = REG_RD_IND(bp, BNX2_SHM_HDR_ADDR_0);
2241  else
2242  bp->shmem_base = HOST_VIEW_SHMEM_BASE;
2243 
2244  /* Get the permanent MAC address. First we need to make sure the
2245  * firmware is actually running.
2246  */
2247  reg = REG_RD_IND(bp, bp->shmem_base + BNX2_DEV_INFO_SIGNATURE);
2248 
2251  printf("Firmware not running, aborting.\n");
2252  rc = -ENODEV;
2253  goto err_out_disable;
2254  }
2255 
2256  bp->fw_ver = REG_RD_IND(bp, bp->shmem_base + BNX2_DEV_INFO_BC_REV);
2257 
2258  reg = REG_RD_IND(bp, bp->shmem_base + BNX2_PORT_HW_CFG_MAC_UPPER);
2259  bp->mac_addr[0] = (u8) (reg >> 8);
2260  bp->mac_addr[1] = (u8) reg;
2261 
2262  reg = REG_RD_IND(bp, bp->shmem_base + BNX2_PORT_HW_CFG_MAC_LOWER);
2263  bp->mac_addr[2] = (u8) (reg >> 24);
2264  bp->mac_addr[3] = (u8) (reg >> 16);
2265  bp->mac_addr[4] = (u8) (reg >> 8);
2266  bp->mac_addr[5] = (u8) reg;
2267 
2268  bp->tx_ring_size = MAX_TX_DESC_CNT;
2269  bp->rx_ring_size = RX_BUF_CNT;
2270  bp->rx_max_ring_idx = MAX_RX_DESC_CNT;
2271 
2272  bp->rx_offset = RX_OFFSET;
2273 
2274  bp->tx_quick_cons_trip_int = 20;
2275  bp->tx_quick_cons_trip = 20;
2276  bp->tx_ticks_int = 80;
2277  bp->tx_ticks = 80;
2278 
2279  bp->rx_quick_cons_trip_int = 6;
2280  bp->rx_quick_cons_trip = 6;
2281  bp->rx_ticks_int = 18;
2282  bp->rx_ticks = 18;
2283 
2284  bp->stats_ticks = 1000000 & 0xffff00;
2285 
2286  bp->phy_addr = 1;
2287 
2288  /* No need for WOL support in Etherboot */
2289  bp->flags |= NO_WOL_FLAG;
2290 
2291  /* Disable WOL support if we are running on a SERDES chip. */
2293  bp->phy_flags |= PHY_SERDES_FLAG;
2294  if (CHIP_NUM(bp) == CHIP_NUM_5708) {
2295  bp->phy_addr = 2;
2296  reg = REG_RD_IND(bp, bp->shmem_base +
2299  bp->phy_flags |= PHY_2_5G_CAPABLE_FLAG;
2300  }
2301  }
2302 
2303  if (CHIP_ID(bp) == CHIP_ID_5706_A0) {
2304  bp->tx_quick_cons_trip_int =
2305  bp->tx_quick_cons_trip;
2306  bp->tx_ticks_int = bp->tx_ticks;
2307  bp->rx_quick_cons_trip_int =
2308  bp->rx_quick_cons_trip;
2309  bp->rx_ticks_int = bp->rx_ticks;
2310  bp->comp_prod_trip_int = bp->comp_prod_trip;
2311  bp->com_ticks_int = bp->com_ticks;
2312  bp->cmd_ticks_int = bp->cmd_ticks;
2313  }
2314 
2315  bp->autoneg = AUTONEG_SPEED | AUTONEG_FLOW_CTRL;
2316  bp->req_line_speed = 0;
2317  if (bp->phy_flags & PHY_SERDES_FLAG) {
2319 
2320  reg = REG_RD_IND(bp, bp->shmem_base + BNX2_PORT_HW_CFG_CONFIG);
2323  bp->autoneg = 0;
2324  bp->req_line_speed = bp->line_speed = SPEED_1000;
2325  bp->req_duplex = DUPLEX_FULL;
2326  }
2327  }
2328  else {
2330  }
2331 
2332  bp->req_flow_ctrl = FLOW_CTRL_RX | FLOW_CTRL_TX;
2333 
2334  /* Disable driver heartbeat checking */
2335  REG_WR_IND(bp, bp->shmem_base + BNX2_DRV_PULSE_MB,
2337  REG_RD_IND(bp, bp->shmem_base + BNX2_DRV_PULSE_MB);
2338 
2339  return 0;
2340 
2341 err_out_disable:
2342  bnx2_disable(nic);
2343 
2344  return rc;
2345 }
#define SPEED_1000
Definition: atl1e.h:52
unsigned char irqno
Definition: nic.h:56
#define PCIX_FLAG
Definition: bnx2.h:4005
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static void bnx2_disable(struct nic *nic __unused)
Definition: bnx2.c:1834
int printf(const char *fmt,...)
Write a formatted string to the console.
Definition: vsprintf.c:464
#define BNX2_PCICFG_MISC_CONFIG_REG_WINDOW_ENA
Definition: bnx2.h:459
#define BNX2_PCICFG_MISC_CONFIG_TARGET_MB_WORD_SWAP
Definition: bnx2.h:456
static unsigned int unsigned int reg
Definition: myson.h:162
int pci_find_capability(struct pci_device *pci, int cap)
Look for a PCI capability.
Definition: pciextra.c:38
unsigned long ioaddr
I/O address.
Definition: pci.h:221
#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_133MHZ
Definition: bnx2.h:486
#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_66MHZ
Definition: bnx2.h:483
#define PCI_CAP_ID_PM
Power management.
Definition: pci.h:94
#define REG_WR(bp, offset, val)
Definition: bnx2.h:4194
#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_48MHZ
Definition: bnx2.h:481
#define PHY_2_5G_CAPABLE_FLAG
Definition: bnx2.h:4064
uint16_t bp
Definition: registers.h:23
#define BNX2_PCICFG_MISC_STATUS
Definition: bnx2.h:466
#define BNX2_PCICFG_MISC_CONFIG
Definition: bnx2.h:454
#define PCI_BASE_ADDRESS_0
Definition: pci.h:62
#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET
Definition: bnx2.h:478
#define PCI_COMMAND
PCI command.
Definition: pci.h:25
#define HOST_VIEW_SHMEM_BASE
Definition: bnx2.h:4578
#define BNX2_DEV_INFO_BC_REV
Definition: bnx2.h:4390
#define CHIP_ID_5706_A0
Definition: bnx2.h:4084
#define BNX2_PORT_HW_CFG_MAC_UPPER
Definition: bnx2.h:4392
#define BNX2_DRV_PULSE_MB
Definition: bnx2.h:4350
#define CHIP_NUM_5708
Definition: bnx2.h:4073
void adjust_pci_device(struct pci_device *pci)
Enable PCI device.
Definition: pci.c:154
#define BNX2_SHARED_HW_CFG_PHY_2_5G
Definition: bnx2.h:4379
#define ETHTOOL_ALL_COPPER_SPEED
Definition: bnx2.c:885
#define BNX2_SHM_HDR_SIGNATURE
Definition: bnx2.h:3802
#define FLOW_CTRL_TX
Definition: bnx2.h:4152
#define BNX2_SHM_HDR_ADDR_0
Definition: bnx2.h:3808
#define REG_RD_IND(bp, offset)
Definition: bnx2.h:4200
#define RX_OFFSET
Definition: bnx2.h:4586
#define PCI_32BIT_FLAG
Definition: bnx2.h:4006
unsigned int ioaddr
Definition: nic.h:55
#define MAX_RX_DESC_CNT
Definition: bnx2.h:3885
#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_80MHZ
Definition: bnx2.h:484
#define BNX2_SHARED_HW_CFG_CONFIG
Definition: bnx2.h:4374
static int bnx2_set_power_state_0(struct bnx2 *bp)
Definition: bnx2.c:1628
#define ADVERTISED_Autoneg
Definition: bnx2.h:48
#define BNX2_PCICFG_MISC_STATUS_32BIT_DET
Definition: bnx2.h:468
#define CHIP_NUM(bp)
Definition: bnx2.h:4071
#define DUPLEX_FULL
Definition: bnx2.h:111
#define u8
Definition: igbvf_osdep.h:38
unsigned long pci_bar_start(struct pci_device *pci, unsigned int reg)
Find the start of a PCI BAR.
Definition: pci.c:96
#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_38MHZ
Definition: bnx2.h:480
#define BNX2_PCICFG_MISC_STATUS_PCIX_DET
Definition: bnx2.h:470
#define PCI_CAP_ID_PCIX
Definition: bnx2.h:35
#define AUTONEG_FLOW_CTRL
Definition: bnx2.h:4162
#define PHY_SERDES_FLAG
Definition: bnx2.h:4061
#define REG_RD(bp, offset)
Definition: bnx2.h:4191
#define BNX2_PCICFG_MISC_STATUS_M66EN
Definition: bnx2.h:469
#define ENODEV
No such device.
Definition: errno.h:509
struct pci_device * pdev
Definition: bnx2.h:3997
#define NO_WOL_FLAG
Definition: bnx2.h:4008
#define BNX2_SHM_HDR_SIGNATURE_SIG
Definition: bnx2.h:3804
Definition: bnx2.h:3991
#define BNX2_SHM_HDR_SIGNATURE_SIG_MASK
Definition: bnx2.h:3803
#define FLOW_CTRL_RX
Definition: bnx2.h:4153
#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_LOW
Definition: bnx2.h:487
#define BNX2_DEV_INFO_SIGNATURE_MAGIC_MASK
Definition: bnx2.h:4360
Definition: nic.h:49
#define PCI_COMMAND_SERR
SERR# enable.
Definition: pci.h:31
#define CHIP_BOND_ID(bp)
Definition: bnx2.h:4091
#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_55MHZ
Definition: bnx2.h:482
#define MAX_TX_DESC_CNT
Definition: bnx2.h:3881
#define RX_BUF_CNT
Definition: bnx2.h:4588
#define BNX2_PORT_HW_CFG_CFG_DFLT_LINK_MASK
Definition: bnx2.h:4398
static struct bnx2 bnx2
Definition: bnx2.c:47
#define PCI_COMMAND_PARITY
Parity error response.
Definition: pci.h:30
#define EIO
Input/output error.
Definition: errno.h:433
int pci_write_config_dword(struct pci_device *pci, unsigned int where, uint32_t value)
Write 32-bit dword to PCI configuration space.
#define MB_GET_CID_ADDR(_cid)
Definition: bnx2.h:3923
#define BNX2_PORT_HW_CFG_MAC_LOWER
Definition: bnx2.h:4395
#define REG_WR_IND(bp, offset, val)
Definition: bnx2.h:4203
#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_32MHZ
Definition: bnx2.h:479
#define BNX2_PORT_HW_CFG_CFG_DFLT_LINK_1G
Definition: bnx2.h:4400
#define ETHTOOL_ALL_FIBRE_SPEED
Definition: bnx2.c:882
#define CHIP_ID_5706_A1
Definition: bnx2.h:4085
#define BNX2_DEV_INFO_SIGNATURE
Definition: bnx2.h:4358
#define BNX2_DEV_INFO_SIGNATURE_MAGIC
Definition: bnx2.h:4359
#define CHIP_ID(bp)
Definition: bnx2.h:4083
void * pci_ioremap(struct pci_device *pci, unsigned long bus_addr, size_t len)
Map PCI bus address as an I/O address.
struct nic nic
Definition: legacy.c:22
#define AUTONEG_SPEED
Definition: bnx2.h:4161
static int bnx2_init_nvram(struct bnx2 *bp)
Definition: bnx2.c:1679
#define BNX2_DRV_MSG_DATA_PULSE_CODE_ALWAYS_ALIVE
Definition: bnx2.h:4356
#define BNX2_MISC_ID
Definition: bnx2.h:733
#define BNX2_PORT_HW_CFG_CONFIG
Definition: bnx2.h:4396
uint32_t u32
Definition: stdint.h:23
#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_95MHZ
Definition: bnx2.h:485
#define CHIP_BOND_ID_SERDES_BIT
Definition: bnx2.h:4094
#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS
Definition: bnx2.h:477

References adjust_pci_device(), ADVERTISED_Autoneg, AUTONEG_FLOW_CTRL, AUTONEG_SPEED, bnx2, BNX2_DEV_INFO_BC_REV, BNX2_DEV_INFO_SIGNATURE, BNX2_DEV_INFO_SIGNATURE_MAGIC, BNX2_DEV_INFO_SIGNATURE_MAGIC_MASK, bnx2_disable(), BNX2_DRV_MSG_DATA_PULSE_CODE_ALWAYS_ALIVE, BNX2_DRV_PULSE_MB, bnx2_init_nvram(), BNX2_MISC_ID, BNX2_PCICFG_MISC_CONFIG, BNX2_PCICFG_MISC_CONFIG_REG_WINDOW_ENA, BNX2_PCICFG_MISC_CONFIG_TARGET_MB_WORD_SWAP, BNX2_PCICFG_MISC_STATUS, BNX2_PCICFG_MISC_STATUS_32BIT_DET, BNX2_PCICFG_MISC_STATUS_M66EN, BNX2_PCICFG_MISC_STATUS_PCIX_DET, BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS, BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET, BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_133MHZ, BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_32MHZ, BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_38MHZ, BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_48MHZ, BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_55MHZ, BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_66MHZ, BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_80MHZ, BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_95MHZ, BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET_LOW, BNX2_PORT_HW_CFG_CFG_DFLT_LINK_1G, BNX2_PORT_HW_CFG_CFG_DFLT_LINK_MASK, BNX2_PORT_HW_CFG_CONFIG, BNX2_PORT_HW_CFG_MAC_LOWER, BNX2_PORT_HW_CFG_MAC_UPPER, bnx2_set_power_state_0(), BNX2_SHARED_HW_CFG_CONFIG, BNX2_SHARED_HW_CFG_PHY_2_5G, BNX2_SHM_HDR_ADDR_0, BNX2_SHM_HDR_SIGNATURE, BNX2_SHM_HDR_SIGNATURE_SIG, BNX2_SHM_HDR_SIGNATURE_SIG_MASK, bp, CHIP_BOND_ID, CHIP_BOND_ID_SERDES_BIT, CHIP_ID, CHIP_ID_5706_A0, CHIP_ID_5706_A1, CHIP_NUM, CHIP_NUM_5708, DUPLEX_FULL, EIO, ENODEV, ETHTOOL_ALL_COPPER_SPEED, ETHTOOL_ALL_FIBRE_SPEED, FLOW_CTRL_RX, FLOW_CTRL_TX, HOST_VIEW_SHMEM_BASE, nic::ioaddr, pci_device::ioaddr, nic::irqno, MAX_RX_DESC_CNT, MAX_TX_DESC_CNT, MB_GET_CID_ADDR, nic, NO_WOL_FLAG, PCI_32BIT_FLAG, pci_bar_start(), PCI_BASE_ADDRESS_0, PCI_CAP_ID_PCIX, PCI_CAP_ID_PM, PCI_COMMAND, PCI_COMMAND_PARITY, PCI_COMMAND_SERR, pci_find_capability(), pci_ioremap(), pci_write_config_dword(), PCIX_FLAG, bnx2::pdev, PHY_2_5G_CAPABLE_FLAG, PHY_SERDES_FLAG, printf(), rc, reg, REG_RD, REG_RD_IND, REG_WR, REG_WR_IND, RX_BUF_CNT, RX_OFFSET, SPEED_1000, and u8.

Referenced by bnx2_probe(), and bnx2_transmit().

◆ bnx2_transmit()

static void bnx2_transmit ( struct nic nic,
const char *  dst_addr,
unsigned int  type,
unsigned int  size,
const char *  packet 
)
static

Definition at line 2348 of file bnx2.c.

2350 {
2351  /* Sometimes the nic will be behind by a frame. Using two transmit
2352  * buffers prevents us from timing out in that case.
2353  */
2354  static struct eth_frame {
2357  uint16_t type;
2359  } frame[2];
2360  static int frame_idx = 0;
2361 
2362  /* send the packet to destination */
2363  struct tx_bd *txbd;
2364  struct bnx2 *bp = &bnx2;
2365  u16 prod, ring_prod;
2366  u16 hw_cons;
2367  int i = 0;
2368 
2369  prod = bp->tx_prod;
2370  ring_prod = TX_RING_IDX(prod);
2371  hw_cons = bp->status_blk->status_tx_quick_consumer_index0;
2372  if ((hw_cons & MAX_TX_DESC_CNT) == MAX_TX_DESC_CNT) {
2373  hw_cons++;
2374  }
2375 
2376  while((hw_cons != prod) && (hw_cons != (PREV_TX_BD(prod)))) {
2377  mdelay(10); /* give the nic a chance */
2378  //poll_interruptions();
2379  if (++i > 500) { /* timeout 5s for transmit */
2380  printf("transmit timed out\n");
2381  bnx2_disable(bp->nic);
2382  bnx2_init_board(bp->pdev, bp->nic);
2383  return;
2384  }
2385  }
2386  if (i != 0) {
2387  printf("#");
2388  }
2389 
2390  /* Copy the packet to the our local buffer */
2391  memcpy(&frame[frame_idx].dst_addr, dst_addr, ETH_ALEN);
2392  memcpy(&frame[frame_idx].src_addr, nic->node_addr, ETH_ALEN);
2393  frame[frame_idx].type = htons(type);
2394  memset(&frame[frame_idx].data, 0, sizeof(frame[frame_idx].data));
2395  memcpy(&frame[frame_idx].data, packet, size);
2396 
2397  /* Setup the ring buffer entry to transmit */
2398  txbd = &bp->tx_desc_ring[ring_prod];
2399  txbd->tx_bd_haddr_hi = 0; /* Etherboot runs under 4GB */
2400  txbd->tx_bd_haddr_lo = virt_to_bus(&frame[frame_idx]);
2401  txbd->tx_bd_mss_nbytes = (size + ETH_HLEN);
2403 
2404  /* Advance to the next entry */
2405  prod = NEXT_TX_BD(prod);
2406  frame_idx ^= 1;
2407 
2408  bp->tx_prod_bseq += (size + ETH_HLEN);
2409 
2411  REG_WR(bp, MB_TX_CID_ADDR + BNX2_L2CTX_TX_HOST_BSEQ, bp->tx_prod_bseq);
2412 
2413  wmb();
2414 
2415  bp->tx_prod = prod;
2416 }
uint16_t u16
Definition: stdint.h:21
static void bnx2_disable(struct nic *nic __unused)
Definition: bnx2.c:1834
unsigned short uint16_t
Definition: stdint.h:11
wmb()
u16 type
Definition: amd8111e.c:85
int printf(const char *fmt,...)
Write a formatted string to the console.
Definition: vsprintf.c:464
#define TX_RING_IDX(x)
Definition: bnx2.h:3896
u32 tx_bd_vlan_tag_flags
Definition: bnx2.h:154
#define MB_TX_CID_ADDR
Definition: bnx2.h:3932
#define REG_WR(bp, offset, val)
Definition: bnx2.h:4194
uint16_t bp
Definition: registers.h:23
u32 tx_bd_mss_nbytes
Definition: bnx2.h:153
#define PREV_TX_BD(x)
Definition: bnx2.h:3892
#define BNX2_L2CTX_TX_HOST_BSEQ
Definition: bnx2.h:419
u32 tx_bd_haddr_lo
Definition: bnx2.h:152
unsigned long frame
Definition: xengrant.h:179
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition: io.h:183
#define ETH_HLEN
Definition: if_ether.h:9
#define ETH_FRAME_LEN
Definition: if_ether.h:11
Definition: bnx2.h:150
#define TX_BD_FLAGS_START
Definition: bnx2.h:162
static int bnx2_init_board(struct pci_device *pdev, struct nic *nic)
Definition: bnx2.c:2118
#define NEXT_TX_BD(x)
Definition: bnx2.h:3888
unsigned char uint8_t
Definition: stdint.h:10
Definition: bnx2.h:3991
#define ETH_ALEN
Definition: if_ether.h:8
Definition: nic.h:49
#define BNX2_L2CTX_TX_HOST_BIDX
Definition: bnx2.h:412
u8 data[ETH_FRAME_LEN - ETH_HLEN]
Definition: amd8111e.c:86
#define MAX_TX_DESC_CNT
Definition: bnx2.h:3881
#define REG_WR16(bp, offset, val)
Definition: bnx2.h:4197
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition: timer.c:78
unsigned char * node_addr
Definition: nic.h:52
#define TX_BD_FLAGS_END
Definition: bnx2.h:161
uint32_t type
Operating system type.
Definition: ena.h:12
static struct bnx2 bnx2
Definition: bnx2.c:47
uint8_t size
Entry size (in 32-bit words)
Definition: ena.h:16
uint8_t data[48]
Additional event data.
Definition: ena.h:22
u8 src_addr[ETH_ALEN]
Definition: amd8111e.c:84
#define htons(value)
Definition: byteswap.h:135
u8 dst_addr[ETH_ALEN]
Definition: amd8111e.c:83
u32 tx_bd_haddr_hi
Definition: bnx2.h:151
void * memset(void *dest, int character, size_t len) __nonnull

References bnx2, bnx2_disable(), bnx2_init_board(), BNX2_L2CTX_TX_HOST_BIDX, BNX2_L2CTX_TX_HOST_BSEQ, bp, data, eth_frame::data, eth_frame::dst_addr, ETH_ALEN, ETH_FRAME_LEN, ETH_HLEN, frame, htons, MAX_TX_DESC_CNT, MB_TX_CID_ADDR, mdelay(), memcpy(), memset(), NEXT_TX_BD, nic::node_addr, PREV_TX_BD, printf(), REG_WR, REG_WR16, size, eth_frame::src_addr, TX_BD_FLAGS_END, TX_BD_FLAGS_START, tx_bd::tx_bd_haddr_hi, tx_bd::tx_bd_haddr_lo, tx_bd::tx_bd_mss_nbytes, tx_bd::tx_bd_vlan_tag_flags, TX_RING_IDX, type, eth_frame::type, virt_to_bus(), and wmb().

◆ bnx2_poll_link()

static int bnx2_poll_link ( struct bnx2 bp)
static

Definition at line 2419 of file bnx2.c.

2420 {
2421  u32 new_link_state, old_link_state, emac_status;
2422 
2423  new_link_state = bp->status_blk->status_attn_bits &
2425 
2426  old_link_state = bp->status_blk->status_attn_bits_ack &
2428 
2429  if (!new_link_state && !old_link_state) {
2430  /* For some reason the card doesn't always update the link
2431  * status bits properly. Kick the stupid thing and try again.
2432  */
2433  u32 bmsr;
2434 
2435  bnx2_read_phy(bp, MII_BMSR, &bmsr);
2436  bnx2_read_phy(bp, MII_BMSR, &bmsr);
2437 
2438  if ((bp->phy_flags & PHY_SERDES_FLAG) &&
2439  (CHIP_NUM(bp) == CHIP_NUM_5706)) {
2441  }
2442 
2443  new_link_state = bp->status_blk->status_attn_bits &
2445 
2446  old_link_state = bp->status_blk->status_attn_bits_ack &
2448 
2449  /* Okay, for some reason the above doesn't work with some
2450  * switches (like HP ProCurve). If the above doesn't work,
2451  * check the MAC directly to see if we have a link. Perhaps we
2452  * should always check the MAC instead probing the MII.
2453  */
2454  if (!new_link_state && !old_link_state) {
2455  emac_status = REG_RD(bp, BNX2_EMAC_STATUS);
2456  if (emac_status & BNX2_EMAC_STATUS_LINK_CHANGE) {
2457  /* Acknowledge the link change */
2459  } else if (emac_status & BNX2_EMAC_STATUS_LINK) {
2460  new_link_state = !old_link_state;
2461  }
2462  }
2463 
2464  }
2465 
2466  if (new_link_state != old_link_state) {
2467  if (new_link_state) {
2470  }
2471  else {
2474  }
2475 
2476  bnx2_set_link(bp);
2477 
2478  /* This is needed to take care of transient status
2479  * during link changes.
2480  */
2481 
2485 
2486  }
2487 
2488  return bp->link_up;
2489 }
static int bnx2_set_link(struct bnx2 *bp)
Definition: bnx2.c:659
#define REG_WR(bp, offset, val)
Definition: bnx2.h:4194
uint16_t bp
Definition: registers.h:23
#define BNX2_EMAC_STATUS
Definition: bnx2.h:1548
#define BNX2_PCICFG_STATUS_BIT_CLEAR_CMD
Definition: bnx2.h:517
static int bnx2_read_phy(struct bnx2 *bp, u32 reg, u32 *val)
Definition: bnx2.c:159
#define BNX2_EMAC_STATUS_LINK
Definition: bnx2.h:1549
#define STATUS_ATTN_BITS_LINK_STATE
Definition: bnx2.h:192
#define CHIP_NUM(bp)
Definition: bnx2.h:4071
#define BNX2_PCICFG_STATUS_BIT_SET_CMD
Definition: bnx2.h:516
#define PHY_SERDES_FLAG
Definition: bnx2.h:4061
#define BNX2_EMAC_STATUS_LINK_CHANGE
Definition: bnx2.h:1550
#define REG_RD(bp, offset)
Definition: bnx2.h:4191
#define BNX2_HC_COMMAND
Definition: bnx2.h:2841
#define BNX2_HC_COMMAND_COAL_NOW_WO_INT
Definition: bnx2.h:2845
#define CHIP_NUM_5706
Definition: bnx2.h:4072
#define MII_BMSR
Definition: atl1e.h:872
uint32_t u32
Definition: stdint.h:23

References BNX2_EMAC_STATUS, BNX2_EMAC_STATUS_LINK, BNX2_EMAC_STATUS_LINK_CHANGE, BNX2_HC_COMMAND, BNX2_HC_COMMAND_COAL_NOW_WO_INT, BNX2_PCICFG_STATUS_BIT_CLEAR_CMD, BNX2_PCICFG_STATUS_BIT_SET_CMD, bnx2_read_phy(), bnx2_set_link(), bp, CHIP_NUM, CHIP_NUM_5706, MII_BMSR, PHY_SERDES_FLAG, REG_RD, REG_WR, and STATUS_ATTN_BITS_LINK_STATE.

Referenced by bnx2_poll(), and bnx2_probe().

◆ bnx2_poll()

static int bnx2_poll ( struct nic nic,
int  retrieve 
)
static

Definition at line 2492 of file bnx2.c.

2493 {
2494  struct bnx2 *bp = &bnx2;
2495  struct rx_bd *cons_bd, *prod_bd;
2496  u16 hw_cons, sw_cons, sw_ring_cons, sw_prod, sw_ring_prod;
2497  struct l2_fhdr *rx_hdr;
2498  int result = 0;
2499  unsigned int len;
2500  unsigned char *data;
2501  u32 status;
2502 
2503 #if 0
2504  if ((bp->status_blk->status_idx == bp->last_status_idx) &&
2507 
2508  bp->last_status_idx = bp->status_blk->status_idx;
2512  bp->last_status_idx);
2513  return 0;
2514  }
2515 #endif
2516 
2517  if ((bp->status_blk->status_rx_quick_consumer_index0 != bp->rx_cons) && !retrieve)
2518  return 1;
2519 
2520  if (bp->status_blk->status_rx_quick_consumer_index0 != bp->rx_cons) {
2521 
2522  hw_cons = bp->hw_rx_cons = bp->status_blk->status_rx_quick_consumer_index0;
2523  if ((hw_cons & MAX_RX_DESC_CNT) == MAX_RX_DESC_CNT) {
2524  hw_cons++;
2525  }
2526  sw_cons = bp->rx_cons;
2527  sw_prod = bp->rx_prod;
2528 
2529  rmb();
2530  if (sw_cons != hw_cons) {
2531 
2532  sw_ring_cons = RX_RING_IDX(sw_cons);
2533  sw_ring_prod = RX_RING_IDX(sw_prod);
2534 
2535  data = bus_to_virt(bp->rx_desc_ring[sw_ring_cons].rx_bd_haddr_lo);
2536 
2537  rx_hdr = (struct l2_fhdr *)data;
2538  len = rx_hdr->l2_fhdr_pkt_len - 4;
2539  if ((len > (ETH_MAX_MTU + ETH_HLEN)) ||
2540  ((status = rx_hdr->l2_fhdr_status) &
2546  result = 0;
2547  }
2548  else
2549  {
2550  nic->packetlen = len;
2551  memcpy(nic->packet, data + bp->rx_offset, len);
2552  result = 1;
2553  }
2554 
2555  /* Reuse the buffer */
2556  bp->rx_prod_bseq += bp->rx_buf_use_size;
2557  if (sw_cons != sw_prod) {
2558  cons_bd = &bp->rx_desc_ring[sw_ring_cons];
2559  prod_bd = &bp->rx_desc_ring[sw_ring_prod];
2560  prod_bd->rx_bd_haddr_hi = 0; /* Etherboot runs under 4GB */
2561  prod_bd->rx_bd_haddr_lo = cons_bd->rx_bd_haddr_lo;
2562  }
2563 
2564  sw_cons = NEXT_RX_BD(sw_cons);
2565  sw_prod = NEXT_RX_BD(sw_prod);
2566 
2567  }
2568 
2569  bp->rx_cons = sw_cons;
2570  bp->rx_prod = sw_prod;
2571 
2573 
2574  REG_WR(bp, MB_RX_CID_ADDR + BNX2_L2CTX_HOST_BSEQ, bp->rx_prod_bseq);
2575 
2576  wmb();
2577 
2578  }
2579 
2580  bnx2_poll_link(bp);
2581 
2582 #if 0
2583  bp->last_status_idx = bp->status_blk->status_idx;
2584  rmb();
2585 
2589  bp->last_status_idx);
2590 
2592 #endif
2593 
2594  return result;
2595 }
uint16_t u16
Definition: stdint.h:21
#define L2_FHDR_ERRORS_ALIGNMENT
Definition: bnx2.h:382
#define BNX2_PCICFG_INT_ACK_CMD_INDEX_VALID
Definition: bnx2.h:512
wmb()
static const void const void void * result
Definition: crypto.h:335
static int bnx2_poll_link(struct bnx2 *bp)
Definition: bnx2.c:2419
Definition: bnx2.h:367
#define REG_WR(bp, offset, val)
Definition: bnx2.h:4194
u32 l2_fhdr_status
Definition: bnx2.h:368
uint16_t bp
Definition: registers.h:23
#define BNX2_PCICFG_MISC_STATUS
Definition: bnx2.h:466
#define ETH_MAX_MTU
Definition: if_ether.h:14
u32 rx_bd_haddr_lo
Definition: bnx2.h:176
#define L2_FHDR_ERRORS_BAD_CRC
Definition: bnx2.h:380
static __always_inline void * bus_to_virt(unsigned long bus_addr)
Convert bus address to a virtual address.
Definition: io.h:195
uint8_t status
Status.
Definition: ena.h:16
#define MB_RX_CID_ADDR
Definition: bnx2.h:3933
#define rmb()
Definition: io.h:484
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define BNX2_L2CTX_HOST_BDIDX
Definition: bnx2.h:442
#define MAX_RX_DESC_CNT
Definition: bnx2.h:3885
#define ETH_HLEN
Definition: if_ether.h:9
unsigned int packetlen
Definition: nic.h:54
Definition: bnx2.h:174
u16 l2_fhdr_pkt_len
Definition: bnx2.h:390
#define REG_RD(bp, offset)
Definition: bnx2.h:4191
u32 rx_bd_haddr_hi
Definition: bnx2.h:175
#define BNX2_PCICFG_INT_ACK_CMD_MASK_INT
Definition: bnx2.h:514
#define L2_FHDR_ERRORS_GIANT_FRAME
Definition: bnx2.h:384
Definition: bnx2.h:3991
#define RX_RING_IDX(x)
Definition: bnx2.h:3902
Definition: nic.h:49
#define BNX2_HC_COMMAND
Definition: bnx2.h:2841
#define BNX2_HC_COMMAND_COAL_NOW_WO_INT
Definition: bnx2.h:2845
unsigned char * packet
Definition: nic.h:53
#define REG_WR16(bp, offset, val)
Definition: bnx2.h:4197
#define L2_FHDR_ERRORS_TOO_SHORT
Definition: bnx2.h:383
uint32_t len
Length.
Definition: ena.h:14
static struct bnx2 bnx2
Definition: bnx2.c:47
#define BNX2_L2CTX_HOST_BSEQ
Definition: bnx2.h:443
#define BNX2_PCICFG_INT_ACK_CMD
Definition: bnx2.h:510
#define BNX2_PCICFG_MISC_STATUS_INTA_VALUE
Definition: bnx2.h:467
uint8_t data[48]
Additional event data.
Definition: ena.h:22
#define L2_FHDR_ERRORS_PHY_DECODE
Definition: bnx2.h:381
uint32_t u32
Definition: stdint.h:23
#define NEXT_RX_BD(x)
Definition: bnx2.h:3898

References bnx2, BNX2_HC_COMMAND, BNX2_HC_COMMAND_COAL_NOW_WO_INT, BNX2_L2CTX_HOST_BDIDX, BNX2_L2CTX_HOST_BSEQ, BNX2_PCICFG_INT_ACK_CMD, BNX2_PCICFG_INT_ACK_CMD_INDEX_VALID, BNX2_PCICFG_INT_ACK_CMD_MASK_INT, BNX2_PCICFG_MISC_STATUS, BNX2_PCICFG_MISC_STATUS_INTA_VALUE, bnx2_poll_link(), bp, bus_to_virt(), data, ETH_HLEN, ETH_MAX_MTU, L2_FHDR_ERRORS_ALIGNMENT, L2_FHDR_ERRORS_BAD_CRC, L2_FHDR_ERRORS_GIANT_FRAME, L2_FHDR_ERRORS_PHY_DECODE, L2_FHDR_ERRORS_TOO_SHORT, l2_fhdr::l2_fhdr_pkt_len, l2_fhdr::l2_fhdr_status, len, MAX_RX_DESC_CNT, MB_RX_CID_ADDR, memcpy(), NEXT_RX_BD, nic::packet, nic::packetlen, REG_RD, REG_WR, REG_WR16, result, rmb, rx_bd::rx_bd_haddr_hi, rx_bd::rx_bd_haddr_lo, RX_RING_IDX, status, and wmb().

◆ bnx2_irq()

static void bnx2_irq ( struct nic *nic  __unused,
irq_action_t action  __unused 
)
static

Definition at line 2598 of file bnx2.c.

2599 {
2600  switch ( action ) {
2601  case DISABLE: break;
2602  case ENABLE: break;
2603  case FORCE: break;
2604  }
2605 }
Definition: nic.h:35
Definition: nic.h:37
Definition: nic.h:36

References DISABLE, ENABLE, and FORCE.

◆ bnx2_probe()

static int bnx2_probe ( struct nic nic,
struct pci_device pdev 
)
static

Definition at line 2615 of file bnx2.c.

2616 {
2617  struct bnx2 *bp = &bnx2;
2618  int i, rc;
2619 
2620  memset(bp, 0, sizeof(*bp));
2621 
2622  rc = bnx2_init_board(pdev, nic);
2623  if (rc < 0) {
2624  return 0;
2625  }
2626 
2627  /*
2628  nic->disable = bnx2_disable;
2629  nic->transmit = bnx2_transmit;
2630  nic->poll = bnx2_poll;
2631  nic->irq = bnx2_irq;
2632  */
2633 
2635 
2636  memcpy(nic->node_addr, bp->mac_addr, ETH_ALEN);
2637  printf("Ethernet addr: %s\n", eth_ntoa( nic->node_addr ) );
2638  printf("Broadcom NetXtreme II (%c%d) PCI%s %s %dMHz\n",
2639  (int) ((CHIP_ID(bp) & 0xf000) >> 12) + 'A',
2640  (int) ((CHIP_ID(bp) & 0x0ff0) >> 4),
2641  ((bp->flags & PCIX_FLAG) ? "-X" : ""),
2642  ((bp->flags & PCI_32BIT_FLAG) ? "32-bit" : "64-bit"),
2643  bp->bus_speed_mhz);
2644 
2647 
2648  bnx2_alloc_mem(bp);
2649 
2650  rc = bnx2_init_nic(bp);
2651  if (rc) {
2652  return 0;
2653  }
2654 
2655  bnx2_poll_link(bp);
2656  for(i = 0; !bp->link_up && (i < VALID_LINK_TIMEOUT*100); i++) {
2657  mdelay(1);
2658  bnx2_poll_link(bp);
2659  }
2660 #if 1
2661  if (!bp->link_up){
2662  printf("Valid link not established\n");
2663  goto err_out_disable;
2664  }
2665 #endif
2666 
2667  return 1;
2668 
2669 err_out_disable:
2670  bnx2_disable(nic);
2671  return 0;
2672 }
#define PCIX_FLAG
Definition: bnx2.h:4005
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static void bnx2_disable(struct nic *nic __unused)
Definition: bnx2.c:1834
int printf(const char *fmt,...)
Write a formatted string to the console.
Definition: vsprintf.c:464
static int bnx2_poll_link(struct bnx2 *bp)
Definition: bnx2.c:2419
#define VALID_LINK_TIMEOUT
Definition: etherboot.h:34
uint16_t bp
Definition: registers.h:23
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define PCI_32BIT_FLAG
Definition: bnx2.h:4006
static int bnx2_set_power_state_0(struct bnx2 *bp)
Definition: bnx2.c:1628
static struct nic_operations bnx2_operations
Definition: bnx2.c:2607
static int bnx2_init_board(struct pci_device *pdev, struct nic *nic)
Definition: bnx2.c:2118
static int bnx2_init_nic(struct bnx2 *bp)
Definition: bnx2.c:2105
const char * eth_ntoa(const void *ll_addr)
Transcribe Ethernet address.
Definition: ethernet.c:175
struct pci_device * pdev
Definition: bnx2.h:3997
Definition: bnx2.h:3991
#define ETH_ALEN
Definition: if_ether.h:8
Definition: nic.h:49
static void bnx2_disable_int(struct bnx2 *bp)
Definition: bnx2.c:265
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition: timer.c:78
unsigned char * node_addr
Definition: nic.h:52
static struct bnx2 bnx2
Definition: bnx2.c:47
#define CHIP_ID(bp)
Definition: bnx2.h:4083
struct nic_operations * nic_op
Definition: nic.h:50
static int bnx2_alloc_mem(struct bnx2 *bp)
Definition: bnx2.c:274
void * memset(void *dest, int character, size_t len) __nonnull

References bnx2, bnx2_alloc_mem(), bnx2_disable(), bnx2_disable_int(), bnx2_init_board(), bnx2_init_nic(), bnx2_operations, bnx2_poll_link(), bnx2_set_power_state_0(), bp, CHIP_ID, ETH_ALEN, eth_ntoa(), mdelay(), memcpy(), memset(), nic::nic_op, nic::node_addr, PCI_32BIT_FLAG, PCIX_FLAG, bnx2::pdev, printf(), rc, and VALID_LINK_TIMEOUT.

◆ PCI_DRIVER()

PCI_DRIVER ( bnx2_driver  ,
bnx2_nics  ,
PCI_NO_CLASS   
)

◆ DRIVER()

DRIVER ( "BNX2"  ,
nic_driver  ,
pci_driver  ,
bnx2_driver  ,
bnx2_probe  ,
bnx2_disable   
)

Variable Documentation

◆ bnx2_bss

struct bss bnx2_bss
static

◆ bnx2

struct bnx2 bnx2
static

◆ flash_table

struct flash_spec flash_table[]
static

Definition at line 49 of file bnx2.c.

Referenced by bnx2_init_nvram().

◆ bnx2_operations

struct nic_operations bnx2_operations
static
Initial value:
= {
.connect = dummy_connect,
.poll = bnx2_poll,
.transmit = bnx2_transmit,
.irq = bnx2_irq,
}
static void bnx2_transmit(struct nic *nic, const char *dst_addr, unsigned int type, unsigned int size, const char *packet)
Definition: bnx2.c:2348
int dummy_connect(struct nic *nic __unused)
Definition: legacy.c:151
static void bnx2_irq(struct nic *nic __unused, irq_action_t action __unused)
Definition: bnx2.c:2598
static int bnx2_poll(struct nic *nic, int retrieve)
Definition: bnx2.c:2492

Definition at line 2607 of file bnx2.c.

Referenced by bnx2_probe().

◆ bnx2_nics

struct pci_device_id bnx2_nics[]
static
Initial value:
= {
PCI_ROM(0x14e4, 0x164a, "bnx2-5706", "Broadcom NetXtreme II BCM5706", 0),
PCI_ROM(0x14e4, 0x164c, "bnx2-5708", "Broadcom NetXtreme II BCM5708", 0),
PCI_ROM(0x14e4, 0x16aa, "bnx2-5706S", "Broadcom NetXtreme II BCM5706S", 0),
PCI_ROM(0x14e4, 0x16ac, "bnx2-5708S", "Broadcom NetXtreme II BCM5708S", 0),
}
#define PCI_ROM(_vendor, _device, _name, _description, _data)
Definition: pci.h:303

Definition at line 2674 of file bnx2.c.