iPXE
Macros | Typedefs | Functions | Variables
bnxt.c File Reference
#include <mii.h>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <byteswap.h>
#include <ipxe/pci.h>
#include <ipxe/iobuf.h>
#include <ipxe/timer.h>
#include <ipxe/malloc.h>
#include <ipxe/if_ether.h>
#include <ipxe/ethernet.h>
#include <ipxe/netdevice.h>
#include "bnxt.h"
#include "bnxt_dbg.h"

Go to the source code of this file.

Macros

#define bnxt_down_chip(bp)   bnxt_hwrm_run ( bring_down_chip, bp )
 
#define bnxt_up_chip(bp)   bnxt_hwrm_run ( bring_up_chip, bp )
 
#define bnxt_down_nic(bp)   bnxt_hwrm_run ( bring_down_nic, bp )
 
#define bnxt_up_nic(bp)   bnxt_hwrm_run ( bring_up_nic, bp )
 

Typedefs

typedef int(* hwrm_func_t) (struct bnxt *bp)
 

Functions

 FILE_LICENCE (GPL2_ONLY)
 
static void bnxt_service_cq (struct net_device *dev)
 
static void bnxt_tx_complete (struct net_device *dev, u16 hw_idx)
 
static void bnxt_adv_cq_index (struct bnxt *bp, u16 cnt)
 
static int bnxt_rx_complete (struct net_device *dev, struct rx_pkt_cmpl *rx)
 
void bnxt_link_evt (struct bnxt *bp, struct hwrm_async_event_cmpl *evt)
 
u8 bnxt_is_pci_vf (struct pci_device *pdev)
 Check if Virtual Function. More...
 
static void bnxt_down_pci (struct bnxt *bp)
 
static void * bnxt_pci_base (struct pci_device *pdev, unsigned int reg)
 
static int bnxt_get_pci_info (struct bnxt *bp)
 
static int bnxt_get_device_address (struct bnxt *bp)
 
static void bnxt_set_link (struct bnxt *bp)
 
static void thor_db (struct bnxt *bp, u32 idx, u32 xid, u32 flag)
 
static void bnxt_db_nq (struct bnxt *bp)
 
static void bnxt_db_cq (struct bnxt *bp)
 
static void bnxt_db_rx (struct bnxt *bp, u32 idx)
 
static void bnxt_db_tx (struct bnxt *bp, u32 idx)
 
void bnxt_add_vlan (struct io_buffer *iob, u16 vlan)
 
static u16 bnxt_get_pkt_vlan (char *src)
 
int bnxt_vlan_drop (struct bnxt *bp, u16 rx_vlan)
 
static u32 bnxt_tx_avail (struct bnxt *bp)
 
void bnxt_set_txq (struct bnxt *bp, int entry, dma_addr_t mapping, int len)
 
int bnxt_free_rx_iob (struct bnxt *bp)
 
static void bnxt_set_rx_desc (u8 *buf, struct io_buffer *iob, u16 cid, u32 idx)
 
static int bnxt_alloc_rx_iob (struct bnxt *bp, u16 cons_id, u16 iob_idx)
 
int bnxt_post_rx_buffers (struct bnxt *bp)
 
u8 bnxt_rx_drop (struct bnxt *bp, struct io_buffer *iob, struct rx_pkt_cmpl_hi *rx_cmp_hi, u16 rx_len)
 
void bnxt_rx_process (struct net_device *dev, struct bnxt *bp, struct rx_pkt_cmpl *rx_cmp, struct rx_pkt_cmpl_hi *rx_cmp_hi)
 
void bnxt_mm_init (struct bnxt *bp, const char *func)
 
void bnxt_mm_nic (struct bnxt *bp)
 
void bnxt_free_mem (struct bnxt *bp)
 
int bnxt_alloc_mem (struct bnxt *bp)
 
static void hwrm_init (struct bnxt *bp, struct input *req, u16 cmd, u16 len)
 
static void hwrm_write_req (struct bnxt *bp, void *req, u32 cnt)
 
static void short_hwrm_cmd_req (struct bnxt *bp, u16 len)
 
static int wait_resp (struct bnxt *bp, u32 tmo, u16 len, const char *func)
 
static int bnxt_hwrm_ver_get (struct bnxt *bp)
 
static int bnxt_hwrm_func_resource_qcaps (struct bnxt *bp)
 
static u32 bnxt_set_ring_info (struct bnxt *bp)
 
static void bnxt_hwrm_assign_resources (struct bnxt *bp)
 
static int bnxt_hwrm_func_qcaps_req (struct bnxt *bp)
 
static int bnxt_hwrm_func_qcfg_req (struct bnxt *bp)
 
static int bnxt_hwrm_func_reset_req (struct bnxt *bp)
 
static int bnxt_hwrm_func_cfg_req (struct bnxt *bp)
 
static int bnxt_hwrm_func_drv_rgtr (struct bnxt *bp)
 
static int bnxt_hwrm_func_drv_unrgtr (struct bnxt *bp)
 
static int bnxt_hwrm_set_async_event (struct bnxt *bp)
 
static int bnxt_hwrm_cfa_l2_filter_alloc (struct bnxt *bp)
 
static int bnxt_hwrm_cfa_l2_filter_free (struct bnxt *bp)
 
u32 set_rx_mask (u32 rx_mask)
 
static int bnxt_hwrm_set_rx_mask (struct bnxt *bp, u32 rx_mask)
 
static int bnxt_hwrm_port_phy_qcfg (struct bnxt *bp, u16 idx)
 
static int bnxt_hwrm_nvm_get_variable_req (struct bnxt *bp, u16 data_len, u16 option_num, u16 dimensions, u16 index_0)
 
static int bnxt_get_link_speed (struct bnxt *bp)
 
static int bnxt_get_vlan (struct bnxt *bp)
 
static int bnxt_hwrm_backing_store_qcfg (struct bnxt *bp)
 
static int bnxt_hwrm_backing_store_cfg (struct bnxt *bp)
 
static int bnxt_hwrm_queue_qportcfg (struct bnxt *bp)
 
static int bnxt_hwrm_port_mac_cfg (struct bnxt *bp)
 
static int bnxt_hwrm_port_phy_cfg (struct bnxt *bp)
 
static int bnxt_query_phy_link (struct bnxt *bp)
 
static int bnxt_get_phy_link (struct bnxt *bp)
 
static int bnxt_hwrm_stat_ctx_alloc (struct bnxt *bp)
 
static int bnxt_hwrm_stat_ctx_free (struct bnxt *bp)
 
static int bnxt_hwrm_ring_free_grp (struct bnxt *bp)
 
static int bnxt_hwrm_ring_alloc_grp (struct bnxt *bp)
 
int bnxt_hwrm_ring_free (struct bnxt *bp, u16 ring_id, u8 ring_type)
 
static int bnxt_hwrm_ring_alloc (struct bnxt *bp, u8 type)
 
static int bnxt_hwrm_ring_alloc_cq (struct bnxt *bp)
 
static int bnxt_hwrm_ring_alloc_tx (struct bnxt *bp)
 
static int bnxt_hwrm_ring_alloc_rx (struct bnxt *bp)
 
static int bnxt_hwrm_ring_free_cq (struct bnxt *bp)
 
static int bnxt_hwrm_ring_free_tx (struct bnxt *bp)
 
static int bnxt_hwrm_ring_free_rx (struct bnxt *bp)
 
static int bnxt_hwrm_ring_alloc_nq (struct bnxt *bp)
 
static int bnxt_hwrm_ring_free_nq (struct bnxt *bp)
 
static int bnxt_hwrm_vnic_alloc (struct bnxt *bp)
 
static int bnxt_hwrm_vnic_free (struct bnxt *bp)
 
static int bnxt_hwrm_vnic_cfg (struct bnxt *bp)
 
static int bnxt_set_rx_mask (struct bnxt *bp)
 
static int bnxt_reset_rx_mask (struct bnxt *bp)
 
int bnxt_hwrm_run (hwrm_func_t cmds[], struct bnxt *bp)
 
static int bnxt_open (struct net_device *dev)
 
static void bnxt_tx_adjust_pkt (struct bnxt *bp, struct io_buffer *iob)
 
static int bnxt_tx (struct net_device *dev, struct io_buffer *iob)
 
static void bnxt_adv_nq_index (struct bnxt *bp, u16 cnt)
 
static void bnxt_service_nq (struct net_device *dev)
 
static void bnxt_poll (struct net_device *dev)
 
static void bnxt_close (struct net_device *dev)
 
static int bnxt_init_one (struct pci_device *pci)
 
static void bnxt_remove_one (struct pci_device *pci)
 

Variables

static struct pci_device_id bnxt_nics []
 
hwrm_func_t bring_down_chip []
 
hwrm_func_t bring_down_nic []
 
hwrm_func_t bring_up_chip []
 
hwrm_func_t bring_up_nic []
 
static struct net_device_operations bnxt_netdev_ops
 
struct pci_driver bnxt_pci_driver __pci_driver
 

Macro Definition Documentation

◆ bnxt_down_chip

#define bnxt_down_chip (   bp)    bnxt_hwrm_run ( bring_down_chip, bp )

Definition at line 1923 of file bnxt.c.

◆ bnxt_up_chip

#define bnxt_up_chip (   bp)    bnxt_hwrm_run ( bring_up_chip, bp )

Definition at line 1924 of file bnxt.c.

◆ bnxt_down_nic

#define bnxt_down_nic (   bp)    bnxt_hwrm_run ( bring_down_nic, bp )

Definition at line 1925 of file bnxt.c.

◆ bnxt_up_nic

#define bnxt_up_nic (   bp)    bnxt_hwrm_run ( bring_up_nic, bp )

Definition at line 1926 of file bnxt.c.

Typedef Documentation

◆ hwrm_func_t

typedef int( * hwrm_func_t) (struct bnxt *bp)

Definition at line 1850 of file bnxt.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_ONLY  )

◆ bnxt_service_cq()

static void bnxt_service_cq ( struct net_device dev)
static

Definition at line 2010 of file bnxt.c.

2011 {
2012  struct bnxt *bp = netdev_priv ( dev );
2013  struct cmpl_base *cmp;
2014  struct tx_cmpl *tx;
2015  u16 old_cid = bp->cq.cons_id;
2016  int done = SERVICE_NEXT_CQ_BD;
2017  u32 cq_type;
2018 
2019  while ( done == SERVICE_NEXT_CQ_BD ) {
2020  cmp = ( struct cmpl_base * )BD_NOW ( bp->cq.bd_virt,
2021  bp->cq.cons_id,
2022  sizeof ( struct cmpl_base ) );
2023 
2024  if ( ( cmp->info3_v & CMPL_BASE_V ) ^ bp->cq.completion_bit )
2025  break;
2026 
2027  cq_type = cmp->type & CMPL_BASE_TYPE_MASK;
2028  dump_evt ( ( u8 * )cmp, cq_type, bp->cq.cons_id, 0 );
2029  dump_cq ( cmp, bp->cq.cons_id );
2030 
2031  switch ( cq_type ) {
2032  case CMPL_BASE_TYPE_TX_L2:
2033  tx = ( struct tx_cmpl * )cmp;
2034  bnxt_tx_complete ( dev, ( u16 )tx->opaque );
2035  /* Fall through */
2037  bnxt_adv_cq_index ( bp, 1 );
2038  break;
2039  case CMPL_BASE_TYPE_RX_L2:
2040  done = bnxt_rx_complete ( dev,
2041  ( struct rx_pkt_cmpl * )cmp );
2042  break;
2044  bnxt_link_evt ( bp,
2045  ( struct hwrm_async_event_cmpl * )cmp );
2046  bnxt_adv_cq_index ( bp, 1 );
2047  break;
2048  default:
2050  break;
2051  }
2052  }
2053 
2054  if ( bp->cq.cons_id != old_cid )
2055  bnxt_db_cq ( bp );
2056 }
#define dump_evt(cq, ty, id, ring)
Definition: bnxt_dbg.h:674
uint16_t u16
Definition: stdint.h:21
static void * netdev_priv(struct net_device *netdev)
Get driver private area for this network device.
Definition: netdevice.h:578
#define BD_NOW(bd, entry, len)
Definition: bnxt.h:159
#define CMPL_BASE_V
Definition: bnxt.h:509
#define dump_cq(cq, id)
Definition: bnxt_dbg.h:516
uint16_t bp
Definition: registers.h:23
void bnxt_link_evt(struct bnxt *bp, struct hwrm_async_event_cmpl *evt)
Definition: bnxt.c:1994
static void bnxt_adv_cq_index(struct bnxt *bp, u16 cnt)
Definition: bnxt.c:447
#define CMPL_BASE_TYPE_HWRM_ASYNC_EVENT
Definition: bnxt.h:499
u32 info3_v
Definition: bnxt.h:508
static void bnxt_tx_complete(struct net_device *dev, u16 hw_idx)
Definition: bnxt.c:308
#define CMPL_BASE_TYPE_RX_L2
Definition: bnxt.h:491
static int bnxt_rx_complete(struct net_device *dev, struct rx_pkt_cmpl *rx)
Definition: bnxt.c:484
#define CMPL_BASE_TYPE_TX_L2
Definition: bnxt.h:490
u16 type
Definition: bnxt.h:487
#define CMPL_BASE_TYPE_STAT_EJECT
Definition: bnxt.h:495
struct net_device * dev
Definition: bnxt.h:739
Definition: bnxt.h:446
#define NO_MORE_CQ_BD_TO_SERVICE
Definition: bnxt.h:178
#define SERVICE_NEXT_CQ_BD
Definition: bnxt.h:179
#define CMPL_BASE_TYPE_MASK
Definition: bnxt.h:488
struct bofm_section_header done
Definition: bofm_test.c:46
uint8_t u8
Definition: stdint.h:19
uint32_t u32
Definition: stdint.h:23
Definition: bnxt.h:721
u8 tx[WPA_TKIP_MIC_KEY_LEN]
MIC key for packets to the AP.
Definition: wpa.h:237
static void bnxt_db_cq(struct bnxt *bp)
Definition: bnxt.c:208

References BD_NOW, bnxt_adv_cq_index(), bnxt_db_cq(), bnxt_link_evt(), bnxt_rx_complete(), bnxt_tx_complete(), bp, CMPL_BASE_TYPE_HWRM_ASYNC_EVENT, CMPL_BASE_TYPE_MASK, CMPL_BASE_TYPE_RX_L2, CMPL_BASE_TYPE_STAT_EJECT, CMPL_BASE_TYPE_TX_L2, CMPL_BASE_V, bnxt::dev, done, dump_cq, dump_evt, cmpl_base::info3_v, netdev_priv(), NO_MORE_CQ_BD_TO_SERVICE, SERVICE_NEXT_CQ_BD, tx, and cmpl_base::type.

Referenced by bnxt_poll().

◆ bnxt_tx_complete()

static void bnxt_tx_complete ( struct net_device dev,
u16  hw_idx 
)
static

Definition at line 308 of file bnxt.c.

309 {
310  struct bnxt *bp = netdev_priv ( dev );
311  struct io_buffer *iob;
312 
313  iob = bp->tx.iob[hw_idx];
314  dbg_tx_done ( iob->data, iob_len ( iob ), hw_idx );
315  netdev_tx_complete ( dev, iob );
316  bp->tx.cons_id = NEXT_IDX ( hw_idx, bp->tx.ring_cnt );
317  bp->tx.cnt++;
318  dump_tx_stat ( bp );
319 }
static void * netdev_priv(struct net_device *netdev)
Get driver private area for this network device.
Definition: netdevice.h:578
static void netdev_tx_complete(struct net_device *netdev, struct io_buffer *iobuf)
Complete network transmission.
Definition: netdevice.h:756
uint16_t bp
Definition: registers.h:23
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:155
#define dump_tx_stat(bp)
Definition: bnxt_dbg.h:580
#define dbg_tx_done(pkt, len, idx)
Definition: bnxt_dbg.h:583
struct net_device * dev
Definition: bnxt.h:739
void * data
Start of data.
Definition: iobuf.h:48
#define NEXT_IDX(N, S)
Definition: bnxt.h:158
Definition: bnxt.h:721
A persistent I/O buffer.
Definition: iobuf.h:33

References bp, io_buffer::data, dbg_tx_done, bnxt::dev, dump_tx_stat, iob_len(), netdev_priv(), netdev_tx_complete(), and NEXT_IDX.

Referenced by bnxt_service_cq().

◆ bnxt_adv_cq_index()

static void bnxt_adv_cq_index ( struct bnxt bp,
u16  cnt 
)
static

Definition at line 447 of file bnxt.c.

448 {
449  u16 cons_id;
450 
451  cons_id = bp->cq.cons_id + cnt;
452  if ( cons_id >= MAX_CQ_DESC_CNT ) {
453  /* Toggle completion bit when the ring wraps. */
454  bp->cq.completion_bit ^= 1;
455  cons_id = cons_id - MAX_CQ_DESC_CNT;
456  }
457  bp->cq.cons_id = cons_id;
458 }
uint16_t u16
Definition: stdint.h:21
uint16_t bp
Definition: registers.h:23
#define MAX_CQ_DESC_CNT
Definition: bnxt.h:146

References bp, and MAX_CQ_DESC_CNT.

Referenced by bnxt_rx_process(), and bnxt_service_cq().

◆ bnxt_rx_complete()

static int bnxt_rx_complete ( struct net_device dev,
struct rx_pkt_cmpl rx 
)
static

Definition at line 484 of file bnxt.c.

486 {
487  struct bnxt *bp = netdev_priv ( dev );
488  struct rx_pkt_cmpl_hi *rx_cmp_hi;
489  u8 cmpl_bit = bp->cq.completion_bit;
490 
491  if ( bp->cq.cons_id == ( bp->cq.ring_cnt - 1 ) ) {
492  rx_cmp_hi = ( struct rx_pkt_cmpl_hi * )bp->cq.bd_virt;
493  cmpl_bit ^= 0x1; /* Ring has wrapped. */
494  } else
495  rx_cmp_hi = ( struct rx_pkt_cmpl_hi * ) ( rx_cmp+1 );
496 
497  if ( ! ( ( rx_cmp_hi->errors_v2 & RX_PKT_CMPL_V2 ) ^ cmpl_bit ) ) {
498  bnxt_rx_process ( dev, bp, rx_cmp, rx_cmp_hi );
499  return SERVICE_NEXT_CQ_BD;
500  } else
502 }
static void * netdev_priv(struct net_device *netdev)
Get driver private area for this network device.
Definition: netdevice.h:578
uint16_t bp
Definition: registers.h:23
void bnxt_rx_process(struct net_device *dev, struct bnxt *bp, struct rx_pkt_cmpl *rx_cmp, struct rx_pkt_cmpl_hi *rx_cmp_hi)
Definition: bnxt.c:460
struct net_device * dev
Definition: bnxt.h:739
#define NO_MORE_CQ_BD_TO_SERVICE
Definition: bnxt.h:178
u16 errors_v2
Definition: bnxt.h:631
#define SERVICE_NEXT_CQ_BD
Definition: bnxt.h:179
#define RX_PKT_CMPL_V2
Definition: bnxt.h:632
uint8_t u8
Definition: stdint.h:19
Definition: bnxt.h:721

References bnxt_rx_process(), bp, bnxt::dev, rx_pkt_cmpl_hi::errors_v2, netdev_priv(), NO_MORE_CQ_BD_TO_SERVICE, RX_PKT_CMPL_V2, and SERVICE_NEXT_CQ_BD.

Referenced by bnxt_service_cq().

◆ bnxt_link_evt()

void bnxt_link_evt ( struct bnxt bp,
struct hwrm_async_event_cmpl evt 
)

Definition at line 1994 of file bnxt.c.

1995 {
1996  switch ( evt->event_id ) {
1998  if ( evt->event_data1 & 0x01 )
1999  bp->link_status = STATUS_LINK_ACTIVE;
2000  else
2001  bp->link_status = STATUS_LINK_DOWN;
2002  bnxt_set_link ( bp );
2003  dbg_link_status ( bp );
2004  break;
2005  default:
2006  break;
2007  }
2008 }
uint16_t bp
Definition: registers.h:23
#define ASYNC_EVENT_CMPL_EVENT_ID_LINK_STATUS_CHANGE
Definition: bnxt_hsi.h:553
#define STATUS_LINK_DOWN
Definition: bnxt.h:63
#define STATUS_LINK_ACTIVE
Definition: bnxt.h:62
static void bnxt_set_link(struct bnxt *bp)
Definition: bnxt.c:176
#define dbg_link_status(bp)
Definition: bnxt_dbg.h:675

References ASYNC_EVENT_CMPL_EVENT_ID_LINK_STATUS_CHANGE, bnxt_set_link(), bp, dbg_link_status, hwrm_async_event_cmpl::event_data1, hwrm_async_event_cmpl::event_id, STATUS_LINK_ACTIVE, and STATUS_LINK_DOWN.

Referenced by bnxt_service_cq(), and bnxt_service_nq().

◆ bnxt_is_pci_vf()

u8 bnxt_is_pci_vf ( struct pci_device pdev)

Check if Virtual Function.

Definition at line 90 of file bnxt.c.

91 {
92  if ( FLAG_TEST ( pdev->id->driver_data, BNXT_FLAG_PCI_VF ) ) {
93  return 1;
94  }
95  return 0;
96 }
unsigned long driver_data
Arbitrary driver data.
Definition: pci.h:178
#define FLAG_TEST(f, b)
Definition: bnxt.h:46
struct pci_device_id * id
Driver device ID.
Definition: pci.h:243
#define BNXT_FLAG_PCI_VF
Definition: bnxt.h:54

References BNXT_FLAG_PCI_VF, pci_device_id::driver_data, FLAG_TEST, and pci_device::id.

Referenced by bnxt_get_pci_info().

◆ bnxt_down_pci()

static void bnxt_down_pci ( struct bnxt bp)
static

Definition at line 98 of file bnxt.c.

99 {
100  DBGP ( "%s\n", __func__ );
101  if ( bp->bar2 ) {
102  iounmap ( bp->bar2 );
103  bp->bar2 = NULL;
104  }
105  if ( bp->bar1 ) {
106  iounmap ( bp->bar1 );
107  bp->bar1 = NULL;
108  }
109  if ( bp->bar0 ) {
110  iounmap ( bp->bar0 );
111  bp->bar0 = NULL;
112  }
113 }
uint16_t bp
Definition: registers.h:23
#define DBGP(...)
Definition: compiler.h:532
void iounmap(volatile const void *io_addr)
Unmap I/O address.
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References bp, DBGP, iounmap(), and NULL.

Referenced by bnxt_close(), bnxt_init_one(), and bnxt_remove_one().

◆ bnxt_pci_base()

static void* bnxt_pci_base ( struct pci_device pdev,
unsigned int  reg 
)
static

Definition at line 115 of file bnxt.c.

116 {
117  unsigned long reg_base, reg_size;
118 
119  reg_base = pci_bar_start ( pdev, reg );
120  reg_size = pci_bar_size ( pdev, reg );
121  return pci_ioremap ( pdev, reg_base, reg_size );
122 }
static unsigned int unsigned int reg
Definition: myson.h:162
unsigned long pci_bar_start(struct pci_device *pci, unsigned int reg)
Find the start of a PCI BAR.
Definition: pci.c:96
unsigned long pci_bar_size(struct pci_device *pci, unsigned int reg)
Find the size of a PCI BAR.
Definition: pciextra.c:92
void * pci_ioremap(struct pci_device *pci, unsigned long bus_addr, size_t len)
Map PCI bus address as an I/O address.

References pci_bar_size(), pci_bar_start(), pci_ioremap(), and reg.

Referenced by bnxt_close(), and bnxt_get_pci_info().

◆ bnxt_get_pci_info()

static int bnxt_get_pci_info ( struct bnxt bp)
static

Definition at line 124 of file bnxt.c.

125 {
126  u16 cmd_reg = 0;
127 
128  DBGP ( "%s\n", __func__ );
129  /* Disable Interrupt */
130  pci_read_word16 ( bp->pdev, PCI_COMMAND, &bp->cmd_reg );
131  cmd_reg = bp->cmd_reg | PCI_COMMAND_INTX_DISABLE;
132  pci_write_word ( bp->pdev, PCI_COMMAND, cmd_reg );
133  pci_read_word16 ( bp->pdev, PCI_COMMAND, &cmd_reg );
134 
135  /* SSVID */
136  pci_read_word16 ( bp->pdev,
138  &bp->subsystem_vendor );
139 
140  /* SSDID */
141  pci_read_word16 ( bp->pdev,
143  &bp->subsystem_device );
144 
145  /* Function Number */
146  pci_read_byte ( bp->pdev,
148  &bp->pf_num );
149 
150  /* Get Bar Address */
151  bp->bar0 = bnxt_pci_base ( bp->pdev, PCI_BASE_ADDRESS_0 );
152  bp->bar1 = bnxt_pci_base ( bp->pdev, PCI_BASE_ADDRESS_2 );
153  bp->bar2 = bnxt_pci_base ( bp->pdev, PCI_BASE_ADDRESS_4 );
154 
155  /* Virtual function */
156  bp->vf = bnxt_is_pci_vf ( bp->pdev );
157 
158  dbg_pci ( bp, __func__, cmd_reg );
159  return STATUS_SUCCESS;
160 }
uint16_t u16
Definition: stdint.h:21
#define STATUS_SUCCESS
Definition: bnxt.h:58
#define pci_read_byte
Definition: bnxt.h:828
#define PCI_COMMAND_INTX_DISABLE
Interrupt disable.
Definition: pci.h:32
static void * bnxt_pci_base(struct pci_device *pdev, unsigned int reg)
Definition: bnxt.c:115
uint16_t bp
Definition: registers.h:23
#define PCI_BASE_ADDRESS_0
Definition: pci.h:62
#define PCI_COMMAND
PCI command.
Definition: pci.h:25
#define PCI_SUBSYSTEM_ID
PCI subsystem ID.
Definition: pci.h:78
#define dbg_pci(bp, func, creg)
Definition: bnxt_dbg.h:140
#define pci_write_word
Definition: bnxt.h:830
#define DBGP(...)
Definition: compiler.h:532
#define PCI_BASE_ADDRESS_2
Definition: pci.h:64
#define pci_read_word16
Definition: bnxt.h:829
u8 bnxt_is_pci_vf(struct pci_device *pdev)
Check if Virtual Function.
Definition: bnxt.c:90
#define PCICFG_ME_REGISTER
Definition: bnxt.h:122
#define PCI_SUBSYSTEM_VENDOR_ID
PCI subsystem vendor ID.
Definition: pci.h:75
#define PCI_BASE_ADDRESS_4
Definition: pci.h:66

References bnxt_is_pci_vf(), bnxt_pci_base(), bp, dbg_pci, DBGP, PCI_BASE_ADDRESS_0, PCI_BASE_ADDRESS_2, PCI_BASE_ADDRESS_4, PCI_COMMAND, PCI_COMMAND_INTX_DISABLE, pci_read_byte, pci_read_word16, PCI_SUBSYSTEM_ID, PCI_SUBSYSTEM_VENDOR_ID, pci_write_word, PCICFG_ME_REGISTER, and STATUS_SUCCESS.

Referenced by bnxt_init_one().

◆ bnxt_get_device_address()

static int bnxt_get_device_address ( struct bnxt bp)
static

Definition at line 162 of file bnxt.c.

163 {
164  struct net_device *dev = bp->dev;
165 
166  DBGP ( "%s\n", __func__ );
167  memcpy ( &dev->hw_addr[0], ( char * )&bp->mac_addr[0], ETH_ALEN );
168  if ( !is_valid_ether_addr ( &dev->hw_addr[0] ) ) {
169  DBGP ( "- %s ( ): Failed\n", __func__ );
170  return -EINVAL;
171  }
172 
173  return STATUS_SUCCESS;
174 }
#define EINVAL
Invalid argument.
Definition: errno.h:428
#define STATUS_SUCCESS
Definition: bnxt.h:58
uint16_t bp
Definition: registers.h:23
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define DBGP(...)
Definition: compiler.h:532
A network device.
Definition: netdevice.h:352
#define ETH_ALEN
Definition: if_ether.h:8
static int is_valid_ether_addr(const void *addr)
Check if Ethernet address is valid.
Definition: ethernet.h:77
struct device * dev
Underlying hardware device.
Definition: netdevice.h:364

References bp, DBGP, net_device::dev, EINVAL, ETH_ALEN, is_valid_ether_addr(), memcpy(), and STATUS_SUCCESS.

◆ bnxt_set_link()

static void bnxt_set_link ( struct bnxt bp)
static

Definition at line 176 of file bnxt.c.

177 {
178  if ( bp->link_status == STATUS_LINK_ACTIVE )
179  netdev_link_up ( bp->dev );
180  else
181  netdev_link_down ( bp->dev );
182 }
uint16_t bp
Definition: registers.h:23
void netdev_link_down(struct net_device *netdev)
Mark network device as having link down.
Definition: netdevice.c:183
#define STATUS_LINK_ACTIVE
Definition: bnxt.h:62
static void netdev_link_up(struct net_device *netdev)
Mark network device as having link up.
Definition: netdevice.h:778

References bp, netdev_link_down(), netdev_link_up(), and STATUS_LINK_ACTIVE.

Referenced by bnxt_get_phy_link(), and bnxt_link_evt().

◆ thor_db()

static void thor_db ( struct bnxt bp,
u32  idx,
u32  xid,
u32  flag 
)
static

Definition at line 184 of file bnxt.c.

185 {
186  void *off;
187  u64 val;
188 
189  if ( bp->vf )
190  off = ( void * ) ( bp->bar1 + DB_OFFSET_VF );
191  else
192  off = ( void * ) ( bp->bar1 + DB_OFFSET_PF );
193 
194  val = ( ( u64 )DBC_MSG_XID ( xid, flag ) << 32 ) |
195  ( u64 )DBC_MSG_IDX ( idx );
196  write64 ( val, off );
197 }
#define DB_OFFSET_VF
Definition: bnxt.h:187
#define DBC_MSG_IDX(idx)
Definition: bnxt.h:188
uint16_t bp
Definition: registers.h:23
#define write64
Definition: bnxt.h:827
#define DB_OFFSET_PF
Definition: bnxt.h:186
uint64_t u64
Definition: stdint.h:25
void __asmcall int val
Definition: setjmp.h:28
uint16_t flag
Flag number.
Definition: hyperv.h:14
#define DBC_MSG_XID(xid, flg)
Definition: bnxt.h:190

References bp, DB_OFFSET_PF, DB_OFFSET_VF, DBC_MSG_IDX, DBC_MSG_XID, flag, val, and write64.

Referenced by bnxt_db_cq(), bnxt_db_nq(), bnxt_db_rx(), and bnxt_db_tx().

◆ bnxt_db_nq()

static void bnxt_db_nq ( struct bnxt bp)
static

Definition at line 199 of file bnxt.c.

200 {
201  if ( bp->thor )
202  thor_db ( bp, ( u32 )bp->nq.cons_id,
203  ( u32 )bp->nq_ring_id, DBC_DBC_TYPE_NQ_ARM );
204  else
205  write32 ( CMPL_DOORBELL_KEY_CMPL, ( bp->bar1 + 0 ) );
206 }
#define write32
Definition: bnxt.h:826
uint16_t bp
Definition: registers.h:23
static void thor_db(struct bnxt *bp, u32 idx, u32 xid, u32 flag)
Definition: bnxt.c:184
#define CMPL_DOORBELL_KEY_CMPL
Definition: bnxt.h:381
#define DBC_DBC_TYPE_NQ_ARM
Definition: bnxt.h:413
uint32_t u32
Definition: stdint.h:23

References bp, CMPL_DOORBELL_KEY_CMPL, DBC_DBC_TYPE_NQ_ARM, thor_db(), and write32.

Referenced by bnxt_service_nq().

◆ bnxt_db_cq()

static void bnxt_db_cq ( struct bnxt bp)
static

Definition at line 208 of file bnxt.c.

209 {
210  if ( bp->thor )
211  thor_db ( bp, ( u32 )bp->cq.cons_id,
212  ( u32 )bp->cq_ring_id, DBC_DBC_TYPE_CQ_ARMALL );
213  else
214  write32 ( CQ_DOORBELL_KEY_IDX ( bp->cq.cons_id ),
215  ( bp->bar1 + 0 ) );
216 }
#define CQ_DOORBELL_KEY_IDX(a)
Definition: bnxt.h:838
#define write32
Definition: bnxt.h:826
uint16_t bp
Definition: registers.h:23
#define DBC_DBC_TYPE_CQ_ARMALL
Definition: bnxt.h:408
static void thor_db(struct bnxt *bp, u32 idx, u32 xid, u32 flag)
Definition: bnxt.c:184
uint32_t u32
Definition: stdint.h:23

References bp, CQ_DOORBELL_KEY_IDX, DBC_DBC_TYPE_CQ_ARMALL, thor_db(), and write32.

Referenced by bnxt_service_cq().

◆ bnxt_db_rx()

static void bnxt_db_rx ( struct bnxt bp,
u32  idx 
)
static

Definition at line 218 of file bnxt.c.

219 {
220  if ( bp->thor )
221  thor_db ( bp, idx, ( u32 )bp->rx_ring_id, DBC_DBC_TYPE_SRQ );
222  else
223  write32 ( RX_DOORBELL_KEY_RX | idx, ( bp->bar1 + 0 ) );
224 }
#define write32
Definition: bnxt.h:826
uint16_t bp
Definition: registers.h:23
#define DBC_DBC_TYPE_SRQ
Definition: bnxt.h:404
static void thor_db(struct bnxt *bp, u32 idx, u32 xid, u32 flag)
Definition: bnxt.c:184
#define RX_DOORBELL_KEY_RX
Definition: bnxt.h:369
uint32_t u32
Definition: stdint.h:23

References bp, DBC_DBC_TYPE_SRQ, RX_DOORBELL_KEY_RX, thor_db(), and write32.

Referenced by bnxt_post_rx_buffers().

◆ bnxt_db_tx()

static void bnxt_db_tx ( struct bnxt bp,
u32  idx 
)
static

Definition at line 226 of file bnxt.c.

227 {
228  if ( bp->thor )
229  thor_db ( bp, idx, ( u32 )bp->tx_ring_id, DBC_DBC_TYPE_SQ );
230  else
231  write32 ( ( u32 ) ( TX_DOORBELL_KEY_TX | idx ),
232  ( bp->bar1 + 0 ) );
233 }
#define write32
Definition: bnxt.h:826
uint16_t bp
Definition: registers.h:23
static void thor_db(struct bnxt *bp, u32 idx, u32 xid, u32 flag)
Definition: bnxt.c:184
#define DBC_DBC_TYPE_SQ
Definition: bnxt.h:402
#define TX_DOORBELL_KEY_TX
Definition: bnxt.h:359
uint32_t u32
Definition: stdint.h:23

References bp, DBC_DBC_TYPE_SQ, thor_db(), TX_DOORBELL_KEY_TX, and write32.

Referenced by bnxt_tx().

◆ bnxt_add_vlan()

void bnxt_add_vlan ( struct io_buffer iob,
u16  vlan 
)

Definition at line 235 of file bnxt.c.

236 {
237  char *src = ( char * )iob->data;
238  u16 len = iob_len ( iob );
239 
240  memmove ( ( char * )&src[MAC_HDR_SIZE + VLAN_HDR_SIZE],
241  ( char * )&src[MAC_HDR_SIZE],
242  ( len - MAC_HDR_SIZE ) );
243 
244  * ( u16 * ) ( &src[MAC_HDR_SIZE] ) = BYTE_SWAP_S ( ETHERTYPE_VLAN );
245  * ( u16 * ) ( &src[MAC_HDR_SIZE + 2] ) = BYTE_SWAP_S ( vlan );
246  iob_put ( iob, VLAN_HDR_SIZE );
247 }
uint16_t u16
Definition: stdint.h:21
#define iob_put(iobuf, len)
Definition: iobuf.h:120
#define MAC_HDR_SIZE
Definition: bnxt.h:180
#define VLAN_HDR_SIZE
Definition: bnxt.h:181
#define BYTE_SWAP_S(w)
Definition: bnxt.h:183
static __always_inline void off_t userptr_t src
Definition: efi_uaccess.h:66
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:155
void * memmove(void *dest, const void *src, size_t len) __nonnull
#define ETHERTYPE_VLAN
Definition: bnxt.h:182
uint32_t len
Length.
Definition: ena.h:14
void * data
Start of data.
Definition: iobuf.h:48

References BYTE_SWAP_S, io_buffer::data, ETHERTYPE_VLAN, iob_len(), iob_put, len, MAC_HDR_SIZE, memmove(), src, and VLAN_HDR_SIZE.

Referenced by bnxt_rx_drop(), and bnxt_tx_adjust_pkt().

◆ bnxt_get_pkt_vlan()

static u16 bnxt_get_pkt_vlan ( char *  src)
static

Definition at line 249 of file bnxt.c.

250 {
251  if ( * ( ( u16 * )&src[MAC_HDR_SIZE] ) == BYTE_SWAP_S ( ETHERTYPE_VLAN ) )
252  return BYTE_SWAP_S ( * ( ( u16 * )&src[MAC_HDR_SIZE + 2] ) );
253  return 0;
254 }
uint16_t u16
Definition: stdint.h:21
#define MAC_HDR_SIZE
Definition: bnxt.h:180
#define BYTE_SWAP_S(w)
Definition: bnxt.h:183
static __always_inline void off_t userptr_t src
Definition: efi_uaccess.h:66
#define ETHERTYPE_VLAN
Definition: bnxt.h:182

References BYTE_SWAP_S, ETHERTYPE_VLAN, MAC_HDR_SIZE, and src.

Referenced by bnxt_tx_adjust_pkt().

◆ bnxt_vlan_drop()

int bnxt_vlan_drop ( struct bnxt bp,
u16  rx_vlan 
)

Definition at line 256 of file bnxt.c.

257 {
258  if ( rx_vlan ) {
259  if ( bp->vlan_tx ) {
260  if ( rx_vlan == bp->vlan_tx )
261  return 0;
262  } else {
263  if ( rx_vlan == bp->vlan_id )
264  return 0;
265  if ( rx_vlan && !bp->vlan_id )
266  return 0;
267  }
268  } else {
269  if ( !bp->vlan_tx && !bp->vlan_id )
270  return 0;
271  }
272 
273  return 1;
274 }
uint16_t bp
Definition: registers.h:23

References bp.

Referenced by bnxt_rx_drop().

◆ bnxt_tx_avail()

static u32 bnxt_tx_avail ( struct bnxt bp)
inlinestatic

Definition at line 276 of file bnxt.c.

277 {
278  u32 avail;
279  u32 use;
280 
281  barrier ( );
282  avail = TX_AVAIL ( bp->tx.ring_cnt );
283  use = TX_IN_USE ( bp->tx.prod_id, bp->tx.cons_id, bp->tx.ring_cnt );
284  dbg_tx_avail ( bp, avail, use );
285  return ( avail-use );
286 }
#define dbg_tx_avail(bp, a, u)
Definition: bnxt_dbg.h:577
uint16_t bp
Definition: registers.h:23
#define TX_AVAIL(r)
Definition: bnxt.h:174
#define TX_IN_USE(a, b, c)
Definition: bnxt.h:175
#define barrier()
Optimisation barrier.
Definition: compiler.h:655
uint32_t u32
Definition: stdint.h:23

References barrier, bp, dbg_tx_avail, TX_AVAIL, and TX_IN_USE.

Referenced by bnxt_tx().

◆ bnxt_set_txq()

void bnxt_set_txq ( struct bnxt bp,
int  entry,
dma_addr_t  mapping,
int  len 
)

Definition at line 288 of file bnxt.c.

289 {
290  struct tx_bd_short *prod_bd;
291 
292  prod_bd = ( struct tx_bd_short * )BD_NOW ( bp->tx.bd_virt,
293  entry, sizeof ( struct tx_bd_short ) );
294  if ( len < 512 )
296  else if ( len < 1024 )
298  else if ( len < 2048 )
300  else
302  prod_bd->flags_type |= TX_BD_FLAGS;
303  prod_bd->dma.addr = mapping;
304  prod_bd->len = len;
305  prod_bd->opaque = ( u32 )entry;
306 }
#define BD_NOW(bd, entry, len)
Definition: bnxt.h:159
#define TX_BD_FLAGS
Definition: bnxt.h:842
uint16_t bp
Definition: registers.h:23
u16 len
Definition: bnxt.h:441
dma_addr_t addr
Definition: bnxt.h:31
u32 opaque
Definition: bnxt.h:442
#define u32
Definition: vga.h:21
#define TX_BD_SHORT_FLAGS_LHINT_LT512
Definition: bnxt.h:435
#define TX_BD_SHORT_FLAGS_LHINT_LT1K
Definition: bnxt.h:436
union aes_table_entry entry[256]
Table entries, indexed by S(N)
Definition: aes.c:26
#define TX_BD_SHORT_FLAGS_LHINT_GTE2K
Definition: bnxt.h:438
#define TX_BD_SHORT_FLAGS_LHINT_LT2K
Definition: bnxt.h:437
u16 flags_type
Definition: bnxt.h:422
uint32_t len
Length.
Definition: ena.h:14
union dma_addr64_t dma
Definition: bnxt.h:443

References dma_addr64_t::addr, BD_NOW, bp, tx_bd_short::dma, entry, tx_bd_short::flags_type, len, tx_bd_short::len, tx_bd_short::opaque, TX_BD_FLAGS, TX_BD_SHORT_FLAGS_LHINT_GTE2K, TX_BD_SHORT_FLAGS_LHINT_LT1K, TX_BD_SHORT_FLAGS_LHINT_LT2K, TX_BD_SHORT_FLAGS_LHINT_LT512, and u32.

Referenced by bnxt_tx().

◆ bnxt_free_rx_iob()

int bnxt_free_rx_iob ( struct bnxt bp)

Definition at line 321 of file bnxt.c.

322 {
323  unsigned int i;
324 
325  DBGP ( "%s\n", __func__ );
326  if ( ! ( FLAG_TEST ( bp->flag_hwrm, VALID_RX_IOB ) ) )
327  return STATUS_SUCCESS;
328 
329  for ( i = 0; i < bp->rx.buf_cnt; i++ ) {
330  if ( bp->rx.iob[i] ) {
331  free_iob ( bp->rx.iob[i] );
332  bp->rx.iob[i] = NULL;
333  }
334  }
335  bp->rx.iob_cnt = 0;
336 
337  FLAG_RESET ( bp->flag_hwrm, VALID_RX_IOB );
338  return STATUS_SUCCESS;
339 }
#define STATUS_SUCCESS
Definition: bnxt.h:58
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
Definition: iobuf.c:146
#define FLAG_TEST(f, b)
Definition: bnxt.h:46
uint16_t bp
Definition: registers.h:23
#define DBGP(...)
Definition: compiler.h:532
#define FLAG_RESET(f, b)
Definition: bnxt.h:47
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
#define VALID_RX_IOB
Definition: bnxt.h:717

References bp, DBGP, FLAG_RESET, FLAG_TEST, free_iob(), NULL, STATUS_SUCCESS, and VALID_RX_IOB.

◆ bnxt_set_rx_desc()

static void bnxt_set_rx_desc ( u8 buf,
struct io_buffer iob,
u16  cid,
u32  idx 
)
static

Definition at line 341 of file bnxt.c.

343 {
344  struct rx_prod_pkt_bd *desc;
345  u16 off = cid * sizeof ( struct rx_prod_pkt_bd );
346 
347  desc = ( struct rx_prod_pkt_bd * )&buf[off];
350  desc->opaque = idx;
351  desc->dma.addr = virt_to_bus ( iob->data );
352 }
uint16_t u16
Definition: stdint.h:21
dma_addr_t addr
Definition: bnxt.h:31
#define RX_PROD_PKT_BD_TYPE_RX_PROD_PKT
Definition: bnxt.h:682
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition: io.h:183
u32 opaque
Definition: bnxt.h:691
void * data
Start of data.
Definition: iobuf.h:48
#define MAX_ETHERNET_PACKET_BUFFER_SIZE
Definition: bnxt.h:137
union dma_addr64_t dma
Definition: bnxt.h:692
u16 flags_type
Definition: bnxt.h:679

References dma_addr64_t::addr, io_buffer::data, rx_prod_pkt_bd::dma, rx_prod_pkt_bd::flags_type, rx_prod_pkt_bd::len, MAX_ETHERNET_PACKET_BUFFER_SIZE, rx_prod_pkt_bd::opaque, RX_PROD_PKT_BD_TYPE_RX_PROD_PKT, and virt_to_bus().

Referenced by bnxt_alloc_rx_iob().

◆ bnxt_alloc_rx_iob()

static int bnxt_alloc_rx_iob ( struct bnxt bp,
u16  cons_id,
u16  iob_idx 
)
static

Definition at line 354 of file bnxt.c.

355 {
356  struct io_buffer *iob;
357 
358  iob = alloc_iob ( BNXT_RX_STD_DMA_SZ );
359  if ( !iob ) {
360  DBGP ( "- %s ( ): alloc_iob Failed\n", __func__ );
361  return -ENOMEM;
362  }
363 
364  dbg_alloc_rx_iob ( iob, iob_idx, cons_id );
365  bnxt_set_rx_desc ( ( u8 * )bp->rx.bd_virt, iob, cons_id,
366  ( u32 ) iob_idx );
367  bp->rx.iob[iob_idx] = iob;
368  return 0;
369 }
#define dbg_alloc_rx_iob(iob, id, cid)
Definition: bnxt_dbg.h:470
uint16_t bp
Definition: registers.h:23
#define BNXT_RX_STD_DMA_SZ
Definition: bnxt.h:157
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
Definition: iobuf.c:129
#define ENOMEM
Not enough space.
Definition: errno.h:534
#define DBGP(...)
Definition: compiler.h:532
static void bnxt_set_rx_desc(u8 *buf, struct io_buffer *iob, u16 cid, u32 idx)
Definition: bnxt.c:341
uint8_t u8
Definition: stdint.h:19
uint32_t u32
Definition: stdint.h:23
A persistent I/O buffer.
Definition: iobuf.h:33

References alloc_iob(), BNXT_RX_STD_DMA_SZ, bnxt_set_rx_desc(), bp, dbg_alloc_rx_iob, DBGP, and ENOMEM.

Referenced by bnxt_post_rx_buffers().

◆ bnxt_post_rx_buffers()

int bnxt_post_rx_buffers ( struct bnxt bp)

Definition at line 371 of file bnxt.c.

372 {
373  u16 cons_id = ( bp->rx.cons_id % bp->rx.ring_cnt );
374  u16 iob_idx;
375 
376  while ( bp->rx.iob_cnt < bp->rx.buf_cnt ) {
377  iob_idx = ( cons_id % bp->rx.buf_cnt );
378  if ( !bp->rx.iob[iob_idx] ) {
379  if ( bnxt_alloc_rx_iob ( bp, cons_id, iob_idx ) < 0 ) {
380  dbg_alloc_rx_iob_fail ( iob_idx, cons_id );
381  break;
382  }
383  }
384  cons_id = NEXT_IDX ( cons_id, bp->rx.ring_cnt );
385  bp->rx.iob_cnt++;
386  }
387 
388  if ( cons_id != bp->rx.cons_id ) {
389  dbg_rx_cid ( bp->rx.cons_id, cons_id );
390  bp->rx.cons_id = cons_id;
391  bnxt_db_rx ( bp, ( u32 )cons_id );
392  }
393 
394  FLAG_SET ( bp->flag_hwrm, VALID_RX_IOB );
395  return STATUS_SUCCESS;
396 }
uint16_t u16
Definition: stdint.h:21
#define FLAG_SET(f, b)
Definition: bnxt.h:45
#define STATUS_SUCCESS
Definition: bnxt.h:58
uint16_t bp
Definition: registers.h:23
#define dbg_rx_cid(idx, cid)
Definition: bnxt_dbg.h:471
#define dbg_alloc_rx_iob_fail(iob_idx, cons_id)
Definition: bnxt_dbg.h:472
static void bnxt_db_rx(struct bnxt *bp, u32 idx)
Definition: bnxt.c:218
static int bnxt_alloc_rx_iob(struct bnxt *bp, u16 cons_id, u16 iob_idx)
Definition: bnxt.c:354
#define NEXT_IDX(N, S)
Definition: bnxt.h:158
uint32_t u32
Definition: stdint.h:23
#define VALID_RX_IOB
Definition: bnxt.h:717

References bnxt_alloc_rx_iob(), bnxt_db_rx(), bp, dbg_alloc_rx_iob_fail, dbg_rx_cid, FLAG_SET, NEXT_IDX, STATUS_SUCCESS, and VALID_RX_IOB.

Referenced by bnxt_rx_process().

◆ bnxt_rx_drop()

u8 bnxt_rx_drop ( struct bnxt bp,
struct io_buffer iob,
struct rx_pkt_cmpl_hi rx_cmp_hi,
u16  rx_len 
)

Definition at line 398 of file bnxt.c.

400 {
401  u8 *rx_buf = ( u8 * )iob->data;
402  u16 err_flags, rx_vlan;
403  u8 ignore_chksum_err = 0;
404  int i;
405 
406  err_flags = rx_cmp_hi->errors_v2 >> RX_PKT_CMPL_ERRORS_BUFFER_ERROR_SFT;
407  if ( rx_cmp_hi->errors_v2 == 0x20 || rx_cmp_hi->errors_v2 == 0x21 )
408  ignore_chksum_err = 1;
409 
410  if ( err_flags && !ignore_chksum_err ) {
411  bp->rx.drop_err++;
412  return 1;
413  }
414 
415  for ( i = 0; i < 6; i++ ) {
416  if ( rx_buf[6 + i] != bp->mac_addr[i] )
417  break;
418  }
419 
420  /* Drop the loopback packets */
421  if ( i == 6 ) {
422  bp->rx.drop_lb++;
423  return 2;
424  }
425 
426  /* Get VLAN ID from RX completion ring */
427  if ( rx_cmp_hi->flags2 & RX_PKT_CMPL_FLAGS2_META_FORMAT_VLAN )
428  rx_vlan = ( rx_cmp_hi->metadata &
430  else
431  rx_vlan = 0;
432 
433  dbg_rx_vlan ( bp, rx_cmp_hi->metadata, rx_cmp_hi->flags2, rx_vlan );
434  if ( bnxt_vlan_drop ( bp, rx_vlan ) ) {
435  bp->rx.drop_vlan++;
436  return 3;
437  }
438  iob_put ( iob, rx_len );
439 
440  if ( rx_vlan )
441  bnxt_add_vlan ( iob, rx_vlan );
442 
443  bp->rx.good++;
444  return 0;
445 }
uint16_t u16
Definition: stdint.h:21
#define iob_put(iobuf, len)
Definition: iobuf.h:120
#define RX_PKT_CMPL_METADATA_VID_MASK
Definition: bnxt.h:624
#define RX_PKT_CMPL_FLAGS2_META_FORMAT_VLAN
Definition: bnxt.h:619
uint16_t bp
Definition: registers.h:23
void bnxt_add_vlan(struct io_buffer *iob, u16 vlan)
Definition: bnxt.c:235
#define dbg_rx_vlan(bp, metadata, flags2, rx_vid)
Definition: bnxt_dbg.h:469
u32 flags2
Definition: bnxt.h:611
#define RX_PKT_CMPL_ERRORS_BUFFER_ERROR_SFT
Definition: bnxt.h:636
void * data
Start of data.
Definition: iobuf.h:48
u16 errors_v2
Definition: bnxt.h:631
int bnxt_vlan_drop(struct bnxt *bp, u16 rx_vlan)
Definition: bnxt.c:256
u32 metadata
Definition: bnxt.h:623
uint8_t u8
Definition: stdint.h:19
if(natsemi->flags &NATSEMI_64BIT) return 1

References bnxt_add_vlan(), bnxt_vlan_drop(), bp, io_buffer::data, dbg_rx_vlan, rx_pkt_cmpl_hi::errors_v2, rx_pkt_cmpl_hi::flags2, if(), iob_put, rx_pkt_cmpl_hi::metadata, RX_PKT_CMPL_ERRORS_BUFFER_ERROR_SFT, RX_PKT_CMPL_FLAGS2_META_FORMAT_VLAN, and RX_PKT_CMPL_METADATA_VID_MASK.

Referenced by bnxt_rx_process().

◆ bnxt_rx_process()

void bnxt_rx_process ( struct net_device dev,
struct bnxt bp,
struct rx_pkt_cmpl rx_cmp,
struct rx_pkt_cmpl_hi rx_cmp_hi 
)

Definition at line 460 of file bnxt.c.

462 {
463  u32 desc_idx = rx_cmp->opaque;
464  struct io_buffer *iob = bp->rx.iob[desc_idx];
465  u8 drop;
466 
467  dump_rx_bd ( rx_cmp, rx_cmp_hi, desc_idx );
468  assert ( !iob );
469  drop = bnxt_rx_drop ( bp, iob, rx_cmp_hi, rx_cmp->len );
470  dbg_rxp ( iob->data, rx_cmp->len, drop );
471  if ( drop )
472  netdev_rx_err ( dev, iob, -EINVAL );
473  else
474  netdev_rx ( dev, iob );
475 
476  bp->rx.cnt++;
477  bp->rx.iob[desc_idx] = NULL;
478  bp->rx.iob_cnt--;
480  bnxt_adv_cq_index ( bp, 2 ); /* Rx completion is 2 entries. */
481  dbg_rx_stat ( bp );
482 }
#define EINVAL
Invalid argument.
Definition: errno.h:428
void netdev_rx_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Discard received packet.
Definition: netdevice.c:539
u32 opaque
Definition: bnxt.h:597
#define dbg_rxp(iob, rx_len, drop)
Definition: bnxt_dbg.h:473
uint16_t bp
Definition: registers.h:23
static void bnxt_adv_cq_index(struct bnxt *bp, u16 cnt)
Definition: bnxt.c:447
int bnxt_post_rx_buffers(struct bnxt *bp)
Definition: bnxt.c:371
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
#define dbg_rx_stat(bp)
Definition: bnxt_dbg.h:474
u8 bnxt_rx_drop(struct bnxt *bp, struct io_buffer *iob, struct rx_pkt_cmpl_hi *rx_cmp_hi, u16 rx_len)
Definition: bnxt.c:398
void netdev_rx(struct net_device *netdev, struct io_buffer *iobuf)
Add packet to receive queue.
Definition: netdevice.c:501
#define dump_rx_bd(rx_cmp, rx_cmp_hi, desc_idx)
Definition: bnxt_dbg.h:468
void * data
Start of data.
Definition: iobuf.h:48
u16 len
Definition: bnxt.h:596
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
uint8_t u8
Definition: stdint.h:19
uint32_t u32
Definition: stdint.h:23
A persistent I/O buffer.
Definition: iobuf.h:33

References assert(), bnxt_adv_cq_index(), bnxt_post_rx_buffers(), bnxt_rx_drop(), bp, io_buffer::data, dbg_rx_stat, dbg_rxp, dump_rx_bd, EINVAL, rx_pkt_cmpl::len, netdev_rx(), netdev_rx_err(), NULL, and rx_pkt_cmpl::opaque.

Referenced by bnxt_rx_complete().

◆ bnxt_mm_init()

void bnxt_mm_init ( struct bnxt bp,
const char *  func 
)

Definition at line 504 of file bnxt.c.

505 {
506  DBGP ( "%s\n", __func__ );
507  memset ( bp->hwrm_addr_req, 0, REQ_BUFFER_SIZE );
508  memset ( bp->hwrm_addr_resp, 0, RESP_BUFFER_SIZE );
509  memset ( bp->hwrm_addr_dma, 0, DMA_BUFFER_SIZE );
510  bp->req_addr_mapping = virt_to_bus ( bp->hwrm_addr_req );
511  bp->resp_addr_mapping = virt_to_bus ( bp->hwrm_addr_resp );
512  bp->dma_addr_mapping = virt_to_bus ( bp->hwrm_addr_dma );
513  bp->link_status = STATUS_LINK_DOWN;
514  bp->wait_link_timeout = LINK_DEFAULT_TIMEOUT;
516  bp->hwrm_max_req_len = HWRM_MAX_REQ_LEN;
517  bp->nq.ring_cnt = MAX_NQ_DESC_CNT;
518  bp->cq.ring_cnt = MAX_CQ_DESC_CNT;
519  bp->tx.ring_cnt = MAX_TX_DESC_CNT;
520  bp->rx.ring_cnt = MAX_RX_DESC_CNT;
521  bp->rx.buf_cnt = NUM_RX_BUFFERS;
522  dbg_mem ( bp, func );
523 }
#define MAX_NQ_DESC_CNT
Definition: bnxt.h:169
#define RESP_BUFFER_SIZE
Definition: bnxt.h:154
uint16_t bp
Definition: registers.h:23
#define STATUS_LINK_DOWN
Definition: bnxt.h:63
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 DBGP(...)
Definition: compiler.h:532
#define REQ_BUFFER_SIZE
Definition: bnxt.h:153
#define dbg_mem(bp, func)
Definition: bnxt_dbg.h:175
#define NUM_RX_BUFFERS
Definition: bnxt.h:143
#define MAX_CQ_DESC_CNT
Definition: bnxt.h:146
#define MAX_TX_DESC_CNT
Definition: bnx2.h:3881
#define LINK_DEFAULT_TIMEOUT
Definition: bnxt.h:163
#define MAX_ETHERNET_PACKET_BUFFER_SIZE
Definition: bnxt.h:137
#define DMA_BUFFER_SIZE
Definition: bnxt.h:155
#define HWRM_MAX_REQ_LEN
Definition: bnxt_hsi.h:363
void * memset(void *dest, int character, size_t len) __nonnull

References bp, dbg_mem, DBGP, DMA_BUFFER_SIZE, HWRM_MAX_REQ_LEN, LINK_DEFAULT_TIMEOUT, MAX_CQ_DESC_CNT, MAX_ETHERNET_PACKET_BUFFER_SIZE, MAX_NQ_DESC_CNT, MAX_RX_DESC_CNT, MAX_TX_DESC_CNT, memset(), NUM_RX_BUFFERS, REQ_BUFFER_SIZE, RESP_BUFFER_SIZE, STATUS_LINK_DOWN, and virt_to_bus().

Referenced by bnxt_alloc_mem().

◆ bnxt_mm_nic()

void bnxt_mm_nic ( struct bnxt bp)

Definition at line 525 of file bnxt.c.

526 {
527  DBGP ( "%s\n", __func__ );
528  memset ( bp->cq.bd_virt, 0, CQ_RING_BUFFER_SIZE );
529  memset ( bp->tx.bd_virt, 0, TX_RING_BUFFER_SIZE );
530  memset ( bp->rx.bd_virt, 0, RX_RING_BUFFER_SIZE );
531  memset ( bp->nq.bd_virt, 0, NQ_RING_BUFFER_SIZE );
532  bp->nq.cons_id = 0;
533  bp->nq.completion_bit = 0x1;
534  bp->cq.cons_id = 0;
535  bp->cq.completion_bit = 0x1;
536  bp->tx.prod_id = 0;
537  bp->tx.cons_id = 0;
538  bp->rx.cons_id = 0;
539  bp->rx.iob_cnt = 0;
540 
541  bp->link_status = STATUS_LINK_DOWN;
542  bp->wait_link_timeout = LINK_DEFAULT_TIMEOUT;
544  bp->hwrm_max_req_len = HWRM_MAX_REQ_LEN;
545  bp->nq.ring_cnt = MAX_NQ_DESC_CNT;
546  bp->cq.ring_cnt = MAX_CQ_DESC_CNT;
547  bp->tx.ring_cnt = MAX_TX_DESC_CNT;
548  bp->rx.ring_cnt = MAX_RX_DESC_CNT;
549  bp->rx.buf_cnt = NUM_RX_BUFFERS;
550 }
#define MAX_NQ_DESC_CNT
Definition: bnxt.h:169
#define NQ_RING_BUFFER_SIZE
Definition: bnxt.h:170
uint16_t bp
Definition: registers.h:23
#define STATUS_LINK_DOWN
Definition: bnxt.h:63
#define MAX_RX_DESC_CNT
Definition: bnx2.h:3885
#define DBGP(...)
Definition: compiler.h:532
#define RX_RING_BUFFER_SIZE
Definition: bnxt.h:148
#define NUM_RX_BUFFERS
Definition: bnxt.h:143
#define TX_RING_BUFFER_SIZE
Definition: bnxt.h:147
#define MAX_CQ_DESC_CNT
Definition: bnxt.h:146
#define CQ_RING_BUFFER_SIZE
Definition: bnxt.h:150
#define MAX_TX_DESC_CNT
Definition: bnx2.h:3881
#define LINK_DEFAULT_TIMEOUT
Definition: bnxt.h:163
#define MAX_ETHERNET_PACKET_BUFFER_SIZE
Definition: bnxt.h:137
#define HWRM_MAX_REQ_LEN
Definition: bnxt_hsi.h:363
void * memset(void *dest, int character, size_t len) __nonnull

References bp, CQ_RING_BUFFER_SIZE, DBGP, HWRM_MAX_REQ_LEN, LINK_DEFAULT_TIMEOUT, MAX_CQ_DESC_CNT, MAX_ETHERNET_PACKET_BUFFER_SIZE, MAX_NQ_DESC_CNT, MAX_RX_DESC_CNT, MAX_TX_DESC_CNT, memset(), NQ_RING_BUFFER_SIZE, NUM_RX_BUFFERS, RX_RING_BUFFER_SIZE, STATUS_LINK_DOWN, and TX_RING_BUFFER_SIZE.

Referenced by bnxt_open().

◆ bnxt_free_mem()

void bnxt_free_mem ( struct bnxt bp)

Definition at line 552 of file bnxt.c.

553 {
554  DBGP ( "%s\n", __func__ );
555  if ( bp->nq.bd_virt ) {
556  free_phys ( bp->nq.bd_virt, NQ_RING_BUFFER_SIZE );
557  bp->nq.bd_virt = NULL;
558  }
559 
560  if ( bp->cq.bd_virt ) {
561  free_phys ( bp->cq.bd_virt, CQ_RING_BUFFER_SIZE );
562  bp->cq.bd_virt = NULL;
563  }
564 
565  if ( bp->rx.bd_virt ) {
566  free_phys ( bp->rx.bd_virt, RX_RING_BUFFER_SIZE );
567  bp->rx.bd_virt = NULL;
568  }
569 
570  if ( bp->tx.bd_virt ) {
571  free_phys ( bp->tx.bd_virt, TX_RING_BUFFER_SIZE );
572  bp->tx.bd_virt = NULL;
573  }
574 
575  if ( bp->hwrm_addr_dma ) {
576  free_phys ( bp->hwrm_addr_dma, DMA_BUFFER_SIZE );
577  bp->dma_addr_mapping = 0;
578  bp->hwrm_addr_dma = NULL;
579  }
580 
581  if ( bp->hwrm_addr_resp ) {
582  free_phys ( bp->hwrm_addr_resp, RESP_BUFFER_SIZE );
583  bp->resp_addr_mapping = 0;
584  bp->hwrm_addr_resp = NULL;
585  }
586 
587  if ( bp->hwrm_addr_req ) {
588  free_phys ( bp->hwrm_addr_req, REQ_BUFFER_SIZE );
589  bp->req_addr_mapping = 0;
590  bp->hwrm_addr_req = NULL;
591  }
592  DBGP ( "- %s ( ): - Done\n", __func__ );
593 }
#define RESP_BUFFER_SIZE
Definition: bnxt.h:154
#define NQ_RING_BUFFER_SIZE
Definition: bnxt.h:170
uint16_t bp
Definition: registers.h:23
#define DBGP(...)
Definition: compiler.h:532
#define REQ_BUFFER_SIZE
Definition: bnxt.h:153
#define RX_RING_BUFFER_SIZE
Definition: bnxt.h:148
#define TX_RING_BUFFER_SIZE
Definition: bnxt.h:147
#define CQ_RING_BUFFER_SIZE
Definition: bnxt.h:150
#define DMA_BUFFER_SIZE
Definition: bnxt.h:155
static void free_phys(void *ptr, size_t size)
Free memory allocated with malloc_phys()
Definition: malloc.h:77
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References bp, CQ_RING_BUFFER_SIZE, DBGP, DMA_BUFFER_SIZE, free_phys(), NQ_RING_BUFFER_SIZE, NULL, REQ_BUFFER_SIZE, RESP_BUFFER_SIZE, RX_RING_BUFFER_SIZE, and TX_RING_BUFFER_SIZE.

Referenced by bnxt_alloc_mem(), bnxt_init_one(), and bnxt_remove_one().

◆ bnxt_alloc_mem()

int bnxt_alloc_mem ( struct bnxt bp)

Definition at line 595 of file bnxt.c.

596 {
597  DBGP ( "%s\n", __func__ );
598  bp->hwrm_addr_req = malloc_phys ( REQ_BUFFER_SIZE, BNXT_DMA_ALIGNMENT );
599  bp->hwrm_addr_resp = malloc_phys ( RESP_BUFFER_SIZE,
601  bp->hwrm_addr_dma = malloc_phys ( DMA_BUFFER_SIZE, BNXT_DMA_ALIGNMENT );
602  bp->tx.bd_virt = malloc_phys ( TX_RING_BUFFER_SIZE, DMA_ALIGN_4K );
603  bp->rx.bd_virt = malloc_phys ( RX_RING_BUFFER_SIZE, DMA_ALIGN_4K );
606  test_if ( bp->hwrm_addr_req &&
607  bp->hwrm_addr_resp &&
608  bp->hwrm_addr_dma &&
609  bp->tx.bd_virt &&
610  bp->rx.bd_virt &&
611  bp->nq.bd_virt &&
612  bp->cq.bd_virt ) {
613  bnxt_mm_init ( bp, __func__ );
614  return STATUS_SUCCESS;
615  }
616 
617  DBGP ( "- %s ( ): Failed\n", __func__ );
618  bnxt_free_mem ( bp );
619  return -ENOMEM;
620 }
#define STATUS_SUCCESS
Definition: bnxt.h:58
#define RESP_BUFFER_SIZE
Definition: bnxt.h:154
#define test_if
Definition: bnxt.h:825
#define NQ_RING_BUFFER_SIZE
Definition: bnxt.h:170
uint16_t bp
Definition: registers.h:23
static void *__malloc malloc_phys(size_t size, size_t phys_align)
Allocate memory with specified physical alignment.
Definition: malloc.h:62
#define ENOMEM
Not enough space.
Definition: errno.h:534
#define DBGP(...)
Definition: compiler.h:532
#define REQ_BUFFER_SIZE
Definition: bnxt.h:153
#define RX_RING_BUFFER_SIZE
Definition: bnxt.h:148
#define BNXT_DMA_ALIGNMENT
Definition: bnxt.h:151
#define TX_RING_BUFFER_SIZE
Definition: bnxt.h:147
void bnxt_mm_init(struct bnxt *bp, const char *func)
Definition: bnxt.c:504
#define CQ_RING_BUFFER_SIZE
Definition: bnxt.h:150
void bnxt_free_mem(struct bnxt *bp)
Definition: bnxt.c:552
#define DMA_BUFFER_SIZE
Definition: bnxt.h:155
#define DMA_ALIGN_4K
Definition: bnxt.h:152

References BNXT_DMA_ALIGNMENT, bnxt_free_mem(), bnxt_mm_init(), bp, CQ_RING_BUFFER_SIZE, DBGP, DMA_ALIGN_4K, DMA_BUFFER_SIZE, ENOMEM, malloc_phys(), NQ_RING_BUFFER_SIZE, REQ_BUFFER_SIZE, RESP_BUFFER_SIZE, RX_RING_BUFFER_SIZE, STATUS_SUCCESS, test_if, and TX_RING_BUFFER_SIZE.

Referenced by bnxt_init_one().

◆ hwrm_init()

static void hwrm_init ( struct bnxt bp,
struct input req,
u16  cmd,
u16  len 
)
static

Definition at line 622 of file bnxt.c.

623 {
624  memset ( req, 0, len );
625  req->req_type = cmd;
626  req->cmpl_ring = ( u16 )HWRM_NA_SIGNATURE;
627  req->target_id = ( u16 )HWRM_NA_SIGNATURE;
628  req->resp_addr = bp->resp_addr_mapping;
629  req->seq_id = bp->seq_id++;
630 }
#define u16
Definition: vga.h:20
__le16 seq_id
Definition: bnxt_hsi.h:71
uint16_t bp
Definition: registers.h:23
#define HWRM_NA_SIGNATURE
Definition: bnxt_hsi.h:362
__le16 cmpl_ring
Definition: bnxt_hsi.h:70
__le16 req_type
Definition: bnxt_hsi.h:69
uint32_t len
Length.
Definition: ena.h:14
__le16 target_id
Definition: bnxt_hsi.h:72
__le64 resp_addr
Definition: bnxt_hsi.h:73
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29
void * memset(void *dest, int character, size_t len) __nonnull

References bp, cmd, input::cmpl_ring, HWRM_NA_SIGNATURE, len, memset(), input::req_type, input::resp_addr, input::seq_id, input::target_id, and u16.

Referenced by bnxt_hwrm_backing_store_cfg(), bnxt_hwrm_backing_store_qcfg(), bnxt_hwrm_cfa_l2_filter_alloc(), bnxt_hwrm_cfa_l2_filter_free(), bnxt_hwrm_func_cfg_req(), bnxt_hwrm_func_drv_rgtr(), bnxt_hwrm_func_drv_unrgtr(), bnxt_hwrm_func_qcaps_req(), bnxt_hwrm_func_qcfg_req(), bnxt_hwrm_func_reset_req(), bnxt_hwrm_func_resource_qcaps(), bnxt_hwrm_nvm_get_variable_req(), bnxt_hwrm_port_mac_cfg(), bnxt_hwrm_port_phy_cfg(), bnxt_hwrm_port_phy_qcfg(), bnxt_hwrm_queue_qportcfg(), bnxt_hwrm_ring_alloc(), bnxt_hwrm_ring_alloc_grp(), bnxt_hwrm_ring_free(), bnxt_hwrm_ring_free_grp(), bnxt_hwrm_set_async_event(), bnxt_hwrm_set_rx_mask(), bnxt_hwrm_stat_ctx_alloc(), bnxt_hwrm_stat_ctx_free(), bnxt_hwrm_ver_get(), bnxt_hwrm_vnic_alloc(), bnxt_hwrm_vnic_cfg(), and bnxt_hwrm_vnic_free().

◆ hwrm_write_req()

static void hwrm_write_req ( struct bnxt bp,
void *  req,
u32  cnt 
)
static

Definition at line 632 of file bnxt.c.

633 {
634  u32 i = 0;
635 
636  for ( i = 0; i < cnt; i++ ) {
637  write32 ( ( ( u32 * )req )[i],
638  ( bp->bar0 + GRC_COM_CHAN_BASE + ( i * 4 ) ) );
639  }
640  write32 ( 0x1, ( bp->bar0 + GRC_COM_CHAN_BASE + GRC_COM_CHAN_TRIG ) );
641 }
#define write32
Definition: bnxt.h:826
uint16_t bp
Definition: registers.h:23
#define GRC_COM_CHAN_TRIG
Definition: bnxt.h:124
uint32_t u32
Definition: stdint.h:23
#define GRC_COM_CHAN_BASE
Definition: bnxt.h:123

References bp, GRC_COM_CHAN_BASE, GRC_COM_CHAN_TRIG, and write32.

Referenced by short_hwrm_cmd_req(), and wait_resp().

◆ short_hwrm_cmd_req()

static void short_hwrm_cmd_req ( struct bnxt bp,
u16  len 
)
static

Definition at line 643 of file bnxt.c.

644 {
645  struct hwrm_short_input sreq;
646 
647  memset ( &sreq, 0, sizeof ( struct hwrm_short_input ) );
648  sreq.req_type = ( u16 ) ( ( struct input * )bp->hwrm_addr_req )->req_type;
649  sreq.signature = SHORT_REQ_SIGNATURE_SHORT_CMD;
650  sreq.size = len;
651  sreq.req_addr = bp->req_addr_mapping;
652  mdelay ( 100 );
653  dbg_short_cmd ( ( u8 * )&sreq, __func__,
654  sizeof ( struct hwrm_short_input ) );
655  hwrm_write_req ( bp, &sreq, sizeof ( struct hwrm_short_input ) / 4 );
656 }
#define u16
Definition: vga.h:20
#define dbg_short_cmd(sreq, func, len)
Definition: bnxt_dbg.h:398
__le16 req_type
Definition: bnxt_hsi.h:86
Definition: bnxt_hsi.h:68
uint16_t bp
Definition: registers.h:23
static void hwrm_write_req(struct bnxt *bp, void *req, u32 cnt)
Definition: bnxt.c:632
#define SHORT_REQ_SIGNATURE_SHORT_CMD
Definition: bnxt_hsi.h:88
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition: timer.c:78
uint32_t len
Length.
Definition: ena.h:14
uint8_t u8
Definition: stdint.h:19
void * memset(void *dest, int character, size_t len) __nonnull

References bp, dbg_short_cmd, hwrm_write_req(), len, mdelay(), memset(), hwrm_short_input::req_addr, hwrm_short_input::req_type, SHORT_REQ_SIGNATURE_SHORT_CMD, hwrm_short_input::signature, hwrm_short_input::size, and u16.

Referenced by wait_resp().

◆ wait_resp()

static int wait_resp ( struct bnxt bp,
u32  tmo,
u16  len,
const char *  func 
)
static

Definition at line 658 of file bnxt.c.

659 {
660  struct input *req = ( struct input * )bp->hwrm_addr_req;
661  struct output *resp = ( struct output * )bp->hwrm_addr_resp;
662  u8 *ptr = ( u8 * )resp;
663  u32 idx;
664  u32 wait_cnt = HWRM_CMD_DEFAULT_MULTIPLAYER ( ( u32 )tmo );
665  u16 resp_len = 0;
666  u16 ret = STATUS_TIMEOUT;
667 
668  if ( len > bp->hwrm_max_req_len )
670  else
671  hwrm_write_req ( bp, req, ( u32 ) ( len / 4 ) );
672 
673  for ( idx = 0; idx < wait_cnt; idx++ ) {
674  resp_len = resp->resp_len;
675  test_if ( resp->seq_id == req->seq_id &&
676  resp->req_type == req->req_type &&
677  ptr[resp_len - 1] == 1 ) {
678  bp->last_resp_code = resp->error_code;
679  ret = resp->error_code;
680  break;
681  }
683  }
684  dbg_hw_cmd ( bp, func, len, resp_len, tmo, ret );
685  return ( int )ret;
686 }
uint16_t u16
Definition: stdint.h:21
#define dbg_hw_cmd(bp, func, cmd_len, resp_len, cmd_tmo, err)
Definition: bnxt_dbg.h:378
__le16 seq_id
Definition: bnxt_hsi.h:71
#define HWRM_CMD_DEFAULT_MULTIPLAYER(a)
Definition: bnxt.h:133
#define test_if
Definition: bnxt.h:825
Definition: bnxt_hsi.h:68
uint16_t bp
Definition: registers.h:23
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
#define STATUS_TIMEOUT
Definition: bnxt.h:82
__le16 req_type
Definition: bnxt_hsi.h:69
static void hwrm_write_req(struct bnxt *bp, void *req, u32 cnt)
Definition: bnxt.c:632
static void short_hwrm_cmd_req(struct bnxt *bp, u16 len)
Definition: bnxt.c:643
uint32_t len
Length.
Definition: ena.h:14
#define HWRM_CMD_POLL_WAIT_TIME
Definition: bnxt.h:132
uint8_t u8
Definition: stdint.h:19
uint32_t u32
Definition: stdint.h:23

References bp, dbg_hw_cmd, HWRM_CMD_DEFAULT_MULTIPLAYER, HWRM_CMD_POLL_WAIT_TIME, hwrm_write_req(), len, input::req_type, input::seq_id, short_hwrm_cmd_req(), STATUS_TIMEOUT, test_if, and udelay().

Referenced by bnxt_hwrm_backing_store_cfg(), bnxt_hwrm_backing_store_qcfg(), bnxt_hwrm_cfa_l2_filter_alloc(), bnxt_hwrm_cfa_l2_filter_free(), bnxt_hwrm_func_cfg_req(), bnxt_hwrm_func_drv_rgtr(), bnxt_hwrm_func_drv_unrgtr(), bnxt_hwrm_func_qcaps_req(), bnxt_hwrm_func_qcfg_req(), bnxt_hwrm_func_reset_req(), bnxt_hwrm_func_resource_qcaps(), bnxt_hwrm_nvm_get_variable_req(), bnxt_hwrm_port_mac_cfg(), bnxt_hwrm_port_phy_cfg(), bnxt_hwrm_port_phy_qcfg(), bnxt_hwrm_queue_qportcfg(), bnxt_hwrm_ring_alloc(), bnxt_hwrm_ring_alloc_grp(), bnxt_hwrm_ring_free(), bnxt_hwrm_ring_free_grp(), bnxt_hwrm_set_async_event(), bnxt_hwrm_set_rx_mask(), bnxt_hwrm_stat_ctx_alloc(), bnxt_hwrm_stat_ctx_free(), bnxt_hwrm_ver_get(), bnxt_hwrm_vnic_alloc(), bnxt_hwrm_vnic_cfg(), and bnxt_hwrm_vnic_free().

◆ bnxt_hwrm_ver_get()

static int bnxt_hwrm_ver_get ( struct bnxt bp)
static

Definition at line 688 of file bnxt.c.

689 {
690  u16 cmd_len = ( u16 )sizeof ( struct hwrm_ver_get_input );
691  struct hwrm_ver_get_input *req;
692  struct hwrm_ver_get_output *resp;
693  int rc;
694 
695  DBGP ( "%s\n", __func__ );
696  req = ( struct hwrm_ver_get_input * )bp->hwrm_addr_req;
697  resp = ( struct hwrm_ver_get_output * )bp->hwrm_addr_resp;
698  hwrm_init ( bp, ( void * )req, ( u16 )HWRM_VER_GET, cmd_len );
699  req->hwrm_intf_maj = HWRM_VERSION_MAJOR;
700  req->hwrm_intf_min = HWRM_VERSION_MINOR;
701  req->hwrm_intf_upd = HWRM_VERSION_UPDATE;
702  rc = wait_resp ( bp, HWRM_CMD_DEFAULT_TIMEOUT, cmd_len, __func__ );
703  if ( rc )
704  return STATUS_FAILURE;
705 
706  bp->hwrm_spec_code =
707  resp->hwrm_intf_maj_8b << 16 |
708  resp->hwrm_intf_min_8b << 8 |
709  resp->hwrm_intf_upd_8b;
710  bp->hwrm_cmd_timeout = ( u32 )resp->def_req_timeout;
711  if ( !bp->hwrm_cmd_timeout )
712  bp->hwrm_cmd_timeout = ( u32 )HWRM_CMD_DEFAULT_TIMEOUT;
713  if ( resp->hwrm_intf_maj_8b >= 1 )
714  bp->hwrm_max_req_len = resp->max_req_win_len;
715  bp->chip_id =
716  resp->chip_rev << 24 |
717  resp->chip_metal << 16 |
718  resp->chip_bond_id << 8 |
719  resp->chip_platform_type;
720  bp->chip_num = resp->chip_num;
721  test_if ( ( resp->dev_caps_cfg & SHORT_CMD_SUPPORTED ) &&
722  ( resp->dev_caps_cfg & SHORT_CMD_REQUIRED ) )
724  bp->hwrm_max_ext_req_len = resp->max_ext_req_len;
725  if ( bp->chip_num == CHIP_NUM_57500 )
726  bp->thor = 1;
727  dbg_fw_ver ( resp, bp->hwrm_cmd_timeout );
728  return STATUS_SUCCESS;
729 }
#define u16
Definition: vga.h:20
uint16_t u16
Definition: stdint.h:21
#define FLAG_SET(f, b)
Definition: bnxt.h:45
#define STATUS_SUCCESS
Definition: bnxt.h:58
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define SHORT_CMD_SUPPORTED
Definition: bnxt.h:831
__le16 def_req_timeout
Definition: bnxt_hsi.h:440
#define HWRM_VER_GET
Definition: bnxt_hsi.h:98
#define test_if
Definition: bnxt.h:825
static void hwrm_init(struct bnxt *bp, struct input *req, u16 cmd, u16 len)
Definition: bnxt.c:622
#define HWRM_VERSION_MINOR
Definition: bnxt_hsi.h:369
uint16_t bp
Definition: registers.h:23
__le16 max_ext_req_len
Definition: bnxt_hsi.h:466
#define CHIP_NUM_57500
Definition: bnxt.h:871
static int wait_resp(struct bnxt *bp, u32 tmo, u16 len, const char *func)
Definition: bnxt.c:658
#define DBGP(...)
Definition: compiler.h:532
#define SHORT_CMD_REQUIRED
Definition: bnxt.h:832
#define u32
Definition: vga.h:21
#define STATUS_FAILURE
Definition: bnxt.h:59
#define HWRM_VERSION_UPDATE
Definition: bnxt_hsi.h:370
#define dbg_fw_ver(resp, tmo)
Definition: bnxt_dbg.h:319
#define BNXT_FLAG_HWRM_SHORT_CMD_SUPP
Definition: bnxt.h:48
#define HWRM_VERSION_MAJOR
Definition: bnxt_hsi.h:368
__le16 max_req_win_len
Definition: bnxt_hsi.h:438
#define HWRM_CMD_DEFAULT_TIMEOUT
Definition: bnxt.h:131
if(natsemi->flags &NATSEMI_64BIT) return 1

References BNXT_FLAG_HWRM_SHORT_CMD_SUPP, bp, hwrm_ver_get_output::chip_bond_id, hwrm_ver_get_output::chip_metal, hwrm_ver_get_output::chip_num, CHIP_NUM_57500, hwrm_ver_get_output::chip_platform_type, hwrm_ver_get_output::chip_rev, dbg_fw_ver, DBGP, hwrm_ver_get_output::def_req_timeout, hwrm_ver_get_output::dev_caps_cfg, FLAG_SET, HWRM_CMD_DEFAULT_TIMEOUT, hwrm_init(), hwrm_ver_get_output::hwrm_intf_maj_8b, hwrm_ver_get_output::hwrm_intf_min_8b, hwrm_ver_get_output::hwrm_intf_upd_8b, HWRM_VER_GET, HWRM_VERSION_MAJOR, HWRM_VERSION_MINOR, HWRM_VERSION_UPDATE, if(), hwrm_ver_get_output::max_ext_req_len, hwrm_ver_get_output::max_req_win_len, rc, SHORT_CMD_REQUIRED, SHORT_CMD_SUPPORTED, STATUS_FAILURE, STATUS_SUCCESS, test_if, u16, u32, and wait_resp().

◆ bnxt_hwrm_func_resource_qcaps()

static int bnxt_hwrm_func_resource_qcaps ( struct bnxt bp)
static

Definition at line 731 of file bnxt.c.

732 {
733  u16 cmd_len = ( u16 )sizeof ( struct hwrm_func_resource_qcaps_input );
734  struct hwrm_func_resource_qcaps_input *req;
735  struct hwrm_func_resource_qcaps_output *resp;
736  int rc;
737 
738  DBGP ( "%s\n", __func__ );
739  req = ( struct hwrm_func_resource_qcaps_input * )bp->hwrm_addr_req;
740  resp = ( struct hwrm_func_resource_qcaps_output * )bp->hwrm_addr_resp;
741  hwrm_init ( bp, ( void * )req, ( u16 )HWRM_FUNC_RESOURCE_QCAPS,
742  cmd_len );
743  req->fid = ( u16 )HWRM_NA_SIGNATURE;
744  rc = wait_resp ( bp, bp->hwrm_cmd_timeout, cmd_len, __func__ );
745  if ( rc != STATUS_SUCCESS )
746  return STATUS_SUCCESS;
747 
749 
750  // VFs
751  if ( !bp->vf ) {
752  bp->max_vfs = resp->max_vfs;
753  bp->vf_res_strategy = resp->vf_reservation_strategy;
754  }
755 
756  // vNICs
757  bp->min_vnics = resp->min_vnics;
758  bp->max_vnics = resp->max_vnics;
759 
760  // MSI-X
761  bp->max_msix = resp->max_msix;
762 
763  // Ring Groups
764  bp->min_hw_ring_grps = resp->min_hw_ring_grps;
765  bp->max_hw_ring_grps = resp->max_hw_ring_grps;
766 
767  // TX Rings
768  bp->min_tx_rings = resp->min_tx_rings;
769  bp->max_tx_rings = resp->max_tx_rings;
770 
771  // RX Rings
772  bp->min_rx_rings = resp->min_rx_rings;
773  bp->max_rx_rings = resp->max_rx_rings;
774 
775  // Completion Rings
776  bp->min_cp_rings = resp->min_cmpl_rings;
777  bp->max_cp_rings = resp->max_cmpl_rings;
778 
779  // RSS Contexts
780  bp->min_rsscos_ctxs = resp->min_rsscos_ctx;
781  bp->max_rsscos_ctxs = resp->max_rsscos_ctx;
782 
783  // L2 Contexts
784  bp->min_l2_ctxs = resp->min_l2_ctxs;
785  bp->max_l2_ctxs = resp->max_l2_ctxs;
786 
787  // Statistic Contexts
788  bp->min_stat_ctxs = resp->min_stat_ctx;
789  bp->max_stat_ctxs = resp->max_stat_ctx;
791  return STATUS_SUCCESS;
792 }
#define u16
Definition: vga.h:20
uint16_t u16
Definition: stdint.h:21
#define FLAG_SET(f, b)
Definition: bnxt.h:45
#define STATUS_SUCCESS
Definition: bnxt.h:58
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define dbg_func_resource_qcaps(bp)
Definition: bnxt_dbg.h:320
static void hwrm_init(struct bnxt *bp, struct input *req, u16 cmd, u16 len)
Definition: bnxt.c:622
uint16_t bp
Definition: registers.h:23
static int wait_resp(struct bnxt *bp, u32 tmo, u16 len, const char *func)
Definition: bnxt.c:658
#define DBGP(...)
Definition: compiler.h:532
#define HWRM_NA_SIGNATURE
Definition: bnxt_hsi.h:362
#define HWRM_FUNC_RESOURCE_QCAPS
Definition: bnxt_hsi.h:280
#define BNXT_FLAG_RESOURCE_QCAPS_SUPPORT
Definition: bnxt.h:50

References BNXT_FLAG_RESOURCE_QCAPS_SUPPORT, bp, dbg_func_resource_qcaps, DBGP, FLAG_SET, HWRM_FUNC_RESOURCE_QCAPS, hwrm_init(), HWRM_NA_SIGNATURE, hwrm_func_resource_qcaps_output::max_cmpl_rings, hwrm_func_resource_qcaps_output::max_hw_ring_grps, hwrm_func_resource_qcaps_output::max_l2_ctxs, hwrm_func_resource_qcaps_output::max_msix, hwrm_func_resource_qcaps_output::max_rsscos_ctx, hwrm_func_resource_qcaps_output::max_rx_rings, hwrm_func_resource_qcaps_output::max_stat_ctx, hwrm_func_resource_qcaps_output::max_tx_rings, hwrm_func_resource_qcaps_output::max_vfs, hwrm_func_resource_qcaps_output::max_vnics, hwrm_func_resource_qcaps_output::min_cmpl_rings, hwrm_func_resource_qcaps_output::min_hw_ring_grps, hwrm_func_resource_qcaps_output::min_l2_ctxs, hwrm_func_resource_qcaps_output::min_rsscos_ctx, hwrm_func_resource_qcaps_output::min_rx_rings, hwrm_func_resource_qcaps_output::min_stat_ctx, hwrm_func_resource_qcaps_output::min_tx_rings, hwrm_func_resource_qcaps_output::min_vnics, rc, STATUS_SUCCESS, u16, hwrm_func_resource_qcaps_output::vf_reservation_strategy, and wait_resp().

◆ bnxt_set_ring_info()

static u32 bnxt_set_ring_info ( struct bnxt bp)
static

Definition at line 794 of file bnxt.c.

795 {
796  u32 enables = 0;
797 
798  DBGP ( "%s\n", __func__ );
799  bp->num_cmpl_rings = DEFAULT_NUMBER_OF_CMPL_RINGS;
800  bp->num_tx_rings = DEFAULT_NUMBER_OF_TX_RINGS;
801  bp->num_rx_rings = DEFAULT_NUMBER_OF_RX_RINGS;
802  bp->num_hw_ring_grps = DEFAULT_NUMBER_OF_RING_GRPS;
803  bp->num_stat_ctxs = DEFAULT_NUMBER_OF_STAT_CTXS;
804 
805  if ( bp->min_cp_rings <= DEFAULT_NUMBER_OF_CMPL_RINGS )
806  bp->num_cmpl_rings = bp->min_cp_rings;
807 
808  if ( bp->min_tx_rings <= DEFAULT_NUMBER_OF_TX_RINGS )
809  bp->num_tx_rings = bp->min_tx_rings;
810 
811  if ( bp->min_rx_rings <= DEFAULT_NUMBER_OF_RX_RINGS )
812  bp->num_rx_rings = bp->min_rx_rings;
813 
814  if ( bp->min_hw_ring_grps <= DEFAULT_NUMBER_OF_RING_GRPS )
815  bp->num_hw_ring_grps = bp->min_hw_ring_grps;
816 
817  if ( bp->min_stat_ctxs <= DEFAULT_NUMBER_OF_STAT_CTXS )
818  bp->num_stat_ctxs = bp->min_stat_ctxs;
819 
820  dbg_num_rings ( bp );
826  return enables;
827 }
#define DEFAULT_NUMBER_OF_CMPL_RINGS
Definition: bnxt.h:138
#define DEFAULT_NUMBER_OF_RING_GRPS
Definition: bnxt.h:141
uint16_t bp
Definition: registers.h:23
#define FUNC_CFG_REQ_ENABLES_NUM_CMPL_RINGS
Definition: bnxt_hsi.h:1533
#define FUNC_CFG_REQ_ENABLES_NUM_HW_RING_GRPS
Definition: bnxt_hsi.h:1549
#define DEFAULT_NUMBER_OF_STAT_CTXS
Definition: bnxt.h:142
#define DBGP(...)
Definition: compiler.h:532
#define DEFAULT_NUMBER_OF_RX_RINGS
Definition: bnxt.h:140
#define FUNC_CFG_REQ_ENABLES_NUM_RX_RINGS
Definition: bnxt_hsi.h:1535
#define FUNC_CFG_REQ_ENABLES_NUM_TX_RINGS
Definition: bnxt_hsi.h:1534
#define FUNC_CFG_REQ_ENABLES_NUM_STAT_CTXS
Definition: bnxt_hsi.h:1538
#define DEFAULT_NUMBER_OF_TX_RINGS
Definition: bnxt.h:139
#define dbg_num_rings(bp)
Definition: bnxt_dbg.h:325
uint32_t u32
Definition: stdint.h:23

References bp, dbg_num_rings, DBGP, DEFAULT_NUMBER_OF_CMPL_RINGS, DEFAULT_NUMBER_OF_RING_GRPS, DEFAULT_NUMBER_OF_RX_RINGS, DEFAULT_NUMBER_OF_STAT_CTXS, DEFAULT_NUMBER_OF_TX_RINGS, FUNC_CFG_REQ_ENABLES_NUM_CMPL_RINGS, FUNC_CFG_REQ_ENABLES_NUM_HW_RING_GRPS, FUNC_CFG_REQ_ENABLES_NUM_RX_RINGS, FUNC_CFG_REQ_ENABLES_NUM_STAT_CTXS, and FUNC_CFG_REQ_ENABLES_NUM_TX_RINGS.

Referenced by bnxt_hwrm_assign_resources().

◆ bnxt_hwrm_assign_resources()

static void bnxt_hwrm_assign_resources ( struct bnxt bp)
static

Definition at line 829 of file bnxt.c.

830 {
831  struct hwrm_func_cfg_input *req;
832  u32 enables = 0;
833 
834  DBGP ( "%s\n", __func__ );
837 
838  req = ( struct hwrm_func_cfg_input * )bp->hwrm_addr_req;
839  req->num_cmpl_rings = bp->num_cmpl_rings;
840  req->num_tx_rings = bp->num_tx_rings;
841  req->num_rx_rings = bp->num_rx_rings;
842  req->num_stat_ctxs = bp->num_stat_ctxs;
843  req->num_hw_ring_grps = bp->num_hw_ring_grps;
844  req->enables = enables;
845 }
static u32 bnxt_set_ring_info(struct bnxt *bp)
Definition: bnxt.c:794
#define FLAG_TEST(f, b)
Definition: bnxt.h:46
uint16_t bp
Definition: registers.h:23
#define DBGP(...)
Definition: compiler.h:532
__le16 num_hw_ring_grps
Definition: bnxt_hsi.h:1562
#define BNXT_FLAG_RESOURCE_QCAPS_SUPPORT
Definition: bnxt.h:50
uint32_t u32
Definition: stdint.h:23

References BNXT_FLAG_RESOURCE_QCAPS_SUPPORT, bnxt_set_ring_info(), bp, DBGP, hwrm_func_cfg_input::enables, FLAG_TEST, hwrm_func_cfg_input::num_cmpl_rings, hwrm_func_cfg_input::num_hw_ring_grps, hwrm_func_cfg_input::num_rx_rings, hwrm_func_cfg_input::num_stat_ctxs, and hwrm_func_cfg_input::num_tx_rings.

Referenced by bnxt_hwrm_func_cfg_req().

◆ bnxt_hwrm_func_qcaps_req()

static int bnxt_hwrm_func_qcaps_req ( struct bnxt bp)
static

Definition at line 847 of file bnxt.c.

848 {
849  u16 cmd_len = ( u16 )sizeof ( struct hwrm_func_qcaps_input );
850  struct hwrm_func_qcaps_input *req;
851  struct hwrm_func_qcaps_output *resp;
852  int rc;
853 
854  DBGP ( "%s\n", __func__ );
855  if ( bp->vf )
856  return STATUS_SUCCESS;
857 
858  req = ( struct hwrm_func_qcaps_input * )bp->hwrm_addr_req;
859  resp = ( struct hwrm_func_qcaps_output * )bp->hwrm_addr_resp;
860  hwrm_init ( bp, ( void * )req, ( u16 )HWRM_FUNC_QCAPS, cmd_len );
861  req->fid = ( u16 )HWRM_NA_SIGNATURE;
862  rc = wait_resp ( bp, bp->hwrm_cmd_timeout, cmd_len, __func__ );
863  if ( rc ) {
864  DBGP ( "- %s ( ): Failed\n", __func__ );
865  return STATUS_FAILURE;
866  }
867 
868  bp->fid = resp->fid;
869  bp->port_idx = ( u8 )resp->port_id;
870 
871  /* Get MAC address for this PF */
872  memcpy ( &bp->mac_addr[0], &resp->mac_address[0], ETH_ALEN );
873  dbg_func_qcaps ( bp );
874  return STATUS_SUCCESS;
875 }
#define u16
Definition: vga.h:20
uint16_t u16
Definition: stdint.h:21
#define STATUS_SUCCESS
Definition: bnxt.h:58
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static void hwrm_init(struct bnxt *bp, struct input *req, u16 cmd, u16 len)
Definition: bnxt.c:622
uint16_t bp
Definition: registers.h:23
#define HWRM_FUNC_QCAPS
Definition: bnxt_hsi.h:107
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static int wait_resp(struct bnxt *bp, u32 tmo, u16 len, const char *func)
Definition: bnxt.c:658
#define DBGP(...)
Definition: compiler.h:532
#define dbg_func_qcaps(bp)
Definition: bnxt_dbg.h:321
#define u8
Definition: igbvf_osdep.h:38
#define HWRM_NA_SIGNATURE
Definition: bnxt_hsi.h:362
#define STATUS_FAILURE
Definition: bnxt.h:59
#define ETH_ALEN
Definition: if_ether.h:8

References bp, dbg_func_qcaps, DBGP, ETH_ALEN, hwrm_func_qcaps_output::fid, HWRM_FUNC_QCAPS, hwrm_init(), HWRM_NA_SIGNATURE, hwrm_func_qcaps_output::mac_address, memcpy(), hwrm_func_qcaps_output::port_id, rc, STATUS_FAILURE, STATUS_SUCCESS, u16, u8, and wait_resp().

◆ bnxt_hwrm_func_qcfg_req()

static int bnxt_hwrm_func_qcfg_req ( struct bnxt bp)
static

Definition at line 877 of file bnxt.c.

878 {
879  u16 cmd_len = ( u16 )sizeof ( struct hwrm_func_qcfg_input );
880  struct hwrm_func_qcfg_input *req;
881  struct hwrm_func_qcfg_output *resp;
882  int rc;
883 
884  DBGP ( "%s\n", __func__ );
885  req = ( struct hwrm_func_qcfg_input * )bp->hwrm_addr_req;
886  resp = ( struct hwrm_func_qcfg_output * )bp->hwrm_addr_resp;
887  hwrm_init ( bp, ( void * )req, ( u16 )HWRM_FUNC_QCFG, cmd_len );
888  req->fid = ( u16 )HWRM_NA_SIGNATURE;
889  rc = wait_resp ( bp, bp->hwrm_cmd_timeout, cmd_len, __func__ );
890  if ( rc ) {
891  DBGP ( "- %s ( ): Failed\n", __func__ );
892  return STATUS_FAILURE;
893  }
894 
896  FLAG_SET ( bp->flags, BNXT_FLAG_MULTI_HOST );
897 
898  if ( resp->port_partition_type &
900  FLAG_SET ( bp->flags, BNXT_FLAG_NPAR_MODE );
901 
902  bp->ordinal_value = ( u8 )resp->pci_id & 0x0F;
903  bp->stat_ctx_id = resp->stat_ctx_id;
904 
905  /* If VF is set to TRUE, then use some data from func_qcfg ( ). */
906  if ( bp->vf ) {
907  bp->fid = resp->fid;
908  bp->port_idx = ( u8 )resp->port_id;
909  bp->vlan_id = resp->vlan;
910 
911  /* Get MAC address for this VF */
912  memcpy ( bp->mac_addr, resp->mac_address, ETH_ALEN );
913  }
914  dbg_func_qcfg ( bp );
915  return STATUS_SUCCESS;
916 }
#define u16
Definition: vga.h:20
uint16_t u16
Definition: stdint.h:21
#define FLAG_SET(f, b)
Definition: bnxt.h:45
#define STATUS_SUCCESS
Definition: bnxt.h:58
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static void hwrm_init(struct bnxt *bp, struct input *req, u16 cmd, u16 len)
Definition: bnxt.c:622
uint16_t bp
Definition: registers.h:23
#define BNXT_FLAG_MULTI_HOST
Definition: bnxt.h:51
#define BNXT_FLAG_NPAR_MODE
Definition: bnxt.h:52
#define FUNC_QCFG_RESP_FLAGS_MULTI_HOST
Definition: bnxt_hsi.h:1410
#define HWRM_FUNC_QCFG
Definition: bnxt_hsi.h:108
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static int wait_resp(struct bnxt *bp, u32 tmo, u16 len, const char *func)
Definition: bnxt.c:658
#define DBGP(...)
Definition: compiler.h:532
#define u8
Definition: igbvf_osdep.h:38
#define HWRM_NA_SIGNATURE
Definition: bnxt_hsi.h:362
#define STATUS_FAILURE
Definition: bnxt.h:59
#define ETH_ALEN
Definition: if_ether.h:8
#define dbg_func_qcfg(bp)
Definition: bnxt_dbg.h:322
#define FUNC_QCFG_RESP_PORT_PARTITION_TYPE_NPAR1_0
Definition: bnxt_hsi.h:1426
if(natsemi->flags &NATSEMI_64BIT) return 1

References BNXT_FLAG_MULTI_HOST, BNXT_FLAG_NPAR_MODE, bp, dbg_func_qcfg, DBGP, ETH_ALEN, hwrm_func_qcfg_output::fid, FLAG_SET, hwrm_func_qcfg_output::flags, FUNC_QCFG_RESP_FLAGS_MULTI_HOST, FUNC_QCFG_RESP_PORT_PARTITION_TYPE_NPAR1_0, HWRM_FUNC_QCFG, hwrm_init(), HWRM_NA_SIGNATURE, if(), hwrm_func_qcfg_output::mac_address, memcpy(), hwrm_func_qcfg_output::pci_id, hwrm_func_qcfg_output::port_id, hwrm_func_qcfg_output::port_partition_type, rc, hwrm_func_qcfg_output::stat_ctx_id, STATUS_FAILURE, STATUS_SUCCESS, u16, u8, hwrm_func_qcfg_output::vlan, and wait_resp().

◆ bnxt_hwrm_func_reset_req()

static int bnxt_hwrm_func_reset_req ( struct bnxt bp)
static

Definition at line 918 of file bnxt.c.

919 {
920  u16 cmd_len = ( u16 )sizeof ( struct hwrm_func_reset_input );
921  struct hwrm_func_reset_input *req;
922 
923  DBGP ( "%s\n", __func__ );
924  req = ( struct hwrm_func_reset_input * )bp->hwrm_addr_req;
925  hwrm_init ( bp, ( void * )req, ( u16 )HWRM_FUNC_RESET, cmd_len );
926  if ( !bp->vf )
928 
929  return wait_resp ( bp, HWRM_CMD_WAIT ( 6 ), cmd_len, __func__ );
930 }
#define u16
Definition: vga.h:20
uint16_t u16
Definition: stdint.h:21
#define HWRM_FUNC_RESET
Definition: bnxt_hsi.h:103
static void hwrm_init(struct bnxt *bp, struct input *req, u16 cmd, u16 len)
Definition: bnxt.c:622
uint16_t bp
Definition: registers.h:23
static int wait_resp(struct bnxt *bp, u32 tmo, u16 len, const char *func)
Definition: bnxt.c:658
#define DBGP(...)
Definition: compiler.h:532
#define HWRM_CMD_WAIT(b)
Definition: bnxt.h:136
#define FUNC_RESET_REQ_FUNC_RESET_LEVEL_RESETME
Definition: bnxt_hsi.h:1175

References bp, DBGP, hwrm_func_reset_input::func_reset_level, FUNC_RESET_REQ_FUNC_RESET_LEVEL_RESETME, HWRM_CMD_WAIT, HWRM_FUNC_RESET, hwrm_init(), u16, and wait_resp().

◆ bnxt_hwrm_func_cfg_req()

static int bnxt_hwrm_func_cfg_req ( struct bnxt bp)
static

Definition at line 932 of file bnxt.c.

933 {
934  u16 cmd_len = ( u16 )sizeof ( struct hwrm_func_cfg_input );
935  struct hwrm_func_cfg_input *req;
936 
937  DBGP ( "%s\n", __func__ );
938  if ( bp->vf )
939  return STATUS_SUCCESS;
940 
941  req = ( struct hwrm_func_cfg_input * )bp->hwrm_addr_req;
942  hwrm_init ( bp, ( void * )req, ( u16 )HWRM_FUNC_CFG, cmd_len );
943  req->fid = ( u16 )HWRM_NA_SIGNATURE;
945  if ( bp->thor ) {
949  req->num_msix = 1;
950  req->num_vnics = 1;
952  }
953  return wait_resp ( bp, bp->hwrm_cmd_timeout, cmd_len, __func__ );
954 }
#define u16
Definition: vga.h:20
uint16_t u16
Definition: stdint.h:21
#define STATUS_SUCCESS
Definition: bnxt.h:58
#define HWRM_FUNC_CFG
Definition: bnxt_hsi.h:109
static void hwrm_init(struct bnxt *bp, struct input *req, u16 cmd, u16 len)
Definition: bnxt.c:622
uint16_t bp
Definition: registers.h:23
#define FUNC_CFG_REQ_EVB_MODE_NO_EVB
Definition: bnxt_hsi.h:1607
static int wait_resp(struct bnxt *bp, u32 tmo, u16 len, const char *func)
Definition: bnxt.c:658
#define DBGP(...)
Definition: compiler.h:532
#define HWRM_NA_SIGNATURE
Definition: bnxt_hsi.h:362
static void bnxt_hwrm_assign_resources(struct bnxt *bp)
Definition: bnxt.c:829
#define FUNC_CFG_REQ_ENABLES_EVB_MODE
Definition: bnxt_hsi.h:1547
#define FUNC_CFG_REQ_ENABLES_NUM_MSIX
Definition: bnxt_hsi.h:1551
#define FUNC_CFG_REQ_ENABLES_NUM_VNICS
Definition: bnxt_hsi.h:1537

References bnxt_hwrm_assign_resources(), bp, DBGP, hwrm_func_cfg_input::enables, hwrm_func_cfg_input::evb_mode, hwrm_func_cfg_input::fid, FUNC_CFG_REQ_ENABLES_EVB_MODE, FUNC_CFG_REQ_ENABLES_NUM_MSIX, FUNC_CFG_REQ_ENABLES_NUM_VNICS, FUNC_CFG_REQ_EVB_MODE_NO_EVB, HWRM_FUNC_CFG, hwrm_init(), HWRM_NA_SIGNATURE, hwrm_func_cfg_input::num_msix, hwrm_func_cfg_input::num_vnics, STATUS_SUCCESS, u16, and wait_resp().

◆ bnxt_hwrm_func_drv_rgtr()

static int bnxt_hwrm_func_drv_rgtr ( struct bnxt bp)
static

Definition at line 956 of file bnxt.c.

957 {
958  u16 cmd_len = ( u16 )sizeof ( struct hwrm_func_drv_rgtr_input );
959  struct hwrm_func_drv_rgtr_input *req;
960  int rc;
961 
962  DBGP ( "%s\n", __func__ );
963  req = ( struct hwrm_func_drv_rgtr_input * )bp->hwrm_addr_req;
964  hwrm_init ( bp, ( void * )req, ( u16 )HWRM_FUNC_DRV_RGTR, cmd_len );
965 
966  /* Register with HWRM */
970  req->async_event_fwd[0] |= 0x01;
975  rc = wait_resp ( bp, bp->hwrm_cmd_timeout, cmd_len, __func__ );
976  if ( rc ) {
977  DBGP ( "- %s ( ): Failed\n", __func__ );
978  return STATUS_FAILURE;
979  }
980 
981  FLAG_SET ( bp->flag_hwrm, VALID_DRIVER_REG );
982  return STATUS_SUCCESS;
983 }
#define u16
Definition: vga.h:20
uint16_t u16
Definition: stdint.h:21
#define IPXE_VERSION_MAJOR
Definition: bnxt.h:38
#define FLAG_SET(f, b)
Definition: bnxt.h:45
#define STATUS_SUCCESS
Definition: bnxt.h:58
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define IPXE_VERSION_UPDATE
Definition: bnxt.h:40
#define FUNC_DRV_RGTR_REQ_ENABLES_VER
Definition: bnxt_hsi.h:1736
static void hwrm_init(struct bnxt *bp, struct input *req, u16 cmd, u16 len)
Definition: bnxt.c:622
#define VALID_DRIVER_REG
Definition: bnxt.h:710
uint16_t bp
Definition: registers.h:23
#define FUNC_DRV_RGTR_REQ_OS_TYPE_OTHER
Definition: bnxt_hsi.h:1742
static int wait_resp(struct bnxt *bp, u32 tmo, u16 len, const char *func)
Definition: bnxt.c:658
#define DBGP(...)
Definition: compiler.h:532
#define HWRM_FUNC_DRV_RGTR
Definition: bnxt_hsi.h:115
#define STATUS_FAILURE
Definition: bnxt.h:59
#define FUNC_DRV_RGTR_REQ_ENABLES_OS_TYPE
Definition: bnxt_hsi.h:1735
#define FUNC_DRV_RGTR_REQ_ENABLES_ASYNC_EVENT_FWD
Definition: bnxt_hsi.h:1739
#define IPXE_VERSION_MINOR
Definition: bnxt.h:39

References hwrm_func_drv_rgtr_input::async_event_fwd, bp, DBGP, hwrm_func_drv_rgtr_input::enables, FLAG_SET, FUNC_DRV_RGTR_REQ_ENABLES_ASYNC_EVENT_FWD, FUNC_DRV_RGTR_REQ_ENABLES_OS_TYPE, FUNC_DRV_RGTR_REQ_ENABLES_VER, FUNC_DRV_RGTR_REQ_OS_TYPE_OTHER, HWRM_FUNC_DRV_RGTR, hwrm_init(), IPXE_VERSION_MAJOR, IPXE_VERSION_MINOR, IPXE_VERSION_UPDATE, hwrm_func_drv_rgtr_input::os_type, rc, STATUS_FAILURE, STATUS_SUCCESS, u16, VALID_DRIVER_REG, hwrm_func_drv_rgtr_input::ver_maj, hwrm_func_drv_rgtr_input::ver_min, hwrm_func_drv_rgtr_input::ver_upd, and wait_resp().

◆ bnxt_hwrm_func_drv_unrgtr()

static int bnxt_hwrm_func_drv_unrgtr ( struct bnxt bp)
static

Definition at line 985 of file bnxt.c.

986 {
987  u16 cmd_len = ( u16 )sizeof ( struct hwrm_func_drv_unrgtr_input );
988  struct hwrm_func_drv_unrgtr_input *req;
989  int rc;
990 
991  DBGP ( "%s\n", __func__ );
992  if ( ! ( FLAG_TEST ( bp->flag_hwrm, VALID_DRIVER_REG ) ) )
993  return STATUS_SUCCESS;
994 
995  req = ( struct hwrm_func_drv_unrgtr_input * )bp->hwrm_addr_req;
996  hwrm_init ( bp, ( void * )req, ( u16 )HWRM_FUNC_DRV_UNRGTR, cmd_len );
998  rc = wait_resp ( bp, bp->hwrm_cmd_timeout, cmd_len, __func__ );
999  if ( rc )
1000  return STATUS_FAILURE;
1001 
1002  FLAG_RESET ( bp->flag_hwrm, VALID_DRIVER_REG );
1003  return STATUS_SUCCESS;
1004 }
#define u16
Definition: vga.h:20
uint16_t u16
Definition: stdint.h:21
#define STATUS_SUCCESS
Definition: bnxt.h:58
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define FUNC_DRV_UNRGTR_REQ_FLAGS_PREPARE_FOR_SHUTDOWN
Definition: bnxt_hsi.h:1787
static void hwrm_init(struct bnxt *bp, struct input *req, u16 cmd, u16 len)
Definition: bnxt.c:622
#define FLAG_TEST(f, b)
Definition: bnxt.h:46
#define VALID_DRIVER_REG
Definition: bnxt.h:710
uint16_t bp
Definition: registers.h:23
static int wait_resp(struct bnxt *bp, u32 tmo, u16 len, const char *func)
Definition: bnxt.c:658
#define DBGP(...)
Definition: compiler.h:532
#define STATUS_FAILURE
Definition: bnxt.h:59
#define HWRM_FUNC_DRV_UNRGTR
Definition: bnxt_hsi.h:112
#define FLAG_RESET(f, b)
Definition: bnxt.h:47

References bp, DBGP, FLAG_RESET, FLAG_TEST, hwrm_func_drv_unrgtr_input::flags, FUNC_DRV_UNRGTR_REQ_FLAGS_PREPARE_FOR_SHUTDOWN, HWRM_FUNC_DRV_UNRGTR, hwrm_init(), rc, STATUS_FAILURE, STATUS_SUCCESS, u16, VALID_DRIVER_REG, and wait_resp().

◆ bnxt_hwrm_set_async_event()

static int bnxt_hwrm_set_async_event ( struct bnxt bp)
static

Definition at line 1006 of file bnxt.c.

1007 {
1008  int rc;
1009  u16 idx;
1010 
1011  DBGP ( "%s\n", __func__ );
1012  if ( bp->thor )
1013  idx = bp->nq_ring_id;
1014  else
1015  idx = bp->cq_ring_id;
1016  if ( bp->vf ) {
1017  u16 cmd_len = ( u16 )sizeof ( struct hwrm_func_vf_cfg_input );
1018  struct hwrm_func_vf_cfg_input *req;
1019 
1020  req = ( struct hwrm_func_vf_cfg_input * )bp->hwrm_addr_req;
1021  hwrm_init ( bp, ( void * )req, ( u16 )HWRM_FUNC_VF_CFG,
1022  cmd_len );
1024  req->async_event_cr = idx;
1025  req->mtu = bp->mtu;
1026  req->guest_vlan = bp->vlan_id;
1027  memcpy ( ( char * )&req->dflt_mac_addr[0], bp->mac_addr,
1028  ETH_ALEN );
1029  rc = wait_resp ( bp, bp->hwrm_cmd_timeout, cmd_len, __func__ );
1030  } else {
1031  u16 cmd_len = ( u16 )sizeof ( struct hwrm_func_cfg_input );
1032  struct hwrm_func_cfg_input *req;
1033 
1034  req = ( struct hwrm_func_cfg_input * )bp->hwrm_addr_req;
1035  hwrm_init ( bp, ( void * )req, ( u16 )HWRM_FUNC_CFG, cmd_len );
1036  req->fid = ( u16 )HWRM_NA_SIGNATURE;
1038  req->async_event_cr = idx;
1039  rc = wait_resp ( bp, bp->hwrm_cmd_timeout, cmd_len, __func__ );
1040  }
1041  return rc;
1042 }
#define u16
Definition: vga.h:20
uint16_t u16
Definition: stdint.h:21
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define HWRM_FUNC_CFG
Definition: bnxt_hsi.h:109
static void hwrm_init(struct bnxt *bp, struct input *req, u16 cmd, u16 len)
Definition: bnxt.c:622
uint16_t bp
Definition: registers.h:23
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static int wait_resp(struct bnxt *bp, u32 tmo, u16 len, const char *func)
Definition: bnxt.c:658
#define DBGP(...)
Definition: compiler.h:532
#define FUNC_CFG_REQ_ENABLES_ASYNC_EVENT_CR
Definition: bnxt_hsi.h:1544
#define HWRM_FUNC_VF_CFG
Definition: bnxt_hsi.h:101
#define HWRM_NA_SIGNATURE
Definition: bnxt_hsi.h:362
#define ETH_ALEN
Definition: if_ether.h:8
#define VF_CFG_ENABLE_FLAGS
Definition: bnxt.h:865

References hwrm_func_vf_cfg_input::async_event_cr, hwrm_func_cfg_input::async_event_cr, bp, DBGP, hwrm_func_vf_cfg_input::dflt_mac_addr, hwrm_func_vf_cfg_input::enables, hwrm_func_cfg_input::enables, ETH_ALEN, hwrm_func_cfg_input::fid, FUNC_CFG_REQ_ENABLES_ASYNC_EVENT_CR, hwrm_func_vf_cfg_input::guest_vlan, HWRM_FUNC_CFG, HWRM_FUNC_VF_CFG, hwrm_init(), HWRM_NA_SIGNATURE, memcpy(), hwrm_func_vf_cfg_input::mtu, rc, u16, VF_CFG_ENABLE_FLAGS, and wait_resp().

◆ bnxt_hwrm_cfa_l2_filter_alloc()

static int bnxt_hwrm_cfa_l2_filter_alloc ( struct bnxt bp)
static

Definition at line 1044 of file bnxt.c.

1045 {
1046  u16 cmd_len = ( u16 )sizeof ( struct hwrm_cfa_l2_filter_alloc_input );
1047  struct hwrm_cfa_l2_filter_alloc_input *req;
1048  struct hwrm_cfa_l2_filter_alloc_output *resp;
1049  int rc;
1051  u32 enables;
1052 
1053  DBGP ( "%s\n", __func__ );
1054  req = ( struct hwrm_cfa_l2_filter_alloc_input * )bp->hwrm_addr_req;
1055  resp = ( struct hwrm_cfa_l2_filter_alloc_output * )bp->hwrm_addr_resp;
1056  if ( bp->vf )
1061 
1062  hwrm_init ( bp, ( void * )req, ( u16 )HWRM_CFA_L2_FILTER_ALLOC,
1063  cmd_len );
1064  req->flags = flags;
1065  req->enables = enables;
1066  memcpy ( ( char * )&req->l2_addr[0], ( char * )&bp->mac_addr[0],
1067  ETH_ALEN );
1068  memset ( ( char * )&req->l2_addr_mask[0], 0xff, ETH_ALEN );
1069  if ( !bp->vf ) {
1070  memcpy ( ( char * )&req->t_l2_addr[0], bp->mac_addr, ETH_ALEN );
1071  memset ( ( char * )&req->t_l2_addr_mask[0], 0xff, ETH_ALEN );
1072  }
1074  req->src_id = ( u32 )bp->port_idx;
1075  req->dst_id = bp->vnic_id;
1076  rc = wait_resp ( bp, bp->hwrm_cmd_timeout, cmd_len, __func__ );
1077  if ( rc )
1078  return STATUS_FAILURE;
1079 
1080  FLAG_SET ( bp->flag_hwrm, VALID_L2_FILTER );
1081  bp->l2_filter_id = resp->l2_filter_id;
1082  return STATUS_SUCCESS;
1083 }
#define u16
Definition: vga.h:20
uint16_t u16
Definition: stdint.h:21
#define FLAG_SET(f, b)
Definition: bnxt.h:45
#define STATUS_SUCCESS
Definition: bnxt.h:58
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define CFA_L2_FILTER_ALLOC_REQ_ENABLES_DST_ID
Definition: bnxt_hsi.h:6229
static void hwrm_init(struct bnxt *bp, struct input *req, u16 cmd, u16 len)
Definition: bnxt.c:622
uint16_t bp
Definition: registers.h:23
#define CFA_L2_FILTER_ALLOC_REQ_FLAGS_PATH_RX
Definition: bnxt_hsi.h:6202
#define CFA_L2_FILTER_ALLOC_REQ_ENABLES_L2_ADDR_MASK
Definition: bnxt_hsi.h:6215
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static int wait_resp(struct bnxt *bp, u32 tmo, u16 len, const char *func)
Definition: bnxt.c:658
#define DBGP(...)
Definition: compiler.h:532
#define HWRM_CFA_L2_FILTER_ALLOC
Definition: bnxt_hsi.h:171
#define u32
Definition: vga.h:21
#define STATUS_FAILURE
Definition: bnxt.h:59
#define VALID_L2_FILTER
Definition: bnxt.h:718
#define ETH_ALEN
Definition: if_ether.h:8
#define CFA_L2_FILTER_ALLOC_REQ_SRC_TYPE_NPORT
Definition: bnxt_hsi.h:6247
#define CFA_L2_FILTER_ALLOC_REQ_ENABLES_L2_ADDR
Definition: bnxt_hsi.h:6214
#define CFA_L2_FILTER_ALLOC_REQ_FLAGS_OUTERMOST
Definition: bnxt_hsi.h:6206
uint32_t u32
Definition: stdint.h:23
void * memset(void *dest, int character, size_t len) __nonnull
uint8_t flags
Flags.
Definition: ena.h:18

References bp, CFA_L2_FILTER_ALLOC_REQ_ENABLES_DST_ID, CFA_L2_FILTER_ALLOC_REQ_ENABLES_L2_ADDR, CFA_L2_FILTER_ALLOC_REQ_ENABLES_L2_ADDR_MASK, CFA_L2_FILTER_ALLOC_REQ_FLAGS_OUTERMOST, CFA_L2_FILTER_ALLOC_REQ_FLAGS_PATH_RX, CFA_L2_FILTER_ALLOC_REQ_SRC_TYPE_NPORT, DBGP, hwrm_cfa_l2_filter_alloc_input::enables, ETH_ALEN, FLAG_SET, flags, HWRM_CFA_L2_FILTER_ALLOC, hwrm_init(), hwrm_cfa_l2_filter_alloc_output::l2_filter_id, memcpy(), memset(), rc, STATUS_FAILURE, STATUS_SUCCESS, u16, u32, VALID_L2_FILTER, and wait_resp().

◆ bnxt_hwrm_cfa_l2_filter_free()

static int bnxt_hwrm_cfa_l2_filter_free ( struct bnxt bp)
static

Definition at line 1085 of file bnxt.c.

1086 {
1087  u16 cmd_len = ( u16 )sizeof ( struct hwrm_cfa_l2_filter_free_input );
1088  struct hwrm_cfa_l2_filter_free_input *req;
1089  int rc;
1090 
1091  DBGP ( "%s\n", __func__ );
1092  if ( ! ( FLAG_TEST ( bp->flag_hwrm, VALID_L2_FILTER ) ) )
1093  return STATUS_SUCCESS;
1094 
1095  req = ( struct hwrm_cfa_l2_filter_free_input * )bp->hwrm_addr_req;
1096  hwrm_init ( bp, ( void * )req, ( u16 )HWRM_CFA_L2_FILTER_FREE,
1097  cmd_len );
1098  req->l2_filter_id = bp->l2_filter_id;
1099  rc = wait_resp ( bp, bp->hwrm_cmd_timeout, cmd_len, __func__ );
1100  if ( rc ) {
1101  DBGP ( "- %s ( ): Failed\n", __func__ );
1102  return STATUS_FAILURE;
1103  }
1104 
1105  FLAG_RESET ( bp->flag_hwrm, VALID_L2_FILTER );
1106  return STATUS_SUCCESS;
1107 }
#define u16
Definition: vga.h:20
uint16_t u16
Definition: stdint.h:21
#define STATUS_SUCCESS
Definition: bnxt.h:58
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define HWRM_CFA_L2_FILTER_FREE
Definition: bnxt_hsi.h:172
static void hwrm_init(struct bnxt *bp, struct input *req, u16 cmd, u16 len)
Definition: bnxt.c:622
#define FLAG_TEST(f, b)
Definition: bnxt.h:46
uint16_t bp
Definition: registers.h:23
static int wait_resp(struct bnxt *bp, u32 tmo, u16 len, const char *func)
Definition: bnxt.c:658
#define DBGP(...)
Definition: compiler.h:532
#define STATUS_FAILURE
Definition: bnxt.h:59
#define VALID_L2_FILTER
Definition: bnxt.h:718
#define FLAG_RESET(f, b)
Definition: bnxt.h:47

References bp, DBGP, FLAG_RESET, FLAG_TEST, HWRM_CFA_L2_FILTER_FREE, hwrm_init(), hwrm_cfa_l2_filter_free_input::l2_filter_id, rc, STATUS_FAILURE, STATUS_SUCCESS, u16, VALID_L2_FILTER, and wait_resp().

◆ set_rx_mask()

u32 set_rx_mask ( u32  rx_mask)

Definition at line 1109 of file bnxt.c.

1110 {
1111  u32 mask = 0;
1112 
1113  if ( !rx_mask )
1114  return mask;
1115 
1117  if ( rx_mask != RX_MASK_ACCEPT_NONE ) {
1118  if ( rx_mask & RX_MASK_ACCEPT_MULTICAST )
1120  if ( rx_mask & RX_MASK_ACCEPT_ALL_MULTICAST )
1122  if ( rx_mask & RX_MASK_PROMISCUOUS_MODE )
1124  }
1125  return mask;
1126 }
#define CFA_L2_SET_RX_MASK_REQ_MASK_PROMISCUOUS
Definition: bnxt_hsi.h:6369
#define CFA_L2_SET_RX_MASK_REQ_MASK_BCAST
Definition: bnxt_hsi.h:6368
#define RX_MASK_PROMISCUOUS_MODE
Definition: bnxt.h:92
#define RX_MASK_ACCEPT_NONE
Definition: bnxt.h:86
#define CFA_L2_SET_RX_MASK_REQ_MASK_MCAST
Definition: bnxt_hsi.h:6366
#define RX_MASK_ACCEPT_ALL_MULTICAST
Definition: bnxt.h:89
#define RX_MASK_ACCEPT_MULTICAST
Definition: bnxt.h:88
#define CFA_L2_SET_RX_MASK_REQ_MASK_ALL_MCAST
Definition: bnxt_hsi.h:6367
uint32_t u32
Definition: stdint.h:23

References CFA_L2_SET_RX_MASK_REQ_MASK_ALL_MCAST, CFA_L2_SET_RX_MASK_REQ_MASK_BCAST, CFA_L2_SET_RX_MASK_REQ_MASK_MCAST, CFA_L2_SET_RX_MASK_REQ_MASK_PROMISCUOUS, RX_MASK_ACCEPT_ALL_MULTICAST, RX_MASK_ACCEPT_MULTICAST, RX_MASK_ACCEPT_NONE, and RX_MASK_PROMISCUOUS_MODE.

Referenced by bnxt_hwrm_set_rx_mask().

◆ bnxt_hwrm_set_rx_mask()

static int bnxt_hwrm_set_rx_mask ( struct bnxt bp,
u32  rx_mask 
)
static

Definition at line 1128 of file bnxt.c.

1129 {
1130  u16 cmd_len = ( u16 )sizeof ( struct hwrm_cfa_l2_set_rx_mask_input );
1131  struct hwrm_cfa_l2_set_rx_mask_input *req;
1132  u32 mask = set_rx_mask ( rx_mask );
1133 
1134  req = ( struct hwrm_cfa_l2_set_rx_mask_input * )bp->hwrm_addr_req;
1135  hwrm_init ( bp, ( void * )req, ( u16 )HWRM_CFA_L2_SET_RX_MASK,
1136  cmd_len );
1137  req->vnic_id = bp->vnic_id;
1138  req->mask = mask;
1139 
1140  return wait_resp ( bp, bp->hwrm_cmd_timeout, cmd_len, __func__ );
1141 }
#define u16
Definition: vga.h:20
uint16_t u16
Definition: stdint.h:21
static void hwrm_init(struct bnxt *bp, struct input *req, u16 cmd, u16 len)
Definition: bnxt.c:622
uint16_t bp
Definition: registers.h:23
static int wait_resp(struct bnxt *bp, u32 tmo, u16 len, const char *func)
Definition: bnxt.c:658
#define HWRM_CFA_L2_SET_RX_MASK
Definition: bnxt_hsi.h:174
u32 set_rx_mask(u32 rx_mask)
Definition: bnxt.c:1109
uint32_t u32
Definition: stdint.h:23

References bp, HWRM_CFA_L2_SET_RX_MASK, hwrm_init(), hwrm_cfa_l2_set_rx_mask_input::mask, set_rx_mask(), u16, hwrm_cfa_l2_set_rx_mask_input::vnic_id, and wait_resp().

Referenced by bnxt_reset_rx_mask(), and bnxt_set_rx_mask().

◆ bnxt_hwrm_port_phy_qcfg()

static int bnxt_hwrm_port_phy_qcfg ( struct bnxt bp,
u16  idx 
)
static

Definition at line 1143 of file bnxt.c.

1144 {
1145  u16 cmd_len = ( u16 )sizeof ( struct hwrm_port_phy_qcfg_input );
1146  struct hwrm_port_phy_qcfg_input *req;
1147  struct hwrm_port_phy_qcfg_output *resp;
1148  int rc;
1149 
1150  DBGP ( "%s\n", __func__ );
1151  req = ( struct hwrm_port_phy_qcfg_input * )bp->hwrm_addr_req;
1152  resp = ( struct hwrm_port_phy_qcfg_output * )bp->hwrm_addr_resp;
1153  hwrm_init ( bp, ( void * )req, ( u16 )HWRM_PORT_PHY_QCFG, cmd_len );
1154  rc = wait_resp ( bp, bp->hwrm_cmd_timeout, cmd_len, __func__ );
1155  if ( rc ) {
1156  DBGP ( "- %s ( ): Failed\n", __func__ );
1157  return STATUS_FAILURE;
1158  }
1159 
1160  if ( idx & SUPPORT_SPEEDS )
1161  bp->support_speeds = resp->support_speeds;
1162 
1163  if ( idx & DETECT_MEDIA )
1164  bp->media_detect = resp->module_status;
1165 
1166  if ( idx & PHY_SPEED )
1167  bp->current_link_speed = resp->link_speed;
1168 
1169  if ( idx & PHY_STATUS ) {
1170  if ( resp->link == PORT_PHY_QCFG_RESP_LINK_LINK )
1171  bp->link_status = STATUS_LINK_ACTIVE;
1172  else
1173  bp->link_status = STATUS_LINK_DOWN;
1174  }
1175  return STATUS_SUCCESS;
1176 }
#define u16
Definition: vga.h:20
uint16_t u16
Definition: stdint.h:21
#define STATUS_SUCCESS
Definition: bnxt.h:58
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define DETECT_MEDIA
Definition: bnxt.h:195
static void hwrm_init(struct bnxt *bp, struct input *req, u16 cmd, u16 len)
Definition: bnxt.c:622
uint16_t bp
Definition: registers.h:23
#define STATUS_LINK_DOWN
Definition: bnxt.h:63
#define PORT_PHY_QCFG_RESP_LINK_LINK
Definition: bnxt_hsi.h:3099
#define PHY_STATUS
Definition: bnxt.h:193
#define STATUS_LINK_ACTIVE
Definition: bnxt.h:62
static int wait_resp(struct bnxt *bp, u32 tmo, u16 len, const char *func)
Definition: bnxt.c:658
#define DBGP(...)
Definition: compiler.h:532
#define SUPPORT_SPEEDS
Definition: bnxt.h:196
#define STATUS_FAILURE
Definition: bnxt.h:59
#define PHY_SPEED
Definition: bnxt.h:194
#define HWRM_PORT_PHY_QCFG
Definition: bnxt_hsi.h:125

References bp, DBGP, DETECT_MEDIA, hwrm_init(), HWRM_PORT_PHY_QCFG, hwrm_port_phy_qcfg_output::link, hwrm_port_phy_qcfg_output::link_speed, hwrm_port_phy_qcfg_output::module_status, PHY_SPEED, PHY_STATUS, PORT_PHY_QCFG_RESP_LINK_LINK, rc, STATUS_FAILURE, STATUS_LINK_ACTIVE, STATUS_LINK_DOWN, STATUS_SUCCESS, SUPPORT_SPEEDS, hwrm_port_phy_qcfg_output::support_speeds, u16, and wait_resp().

Referenced by bnxt_get_phy_link(), and bnxt_query_phy_link().

◆ bnxt_hwrm_nvm_get_variable_req()

static int bnxt_hwrm_nvm_get_variable_req ( struct bnxt bp,
u16  data_len,
u16  option_num,
u16  dimensions,
u16  index_0 
)
static

Definition at line 1178 of file bnxt.c.

1180 {
1181  u16 cmd_len = ( u16 )sizeof ( struct hwrm_nvm_get_variable_input );
1182  struct hwrm_nvm_get_variable_input *req;
1183 
1184  DBGP ( "%s\n", __func__ );
1185  req = ( struct hwrm_nvm_get_variable_input * )bp->hwrm_addr_req;
1186  hwrm_init ( bp, ( void * )req, ( u16 )HWRM_NVM_GET_VARIABLE, cmd_len );
1187  req->dest_data_addr = bp->dma_addr_mapping;
1188  req->data_len = data_len;
1189  req->option_num = option_num;
1190  req->dimensions = dimensions;
1191  req->index_0 = index_0;
1192  return wait_resp ( bp,
1193  HWRM_CMD_FLASH_MULTIPLAYER ( bp->hwrm_cmd_timeout ),
1194  cmd_len, __func__ );
1195 }
#define u16
Definition: vga.h:20
uint16_t u16
Definition: stdint.h:21
#define HWRM_CMD_FLASH_MULTIPLAYER(a)
Definition: bnxt.h:134
static void hwrm_init(struct bnxt *bp, struct input *req, u16 cmd, u16 len)
Definition: bnxt.c:622
uint16_t bp
Definition: registers.h:23
static int wait_resp(struct bnxt *bp, u32 tmo, u16 len, const char *func)
Definition: bnxt.c:658
#define DBGP(...)
Definition: compiler.h:532
#define HWRM_NVM_GET_VARIABLE
Definition: bnxt_hsi.h:308

References bp, hwrm_nvm_get_variable_input::data_len, DBGP, hwrm_nvm_get_variable_input::dest_data_addr, hwrm_nvm_get_variable_input::dimensions, HWRM_CMD_FLASH_MULTIPLAYER, hwrm_init(), HWRM_NVM_GET_VARIABLE, hwrm_nvm_get_variable_input::index_0, hwrm_nvm_get_variable_input::option_num, u16, and wait_resp().

Referenced by bnxt_get_link_speed(), and bnxt_get_vlan().

◆ bnxt_get_link_speed()

static int bnxt_get_link_speed ( struct bnxt bp)
static

Definition at line 1197 of file bnxt.c.

1198 {
1199  u32 *ptr32 = ( u32 * )bp->hwrm_addr_dma;
1200 
1201  DBGP ( "%s\n", __func__ );
1204  1, ( u16 )bp->port_idx ) != STATUS_SUCCESS )
1205  return STATUS_FAILURE;
1206  bp->link_set = SET_LINK ( *ptr32, SPEED_DRV_MASK, SPEED_DRV_SHIFT );
1209  1, ( u16 )bp->port_idx ) != STATUS_SUCCESS )
1210  return STATUS_FAILURE;
1211  bp->link_set |= SET_LINK ( *ptr32, SPEED_FW_MASK, SPEED_FW_SHIFT );
1213  ( u16 )D3_LINK_SPEED_FW_NUM, 1,
1214  ( u16 )bp->port_idx ) != STATUS_SUCCESS )
1215  return STATUS_FAILURE;
1216  bp->link_set |= SET_LINK ( *ptr32, D3_SPEED_FW_MASK,
1220  1, ( u16 )bp->port_idx ) != STATUS_SUCCESS )
1221  return STATUS_FAILURE;
1222  bp->link_set |= SET_LINK ( *ptr32,
1224 
1225  switch ( bp->link_set & LINK_SPEED_DRV_MASK ) {
1226  case LINK_SPEED_DRV_1G:
1228  break;
1229  case LINK_SPEED_DRV_2_5G:
1231  break;
1232  case LINK_SPEED_DRV_10G:
1233  bp->medium = SET_MEDIUM_SPEED ( bp, MEDIUM_SPEED_10GBPS );
1234  break;
1235  case LINK_SPEED_DRV_25G:
1236  bp->medium = SET_MEDIUM_SPEED ( bp, MEDIUM_SPEED_25GBPS );
1237  break;
1238  case LINK_SPEED_DRV_40G:
1239  bp->medium = SET_MEDIUM_SPEED ( bp, MEDIUM_SPEED_40GBPS );
1240  break;
1241  case LINK_SPEED_DRV_50G:
1242  bp->medium = SET_MEDIUM_SPEED ( bp, MEDIUM_SPEED_50GBPS );
1243  break;
1244  case LINK_SPEED_DRV_100G:
1245  bp->medium = SET_MEDIUM_SPEED ( bp, MEDIUM_SPEED_100GBPS );
1246  break;
1247  case LINK_SPEED_DRV_200G:
1248  bp->medium = SET_MEDIUM_SPEED ( bp, MEDIUM_SPEED_200GBPS );
1249  break;
1251  bp->medium = SET_MEDIUM_SPEED ( bp, MEDIUM_SPEED_AUTONEG );
1252  break;
1253  default:
1254  bp->medium = SET_MEDIUM_DUPLEX ( bp, MEDIUM_FULL_DUPLEX );
1255  break;
1256  }
1257  prn_set_speed ( bp->link_set );
1258  return STATUS_SUCCESS;
1259 }
uint16_t u16
Definition: stdint.h:21
#define LINK_SPEED_DRV_2_5G
Definition: bnxt.h:224
#define STATUS_SUCCESS
Definition: bnxt.h:58
#define MEDIA_AUTO_DETECT_MASK
Definition: bnxt.h:859
#define MEDIUM_SPEED_2500MBPS
Definition: bnxt.h:101
#define test_if
Definition: bnxt.h:825
#define LINK_SPEED_DRV_AUTONEG
Definition: bnxt.h:208
uint16_t bp
Definition: registers.h:23
#define D3_LINK_SPEED_FW_NUM
Definition: bnxt.h:295
#define D3_SPEED_FW_SHIFT
Definition: bnxt.h:858
#define LINK_SPEED_DRV_NUM
Definition: bnxt.h:205
#define MEDIUM_SPEED_10GBPS
Definition: bnxt.h:102
static int bnxt_hwrm_nvm_get_variable_req(struct bnxt *bp, u16 data_len, u16 option_num, u16 dimensions, u16 index_0)
Definition: bnxt.c:1178
#define D3_SPEED_FW_MASK
Definition: bnxt.h:857
#define MEDIUM_SPEED_50GBPS
Definition: bnxt.h:106
#define MEDIUM_SPEED_200GBPS
Definition: bnxt.h:108
#define MEDIUM_SPEED_25GBPS
Definition: bnxt.h:104
#define LINK_SPEED_FW_NUM
Definition: bnxt.h:271
#define LINK_SPEED_DRV_40G
Definition: bnxt.h:216
#define DBGP(...)
Definition: compiler.h:532
#define SPEED_FW_SHIFT
Definition: bnxt.h:856
#define PORT_CFG_LINK_SETTINGS_MEDIA_AUTO_DETECT_NUM
Definition: bnxt.h:333
#define STATUS_FAILURE
Definition: bnxt.h:59
#define LINK_SPEED_DRV_MASK
Definition: bnxt.h:206
#define MEDIUM_SPEED_1000MBPS
Definition: bnxt.h:100
#define LINK_SPEED_DRV_10G
Definition: bnxt.h:212
#define MEDIUM_SPEED_AUTONEG
Definition: bnxt.h:96
#define prn_set_speed(speed)
Definition: bnxt_dbg.h:323
#define SPEED_DRV_SHIFT
Definition: bnxt.h:854
#define MEDIUM_FULL_DUPLEX
Definition: bnxt.h:116
#define LINK_SPEED_DRV_50G
Definition: bnxt.h:218
#define LINK_SPEED_DRV_200G
Definition: bnxt.h:222
#define SPEED_FW_MASK
Definition: bnxt.h:855
#define SET_MEDIUM_DUPLEX(bp, d)
Definition: bnxt.h:119
#define SPEED_DRV_MASK
Definition: bnxt.h:853
#define LINK_SPEED_DRV_100G
Definition: bnxt.h:220
#define MEDIUM_SPEED_40GBPS
Definition: bnxt.h:105
#define LINK_SPEED_DRV_1G
Definition: bnxt.h:210
#define MEDIUM_SPEED_100GBPS
Definition: bnxt.h:107
#define SET_LINK(p, m, s)
Definition: bnxt.h:851
#define SET_MEDIUM_SPEED(bp, s)
Definition: bnxt.h:114
uint32_t u32
Definition: stdint.h:23
#define MEDIA_AUTO_DETECT_SHIFT
Definition: bnxt.h:860
#define LINK_SPEED_DRV_25G
Definition: bnxt.h:214

References bnxt_hwrm_nvm_get_variable_req(), bp, D3_LINK_SPEED_FW_NUM, D3_SPEED_FW_MASK, D3_SPEED_FW_SHIFT, DBGP, LINK_SPEED_DRV_100G, LINK_SPEED_DRV_10G, LINK_SPEED_DRV_1G, LINK_SPEED_DRV_200G, LINK_SPEED_DRV_25G, LINK_SPEED_DRV_2_5G, LINK_SPEED_DRV_40G, LINK_SPEED_DRV_50G, LINK_SPEED_DRV_AUTONEG, LINK_SPEED_DRV_MASK, LINK_SPEED_DRV_NUM, LINK_SPEED_FW_NUM, MEDIA_AUTO_DETECT_MASK, MEDIA_AUTO_DETECT_SHIFT, MEDIUM_FULL_DUPLEX, MEDIUM_SPEED_1000MBPS, MEDIUM_SPEED_100GBPS, MEDIUM_SPEED_10GBPS, MEDIUM_SPEED_200GBPS, MEDIUM_SPEED_2500MBPS, MEDIUM_SPEED_25GBPS, MEDIUM_SPEED_40GBPS, MEDIUM_SPEED_50GBPS, MEDIUM_SPEED_AUTONEG, PORT_CFG_LINK_SETTINGS_MEDIA_AUTO_DETECT_NUM, prn_set_speed, SET_LINK, SET_MEDIUM_DUPLEX, SET_MEDIUM_SPEED, SPEED_DRV_MASK, SPEED_DRV_SHIFT, SPEED_FW_MASK, SPEED_FW_SHIFT, STATUS_FAILURE, STATUS_SUCCESS, and test_if.

Referenced by bnxt_query_phy_link().

◆ bnxt_get_vlan()

static int bnxt_get_vlan ( struct bnxt bp)
static

Definition at line 1261 of file bnxt.c.

1262 {
1263  u32 *ptr32 = ( u32 * )bp->hwrm_addr_dma;
1264 
1265  /* If VF is set to TRUE, Do not issue this command */
1266  if ( bp->vf )
1267  return STATUS_SUCCESS;
1268 
1271  ( u16 )bp->ordinal_value ) != STATUS_SUCCESS )
1272  return STATUS_FAILURE;
1273 
1274  bp->mba_cfg2 = SET_MBA ( *ptr32, VLAN_MASK, VLAN_SHIFT );
1277  ( u16 )bp->ordinal_value ) != STATUS_SUCCESS )
1278  return STATUS_FAILURE;
1279 
1280  bp->mba_cfg2 |= SET_MBA ( *ptr32, VLAN_VALUE_MASK, VLAN_VALUE_SHIFT );
1281  if ( bp->mba_cfg2 & FUNC_CFG_PRE_BOOT_MBA_VLAN_ENABLED )
1282  bp->vlan_id = bp->mba_cfg2 & VLAN_VALUE_MASK;
1283  else
1284  bp->vlan_id = 0;
1285 
1286  if ( bp->mba_cfg2 & FUNC_CFG_PRE_BOOT_MBA_VLAN_ENABLED )
1287  DBGP ( "VLAN MBA Enabled ( %d )\n",
1288  ( bp->mba_cfg2 & VLAN_VALUE_MASK ) );
1289 
1290  return STATUS_SUCCESS;
1291 }
uint16_t u16
Definition: stdint.h:21
#define STATUS_SUCCESS
Definition: bnxt.h:58
#define VLAN_VALUE_MASK
Definition: bnxt.h:863
#define test_if
Definition: bnxt.h:825
uint16_t bp
Definition: registers.h:23
#define SET_MBA(p, m, s)
Definition: bnxt.h:852
static int bnxt_hwrm_nvm_get_variable_req(struct bnxt *bp, u16 data_len, u16 option_num, u16 dimensions, u16 index_0)
Definition: bnxt.c:1178
#define VLAN_VALUE_SHIFT
Definition: bnxt.h:864
#define DBGP(...)
Definition: compiler.h:532
#define STATUS_FAILURE
Definition: bnxt.h:59
#define VLAN_SHIFT
Definition: bnxt.h:862
#define FUNC_CFG_PRE_BOOT_MBA_VLAN_VALUE_NUM
Definition: bnxt.h:341
#define FUNC_CFG_PRE_BOOT_MBA_VLAN_NUM
Definition: bnxt.h:345
#define FUNC_CFG_PRE_BOOT_MBA_VLAN_ENABLED
Definition: bnxt.h:350
#define VLAN_MASK
Definition: bnxt.h:861
uint32_t u32
Definition: stdint.h:23
if(natsemi->flags &NATSEMI_64BIT) return 1

References bnxt_hwrm_nvm_get_variable_req(), bp, DBGP, FUNC_CFG_PRE_BOOT_MBA_VLAN_ENABLED, FUNC_CFG_PRE_BOOT_MBA_VLAN_NUM, FUNC_CFG_PRE_BOOT_MBA_VLAN_VALUE_NUM, if(), SET_MBA, STATUS_FAILURE, STATUS_SUCCESS, test_if, VLAN_MASK, VLAN_SHIFT, VLAN_VALUE_MASK, and VLAN_VALUE_SHIFT.

◆ bnxt_hwrm_backing_store_qcfg()

static int bnxt_hwrm_backing_store_qcfg ( struct bnxt bp)
static

Definition at line 1293 of file bnxt.c.

1294 {
1295  u16 cmd_len = ( u16 )sizeof ( struct hwrm_func_backing_store_qcfg_input );
1297 
1298  DBGP ( "%s\n", __func__ );
1299  if ( !bp->thor )
1300  return STATUS_SUCCESS;
1301 
1302  req = ( struct hwrm_func_backing_store_qcfg_input * )bp->hwrm_addr_req;
1303  hwrm_init ( bp, ( void * )req, ( u16 )HWRM_FUNC_BACKING_STORE_QCFG,
1304  cmd_len );
1305  return wait_resp ( bp, bp->hwrm_cmd_timeout, cmd_len, __func__ );
1306 }
#define u16
Definition: vga.h:20
uint16_t u16
Definition: stdint.h:21
#define STATUS_SUCCESS
Definition: bnxt.h:58
static void hwrm_init(struct bnxt *bp, struct input *req, u16 cmd, u16 len)
Definition: bnxt.c:622
uint16_t bp
Definition: registers.h:23
static int wait_resp(struct bnxt *bp, u32 tmo, u16 len, const char *func)
Definition: bnxt.c:658
#define DBGP(...)
Definition: compiler.h:532
#define HWRM_FUNC_BACKING_STORE_QCFG
Definition: bnxt_hsi.h:284

References bp, DBGP, HWRM_FUNC_BACKING_STORE_QCFG, hwrm_init(), STATUS_SUCCESS, u16, and wait_resp().

◆ bnxt_hwrm_backing_store_cfg()

static int bnxt_hwrm_backing_store_cfg ( struct bnxt bp)
static

Definition at line 1308 of file bnxt.c.

1309 {
1310  u16 cmd_len = ( u16 )sizeof ( struct hwrm_func_backing_store_cfg_input );
1312 
1313  DBGP ( "%s\n", __func__ );
1314  if ( !bp->thor )
1315  return STATUS_SUCCESS;
1316 
1317  req = ( struct hwrm_func_backing_store_cfg_input * )bp->hwrm_addr_req;
1318  hwrm_init ( bp, ( void * )req, ( u16 )HWRM_FUNC_BACKING_STORE_CFG,
1319  cmd_len );
1321  req->enables = 0;
1322  return wait_resp ( bp, HWRM_CMD_WAIT ( 6 ), cmd_len, __func__ );
1323 }
#define u16
Definition: vga.h:20
uint16_t u16
Definition: stdint.h:21
#define STATUS_SUCCESS
Definition: bnxt.h:58
static void hwrm_init(struct bnxt *bp, struct input *req, u16 cmd, u16 len)
Definition: bnxt.c:622
uint16_t bp
Definition: registers.h:23
#define HWRM_FUNC_BACKING_STORE_CFG
Definition: bnxt_hsi.h:283
static int wait_resp(struct bnxt *bp, u32 tmo, u16 len, const char *func)
Definition: bnxt.c:658
#define DBGP(...)
Definition: compiler.h:532
#define HWRM_CMD_WAIT(b)
Definition: bnxt.h:136
#define FUNC_BACKING_STORE_CFG_REQ_FLAGS_PREBOOT_MODE
Definition: bnxt_hsi.h:2060

References bp, DBGP, hwrm_func_backing_store_cfg_input::enables, hwrm_func_backing_store_cfg_input::flags, FUNC_BACKING_STORE_CFG_REQ_FLAGS_PREBOOT_MODE, HWRM_CMD_WAIT, HWRM_FUNC_BACKING_STORE_CFG, hwrm_init(), STATUS_SUCCESS, u16, and wait_resp().

◆ bnxt_hwrm_queue_qportcfg()

static int bnxt_hwrm_queue_qportcfg ( struct bnxt bp)
static

Definition at line 1325 of file bnxt.c.

1326 {
1327  u16 cmd_len = ( u16 )sizeof ( struct hwrm_queue_qportcfg_input );
1328  struct hwrm_queue_qportcfg_input *req;
1329  struct hwrm_queue_qportcfg_output *resp;
1330  int rc;
1331 
1332  DBGP ( "%s\n", __func__ );
1333  if ( !bp->thor )
1334  return STATUS_SUCCESS;
1335 
1336  req = ( struct hwrm_queue_qportcfg_input * )bp->hwrm_addr_req;
1337  resp = ( struct hwrm_queue_qportcfg_output * )bp->hwrm_addr_resp;
1338  hwrm_init ( bp, ( void * )req, ( u16 )HWRM_QUEUE_QPORTCFG, cmd_len );
1339  req->flags = 0;
1340  req->port_id = 0;
1341  rc = wait_resp ( bp, bp->hwrm_cmd_timeout, cmd_len, __func__ );
1342  if ( rc ) {
1343  DBGP ( "- %s ( ): Failed\n", __func__ );
1344  return STATUS_FAILURE;
1345  }
1346 
1347  bp->queue_id = resp->queue_id0;
1348  return STATUS_SUCCESS;
1349 }
#define u16
Definition: vga.h:20
uint16_t u16
Definition: stdint.h:21
#define STATUS_SUCCESS
Definition: bnxt.h:58
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static void hwrm_init(struct bnxt *bp, struct input *req, u16 cmd, u16 len)
Definition: bnxt.c:622
uint16_t bp
Definition: registers.h:23
static int wait_resp(struct bnxt *bp, u32 tmo, u16 len, const char *func)
Definition: bnxt.c:658
#define DBGP(...)
Definition: compiler.h:532
#define HWRM_QUEUE_QPORTCFG
Definition: bnxt_hsi.h:134
#define STATUS_FAILURE
Definition: bnxt.h:59

References bp, DBGP, hwrm_init(), HWRM_QUEUE_QPORTCFG, hwrm_queue_qportcfg_output::queue_id0, rc, STATUS_FAILURE, STATUS_SUCCESS, u16, and wait_resp().

◆ bnxt_hwrm_port_mac_cfg()

static int bnxt_hwrm_port_mac_cfg ( struct bnxt bp)
static

Definition at line 1351 of file bnxt.c.

1352 {
1353  u16 cmd_len = ( u16 )sizeof ( struct hwrm_port_mac_cfg_input );
1354  struct hwrm_port_mac_cfg_input *req;
1355 
1356  DBGP ( "%s\n", __func__ );
1357  if ( bp->vf )
1358  return STATUS_SUCCESS;
1359 
1360  req = ( struct hwrm_port_mac_cfg_input * )bp->hwrm_addr_req;
1361  hwrm_init ( bp, ( void * )req, ( u16 )HWRM_PORT_MAC_CFG, cmd_len );
1363  return wait_resp ( bp, bp->hwrm_cmd_timeout, cmd_len, __func__ );
1364 }
#define u16
Definition: vga.h:20
uint16_t u16
Definition: stdint.h:21
#define STATUS_SUCCESS
Definition: bnxt.h:58
#define HWRM_PORT_MAC_CFG
Definition: bnxt_hsi.h:119
static void hwrm_init(struct bnxt *bp, struct input *req, u16 cmd, u16 len)
Definition: bnxt.c:622
uint16_t bp
Definition: registers.h:23
static int wait_resp(struct bnxt *bp, u32 tmo, u16 len, const char *func)
Definition: bnxt.c:658
#define DBGP(...)
Definition: compiler.h:532
#define PORT_MAC_CFG_REQ_LPBK_NONE
Definition: bnxt_hsi.h:3378

References bp, DBGP, hwrm_init(), HWRM_PORT_MAC_CFG, hwrm_port_mac_cfg_input::lpbk, PORT_MAC_CFG_REQ_LPBK_NONE, STATUS_SUCCESS, u16, and wait_resp().

◆ bnxt_hwrm_port_phy_cfg()

static int bnxt_hwrm_port_phy_cfg ( struct bnxt bp)
static

Definition at line 1366 of file bnxt.c.

1367 {
1368  u16 cmd_len = ( u16 )sizeof ( struct hwrm_port_phy_cfg_input );
1369  struct hwrm_port_phy_cfg_input *req;
1370  u32 flags;
1371  u32 enables = 0;
1372  u16 force_link_speed = 0;
1374  u8 auto_mode = 0;
1375  u8 auto_pause = 0;
1376  u8 auto_duplex = 0;
1377 
1378  DBGP ( "%s\n", __func__ );
1379  req = ( struct hwrm_port_phy_cfg_input * )bp->hwrm_addr_req;
1382 
1383  switch ( GET_MEDIUM_SPEED ( bp->medium ) ) {
1384  case MEDIUM_SPEED_1000MBPS:
1386  break;
1387  case MEDIUM_SPEED_10GBPS:
1389  break;
1390  case MEDIUM_SPEED_25GBPS:
1392  break;
1393  case MEDIUM_SPEED_40GBPS:
1395  break;
1396  case MEDIUM_SPEED_50GBPS:
1398  break;
1399  case MEDIUM_SPEED_100GBPS:
1401  break;
1402  case MEDIUM_SPEED_200GBPS:
1404  break;
1405  default:
1415  auto_link_speed_mask = bp->support_speeds;
1416  break;
1417  }
1418 
1419  hwrm_init ( bp, ( void * )req, ( u16 )HWRM_PORT_PHY_CFG, cmd_len );
1420  req->flags = flags;
1421  req->enables = enables;
1422  req->port_id = bp->port_idx;
1423  req->force_link_speed = force_link_speed;
1424  req->auto_mode = auto_mode;
1425  req->auto_duplex = auto_duplex;
1426  req->auto_pause = auto_pause;
1427  req->auto_link_speed_mask = auto_link_speed_mask;
1428 
1429  return wait_resp ( bp, bp->hwrm_cmd_timeout, cmd_len, __func__ );
1430 }
#define u16
Definition: vga.h:20
uint16_t u16
Definition: stdint.h:21
#define PORT_PHY_CFG_REQ_AUTO_DUPLEX_BOTH
Definition: bnxt_hsi.h:2992
#define PORT_PHY_CFG_REQ_FORCE_LINK_SPEED_100GB
Definition: bnxt_hsi.h:2978
#define PORT_PHY_CFG_REQ_FORCE_LINK_SPEED_10GB
Definition: bnxt_hsi.h:2973
static void hwrm_init(struct bnxt *bp, struct input *req, u16 cmd, u16 len)
Definition: bnxt.c:622
#define PORT_PHY_CFG_REQ_AUTO_MODE_SPEED_MASK
Definition: bnxt_hsi.h:2987
#define PORT_PHY_CFG_REQ_ENABLES_AUTO_LINK_SPEED_MASK
Definition: bnxt_hsi.h:2960
switch(len)
Definition: string.h:61
uint16_t bp
Definition: registers.h:23
#define MEDIUM_SPEED_10GBPS
Definition: bnxt.h:102
#define GET_MEDIUM_SPEED(m)
Definition: bnxt.h:113
#define PORT_PHY_CFG_REQ_FLAGS_RESET_PHY
Definition: bnxt_hsi.h:2940
#define MEDIUM_SPEED_50GBPS
Definition: bnxt.h:106
#define PORT_PHY_CFG_REQ_ENABLES_AUTO_MODE
Definition: bnxt_hsi.h:2956
#define MEDIUM_SPEED_200GBPS
Definition: bnxt.h:108
#define MEDIUM_SPEED_25GBPS
Definition: bnxt.h:104
#define PORT_PHY_CFG_REQ_AUTO_PAUSE_RX
Definition: bnxt_hsi.h:2996
static int wait_resp(struct bnxt *bp, u32 tmo, u16 len, const char *func)
Definition: bnxt.c:658
#define PORT_PHY_CFG_REQ_FORCE_LINK_SPEED_40GB
Definition: bnxt_hsi.h:2976
#define DBGP(...)
Definition: compiler.h:532
#define MEDIUM_SPEED_1000MBPS
Definition: bnxt.h:100
#define PORT_PHY_CFG_REQ_FORCE_LINK_SPEED_1GB
Definition: bnxt_hsi.h:2970
#define PORT_PHY_CFG_REQ_ENABLES_AUTO_PAUSE
Definition: bnxt_hsi.h:2958
#define PORT_PHY_CFG_REQ_FLAGS_FORCE
Definition: bnxt_hsi.h:2942
#define PORT_PHY_CFG_REQ_FORCE_LINK_SPEED_200GB
Definition: bnxt_hsi.h:2979
#define PORT_PHY_CFG_REQ_AUTO_PAUSE_TX
Definition: bnxt_hsi.h:2995
#define PORT_PHY_CFG_REQ_FORCE_LINK_SPEED_50GB
Definition: bnxt_hsi.h:2977
#define HWRM_PORT_PHY_CFG
Definition: bnxt_hsi.h:118
#define MEDIUM_SPEED_40GBPS
Definition: bnxt.h:105
#define MEDIUM_SPEED_100GBPS
Definition: bnxt.h:107
#define PORT_PHY_CFG_REQ_FORCE_LINK_SPEED_25GB
Definition: bnxt_hsi.h:2975
uint8_t u8
Definition: stdint.h:19
uint32_t u32
Definition: stdint.h:23
#define PORT_PHY_CFG_REQ_ENABLES_AUTO_DUPLEX
Definition: bnxt_hsi.h:2957
uint8_t flags
Flags.
Definition: ena.h:18

References hwrm_port_phy_cfg_input::auto_duplex, hwrm_port_phy_cfg_input::auto_link_speed_mask, hwrm_port_phy_cfg_input::auto_mode, hwrm_port_phy_cfg_input::auto_pause, bp, DBGP, hwrm_port_phy_cfg_input::enables, flags, hwrm_port_phy_cfg_input::force_link_speed, GET_MEDIUM_SPEED, hwrm_init(), HWRM_PORT_PHY_CFG, MEDIUM_SPEED_1000MBPS, MEDIUM_SPEED_100GBPS, MEDIUM_SPEED_10GBPS, MEDIUM_SPEED_200GBPS, MEDIUM_SPEED_25GBPS, MEDIUM_SPEED_40GBPS, MEDIUM_SPEED_50GBPS, PORT_PHY_CFG_REQ_AUTO_DUPLEX_BOTH, PORT_PHY_CFG_REQ_AUTO_MODE_SPEED_MASK, PORT_PHY_CFG_REQ_AUTO_PAUSE_RX, PORT_PHY_CFG_REQ_AUTO_PAUSE_TX, PORT_PHY_CFG_REQ_ENABLES_AUTO_DUPLEX, PORT_PHY_CFG_REQ_ENABLES_AUTO_LINK_SPEED_MASK, PORT_PHY_CFG_REQ_ENABLES_AUTO_MODE, PORT_PHY_CFG_REQ_ENABLES_AUTO_PAUSE, PORT_PHY_CFG_REQ_FLAGS_FORCE, PORT_PHY_CFG_REQ_FLAGS_RESET_PHY, PORT_PHY_CFG_REQ_FORCE_LINK_SPEED_100GB, PORT_PHY_CFG_REQ_FORCE_LINK_SPEED_10GB, PORT_PHY_CFG_REQ_FORCE_LINK_SPEED_1GB, PORT_PHY_CFG_REQ_FORCE_LINK_SPEED_200GB, PORT_PHY_CFG_REQ_FORCE_LINK_SPEED_25GB, PORT_PHY_CFG_REQ_FORCE_LINK_SPEED_40GB, PORT_PHY_CFG_REQ_FORCE_LINK_SPEED_50GB, switch(), u16, and wait_resp().

Referenced by bnxt_query_phy_link().

◆ bnxt_query_phy_link()

static int bnxt_query_phy_link ( struct bnxt bp)
static

Definition at line 1432 of file bnxt.c.

1433 {
1435 
1436  DBGP ( "%s\n", __func__ );
1437  /* Query Link Status */
1439  return STATUS_FAILURE;
1440  }
1441 
1442  if ( bp->link_status == STATUS_LINK_ACTIVE )
1443  return STATUS_SUCCESS;
1444 
1445  /* If VF is set to TRUE, Do not issue the following commands */
1446  if ( bp->vf )
1447  return STATUS_SUCCESS;
1448 
1449  /* If multi_host or NPAR, Do not issue bnxt_get_link_speed */
1450  if ( FLAG_TEST ( bp->flags, PORT_PHY_FLAGS ) ) {
1451  dbg_flags ( __func__, bp->flags );
1452  return STATUS_SUCCESS;
1453  }
1454 
1455  /* HWRM_NVM_GET_VARIABLE - speed */
1456  if ( bnxt_get_link_speed ( bp ) != STATUS_SUCCESS ) {
1457  return STATUS_FAILURE;
1458  }
1459 
1460  /* Configure link if it is not up */
1462 
1463  /* refresh link speed values after bringing link up */
1464  return bnxt_hwrm_port_phy_qcfg ( bp, flag );
1465 }
uint16_t u16
Definition: stdint.h:21
#define STATUS_SUCCESS
Definition: bnxt.h:58
#define DETECT_MEDIA
Definition: bnxt.h:195
#define dbg_flags(func, flags)
Definition: bnxt_dbg.h:326
#define FLAG_TEST(f, b)
Definition: bnxt.h:46
uint16_t bp
Definition: registers.h:23
#define PHY_STATUS
Definition: bnxt.h:193
#define STATUS_LINK_ACTIVE
Definition: bnxt.h:62
#define QCFG_PHY_ALL
Definition: bnxt.h:197
#define DBGP(...)
Definition: compiler.h:532
#define PORT_PHY_FLAGS
Definition: bnxt.h:847
static int bnxt_hwrm_port_phy_qcfg(struct bnxt *bp, u16 idx)
Definition: bnxt.c:1143
#define STATUS_FAILURE
Definition: bnxt.h:59
static int bnxt_get_link_speed(struct bnxt *bp)
Definition: bnxt.c:1197
#define PHY_SPEED
Definition: bnxt.h:194
static int bnxt_hwrm_port_phy_cfg(struct bnxt *bp)
Definition: bnxt.c:1366
uint16_t flag
Flag number.
Definition: hyperv.h:14

References bnxt_get_link_speed(), bnxt_hwrm_port_phy_cfg(), bnxt_hwrm_port_phy_qcfg(), bp, dbg_flags, DBGP, DETECT_MEDIA, flag, FLAG_TEST, PHY_SPEED, PHY_STATUS, PORT_PHY_FLAGS, QCFG_PHY_ALL, STATUS_FAILURE, STATUS_LINK_ACTIVE, and STATUS_SUCCESS.

◆ bnxt_get_phy_link()

static int bnxt_get_phy_link ( struct bnxt bp)
static

Definition at line 1467 of file bnxt.c.

1468 {
1469  u16 i;
1471 
1472  DBGP ( "%s\n", __func__ );
1473  dbg_chip_info ( bp );
1474  for ( i = 0; i < ( bp->wait_link_timeout / 100 ); i++ ) {
1476  break;
1477 
1478  if ( bp->link_status == STATUS_LINK_ACTIVE )
1479  break;
1480 
1481 // if ( bp->media_detect )
1482 // break;
1484  }
1485  dbg_link_state ( bp, ( u32 ) ( ( i + 1 ) * 100 ) );
1486  bnxt_set_link ( bp );
1487  return STATUS_SUCCESS;
1488 }
uint16_t u16
Definition: stdint.h:21
#define STATUS_SUCCESS
Definition: bnxt.h:58
#define DETECT_MEDIA
Definition: bnxt.h:195
#define LINK_POLL_WAIT_TIME
Definition: bnxt.h:164
uint16_t bp
Definition: registers.h:23
#define PHY_STATUS
Definition: bnxt.h:193
#define STATUS_LINK_ACTIVE
Definition: bnxt.h:62
#define DBGP(...)
Definition: compiler.h:532
static int bnxt_hwrm_port_phy_qcfg(struct bnxt *bp, u16 idx)
Definition: bnxt.c:1143
#define PHY_SPEED
Definition: bnxt.h:194
static void bnxt_set_link(struct bnxt *bp)
Definition: bnxt.c:176
#define dbg_chip_info(bp)
Definition: bnxt_dbg.h:324
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition: timer.c:78
#define dbg_link_state(bp, tmo)
Definition: bnxt_dbg.h:676
uint32_t u32
Definition: stdint.h:23
uint16_t flag
Flag number.
Definition: hyperv.h:14

References bnxt_hwrm_port_phy_qcfg(), bnxt_set_link(), bp, dbg_chip_info, dbg_link_state, DBGP, DETECT_MEDIA, flag, LINK_POLL_WAIT_TIME, mdelay(), PHY_SPEED, PHY_STATUS, STATUS_LINK_ACTIVE, and STATUS_SUCCESS.

◆ bnxt_hwrm_stat_ctx_alloc()

static int bnxt_hwrm_stat_ctx_alloc ( struct bnxt bp)
static

Definition at line 1490 of file bnxt.c.

1491 {
1492  u16 cmd_len = ( u16 )sizeof ( struct hwrm_stat_ctx_alloc_input );
1493  struct hwrm_stat_ctx_alloc_input *req;
1494  struct hwrm_stat_ctx_alloc_output *resp;
1495  int rc;
1496 
1497  DBGP ( "%s\n", __func__ );
1498  req = ( struct hwrm_stat_ctx_alloc_input * )bp->hwrm_addr_req;
1499  resp = ( struct hwrm_stat_ctx_alloc_output * )bp->hwrm_addr_resp;
1500  hwrm_init ( bp, ( void * )req, ( u16 )HWRM_STAT_CTX_ALLOC, cmd_len );
1501  rc = wait_resp ( bp, bp->hwrm_cmd_timeout, cmd_len, __func__ );
1502  if ( rc ) {
1503  DBGP ( "- %s ( ): Failed\n", __func__ );
1504  return STATUS_FAILURE;
1505  }
1506 
1507  FLAG_SET ( bp->flag_hwrm, VALID_STAT_CTX );
1508  bp->stat_ctx_id = ( u16 )resp->stat_ctx_id;
1509  return STATUS_SUCCESS;
1510 }
#define u16
Definition: vga.h:20
uint16_t u16
Definition: stdint.h:21
#define FLAG_SET(f, b)
Definition: bnxt.h:45
#define STATUS_SUCCESS
Definition: bnxt.h:58
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static void hwrm_init(struct bnxt *bp, struct input *req, u16 cmd, u16 len)
Definition: bnxt.c:622
uint16_t bp
Definition: registers.h:23
static int wait_resp(struct bnxt *bp, u32 tmo, u16 len, const char *func)
Definition: bnxt.c:658
#define DBGP(...)
Definition: compiler.h:532
#define STATUS_FAILURE
Definition: bnxt.h:59
#define HWRM_STAT_CTX_ALLOC
Definition: bnxt_hsi.h:190
#define VALID_STAT_CTX
Definition: bnxt.h:711

References bp, DBGP, FLAG_SET, hwrm_init(), HWRM_STAT_CTX_ALLOC, rc, hwrm_stat_ctx_alloc_output::stat_ctx_id, STATUS_FAILURE, STATUS_SUCCESS, u16, VALID_STAT_CTX, and wait_resp().

◆ bnxt_hwrm_stat_ctx_free()

static int bnxt_hwrm_stat_ctx_free ( struct bnxt bp)
static

Definition at line 1512 of file bnxt.c.

1513 {
1514  u16 cmd_len = ( u16 )sizeof ( struct hwrm_stat_ctx_free_input );
1515  struct hwrm_stat_ctx_free_input *req;
1516  int rc;
1517 
1518  DBGP ( "%s\n", __func__ );
1519  if ( ! ( FLAG_TEST ( bp->flag_hwrm, VALID_STAT_CTX ) ) )
1520  return STATUS_SUCCESS;
1521 
1522  req = ( struct hwrm_stat_ctx_free_input * )bp->hwrm_addr_req;
1523  hwrm_init ( bp, ( void * )req, ( u16 )HWRM_STAT_CTX_FREE, cmd_len );
1524  req->stat_ctx_id = ( u32 )bp->stat_ctx_id;
1525  rc = wait_resp ( bp, bp->hwrm_cmd_timeout, cmd_len, __func__ );
1526  if ( rc ) {
1527  DBGP ( "- %s ( ): Failed\n", __func__ );
1528  return STATUS_FAILURE;
1529  }
1530 
1531  FLAG_RESET ( bp->flag_hwrm, VALID_STAT_CTX );
1532  return STATUS_SUCCESS;
1533 }
#define u16
Definition: vga.h:20
uint16_t u16
Definition: stdint.h:21
#define HWRM_STAT_CTX_FREE
Definition: bnxt_hsi.h:191
#define STATUS_SUCCESS
Definition: bnxt.h:58
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static void hwrm_init(struct bnxt *bp, struct input *req, u16 cmd, u16 len)
Definition: bnxt.c:622
#define FLAG_TEST(f, b)
Definition: bnxt.h:46
uint16_t bp
Definition: registers.h:23
static int wait_resp(struct bnxt *bp, u32 tmo, u16 len, const char *func)
Definition: bnxt.c:658
#define DBGP(...)
Definition: compiler.h:532
#define u32
Definition: vga.h:21
#define STATUS_FAILURE
Definition: bnxt.h:59
#define FLAG_RESET(f, b)
Definition: bnxt.h:47
#define VALID_STAT_CTX
Definition: bnxt.h:711

References bp, DBGP, FLAG_RESET, FLAG_TEST, hwrm_init(), HWRM_STAT_CTX_FREE, rc, hwrm_stat_ctx_free_input::stat_ctx_id, STATUS_FAILURE, STATUS_SUCCESS, u16, u32, VALID_STAT_CTX, and wait_resp().

◆ bnxt_hwrm_ring_free_grp()

static int bnxt_hwrm_ring_free_grp ( struct bnxt bp)
static

Definition at line 1535 of file bnxt.c.

1536 {
1537  u16 cmd_len = ( u16 )sizeof ( struct hwrm_ring_grp_free_input );
1538  struct hwrm_ring_grp_free_input *req;
1539  int rc;
1540 
1541  DBGP ( "%s\n", __func__ );
1542  if ( ! ( FLAG_TEST ( bp->flag_hwrm, VALID_RING_GRP ) ) )
1543  return STATUS_SUCCESS;
1544 
1545  req = ( struct hwrm_ring_grp_free_input * )bp->hwrm_addr_req;
1546  hwrm_init ( bp, ( void * )req, ( u16 )HWRM_RING_GRP_FREE, cmd_len );
1547  req->ring_group_id = ( u32 )bp->ring_grp_id;
1548  rc = wait_resp ( bp, bp->hwrm_cmd_timeout, cmd_len, __func__ );
1549  if ( rc ) {
1550  DBGP ( "- %s ( ): Failed\n", __func__ );
1551  return STATUS_FAILURE;
1552  }
1553 
1554  FLAG_RESET ( bp->flag_hwrm, VALID_RING_GRP );
1555  return STATUS_SUCCESS;
1556 }
#define u16
Definition: vga.h:20
uint16_t u16
Definition: stdint.h:21
#define STATUS_SUCCESS
Definition: bnxt.h:58
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static void hwrm_init(struct bnxt *bp, struct input *req, u16 cmd, u16 len)
Definition: bnxt.c:622
#define FLAG_TEST(f, b)
Definition: bnxt.h:46
uint16_t bp
Definition: registers.h:23
static int wait_resp(struct bnxt *bp, u32 tmo, u16 len, const char *func)
Definition: bnxt.c:658
#define DBGP(...)
Definition: compiler.h:532
#define u32
Definition: vga.h:21
#define STATUS_FAILURE
Definition: bnxt.h:59
#define FLAG_RESET(f, b)
Definition: bnxt.h:47
#define HWRM_RING_GRP_FREE
Definition: bnxt_hsi.h:166
#define VALID_RING_GRP
Definition: bnxt.h:715

References bp, DBGP, FLAG_RESET, FLAG_TEST, hwrm_init(), HWRM_RING_GRP_FREE, rc, hwrm_ring_grp_free_input::ring_group_id, STATUS_FAILURE, STATUS_SUCCESS, u16, u32, VALID_RING_GRP, and wait_resp().

◆ bnxt_hwrm_ring_alloc_grp()

static int bnxt_hwrm_ring_alloc_grp ( struct bnxt bp)
static

Definition at line 1558 of file bnxt.c.

1559 {
1560  u16 cmd_len = ( u16 )sizeof ( struct hwrm_ring_grp_alloc_input );
1561  struct hwrm_ring_grp_alloc_input *req;
1562  struct hwrm_ring_grp_alloc_output *resp;
1563  int rc;
1564 
1565  DBGP ( "%s\n", __func__ );
1566  if ( bp->thor )
1567  return STATUS_SUCCESS;
1568 
1569  req = ( struct hwrm_ring_grp_alloc_input * )bp->hwrm_addr_req;
1570  resp = ( struct hwrm_ring_grp_alloc_output * )bp->hwrm_addr_resp;
1571  hwrm_init ( bp, ( void * )req, ( u16 )HWRM_RING_GRP_ALLOC, cmd_len );
1572  req->cr = bp->cq_ring_id;
1573  req->rr = bp->rx_ring_id;
1574  req->ar = ( u16 )HWRM_NA_SIGNATURE;
1575  if ( bp->vf )
1576  req->sc = bp->stat_ctx_id;
1577 
1578  rc = wait_resp ( bp, bp->hwrm_cmd_timeout, cmd_len, __func__ );
1579  if ( rc ) {
1580  DBGP ( "- %s ( ): Failed\n", __func__ );
1581  return STATUS_FAILURE;
1582  }
1583 
1584  FLAG_SET ( bp->flag_hwrm, VALID_RING_GRP );
1585  bp->ring_grp_id = ( u16 )resp->ring_group_id;
1586  return STATUS_SUCCESS;
1587 }
#define u16
Definition: vga.h:20
uint16_t u16
Definition: stdint.h:21
#define FLAG_SET(f, b)
Definition: bnxt.h:45
#define STATUS_SUCCESS
Definition: bnxt.h:58
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static void hwrm_init(struct bnxt *bp, struct input *req, u16 cmd, u16 len)
Definition: bnxt.c:622
uint16_t bp
Definition: registers.h:23
#define HWRM_RING_GRP_ALLOC
Definition: bnxt_hsi.h:165
static int wait_resp(struct bnxt *bp, u32 tmo, u16 len, const char *func)
Definition: bnxt.c:658
#define DBGP(...)
Definition: compiler.h:532
#define HWRM_NA_SIGNATURE
Definition: bnxt_hsi.h:362
#define STATUS_FAILURE
Definition: bnxt.h:59
#define VALID_RING_GRP
Definition: bnxt.h:715

References bp, DBGP, FLAG_SET, hwrm_init(), HWRM_NA_SIGNATURE, HWRM_RING_GRP_ALLOC, rc, hwrm_ring_grp_alloc_output::ring_group_id, STATUS_FAILURE, STATUS_SUCCESS, u16, VALID_RING_GRP, and wait_resp().

◆ bnxt_hwrm_ring_free()

int bnxt_hwrm_ring_free ( struct bnxt bp,
u16  ring_id,
u8  ring_type 
)

Definition at line 1589 of file bnxt.c.

1590 {
1591  u16 cmd_len = ( u16 )sizeof ( struct hwrm_ring_free_input );
1592  struct hwrm_ring_free_input *req;
1593 
1594  DBGP ( "%s\n", __func__ );
1595  req = ( struct hwrm_ring_free_input * )bp->hwrm_addr_req;
1596  hwrm_init ( bp, ( void * )req, ( u16 )HWRM_RING_FREE, cmd_len );
1597  req->ring_type = ring_type;
1598  req->ring_id = ring_id;
1599  return wait_resp ( bp, bp->hwrm_cmd_timeout, cmd_len, __func__ );
1600 }
#define u16
Definition: vga.h:20
uint16_t u16
Definition: stdint.h:21
static void hwrm_init(struct bnxt *bp, struct input *req, u16 cmd, u16 len)
Definition: bnxt.c:622
uint16_t bp
Definition: registers.h:23
static int wait_resp(struct bnxt *bp, u32 tmo, u16 len, const char *func)
Definition: bnxt.c:658
#define DBGP(...)
Definition: compiler.h:532
#define HWRM_RING_FREE
Definition: bnxt_hsi.h:160

References bp, DBGP, hwrm_init(), HWRM_RING_FREE, hwrm_ring_free_input::ring_id, hwrm_ring_free_input::ring_type, u16, and wait_resp().

◆ bnxt_hwrm_ring_alloc()

static int bnxt_hwrm_ring_alloc ( struct bnxt bp,
u8  type 
)
static

Definition at line 1602 of file bnxt.c.

1603 {
1604  u16 cmd_len = ( u16 )sizeof ( struct hwrm_ring_alloc_input );
1605  struct hwrm_ring_alloc_input *req;
1606  struct hwrm_ring_alloc_output *resp;
1607  int rc;
1608 
1609  DBGP ( "%s\n", __func__ );
1610  req = ( struct hwrm_ring_alloc_input * )bp->hwrm_addr_req;
1611  resp = ( struct hwrm_ring_alloc_output * )bp->hwrm_addr_resp;
1612  hwrm_init ( bp, ( void * )req, ( u16 )HWRM_RING_ALLOC, cmd_len );
1613  req->ring_type = type;
1614  switch ( type ) {
1616  req->page_size = LM_PAGE_BITS ( 12 );
1617  req->int_mode = BNXT_CQ_INTR_MODE ( bp->vf );
1618  req->length = ( u32 )bp->nq.ring_cnt;
1619  req->logical_id = 0xFFFF; // Required value for Thor FW?
1620  req->page_tbl_addr = virt_to_bus ( bp->nq.bd_virt );
1621  break;
1623  req->page_size = LM_PAGE_BITS ( 8 );
1624  req->int_mode = BNXT_CQ_INTR_MODE ( bp->vf );
1625  req->length = ( u32 )bp->cq.ring_cnt;
1626  req->page_tbl_addr = virt_to_bus ( bp->cq.bd_virt );
1627  if ( !bp->thor )
1628  break;
1630  req->nq_ring_id = bp->nq_ring_id;
1631  req->cq_handle = ( u64 )bp->nq_ring_id;
1632  break;
1634  req->page_size = LM_PAGE_BITS ( 8 );
1635  req->int_mode = RING_ALLOC_REQ_INT_MODE_POLL;
1636  req->length = ( u32 )bp->tx.ring_cnt;
1637  req->queue_id = TX_RING_QID;
1638  req->stat_ctx_id = ( u32 )bp->stat_ctx_id;
1639  req->cmpl_ring_id = bp->cq_ring_id;
1640  req->page_tbl_addr = virt_to_bus ( bp->tx.bd_virt );
1641  break;
1643  req->page_size = LM_PAGE_BITS ( 8 );
1644  req->int_mode = RING_ALLOC_REQ_INT_MODE_POLL;
1645  req->length = ( u32 )bp->rx.ring_cnt;
1646  req->stat_ctx_id = ( u32 )STAT_CTX_ID;
1647  req->cmpl_ring_id = bp->cq_ring_id;
1648  req->page_tbl_addr = virt_to_bus ( bp->rx.bd_virt );
1649  if ( !bp->thor )
1650  break;
1651  req->queue_id = ( u16 )RX_RING_QID;
1652  req->rx_buf_size = MAX_ETHERNET_PACKET_BUFFER_SIZE;
1654  break;
1655  default:
1656  return STATUS_SUCCESS;
1657  }
1658  rc = wait_resp ( bp, bp->hwrm_cmd_timeout, cmd_len, __func__ );
1659  if ( rc ) {
1660  DBGP ( "- %s ( ): Failed, type = %x\n", __func__, type );
1661  return STATUS_FAILURE;
1662  }
1663 
1665  FLAG_SET ( bp->flag_hwrm, VALID_RING_CQ );
1666  bp->cq_ring_id = resp->ring_id;
1667  } else if ( type == RING_ALLOC_REQ_RING_TYPE_TX ) {
1668  FLAG_SET ( bp->flag_hwrm, VALID_RING_TX );
1669  bp->tx_ring_id = resp->ring_id;
1670  } else if ( type == RING_ALLOC_REQ_RING_TYPE_RX ) {
1671  FLAG_SET ( bp->flag_hwrm, VALID_RING_RX );
1672  bp->rx_ring_id = resp->ring_id;
1673  } else if ( type == RING_ALLOC_REQ_RING_TYPE_NQ ) {
1674  FLAG_SET ( bp->flag_hwrm, VALID_RING_NQ );
1675  bp->nq_ring_id = resp->ring_id;
1676  }
1677  return STATUS_SUCCESS;
1678 }
#define RING_ALLOC_REQ_RING_TYPE_NQ
Definition: bnxt_hsi.h:5904
#define u16
Definition: vga.h:20
uint16_t u16
Definition: stdint.h:21
#define FLAG_SET(f, b)
Definition: bnxt.h:45
#define STATUS_SUCCESS
Definition: bnxt.h:58
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static void hwrm_init(struct bnxt *bp, struct input *req, u16 cmd, u16 len)
Definition: bnxt.c:622
uint32_t type
Operating system type.
Definition: ena.h:12
uint16_t bp
Definition: registers.h:23
#define LM_PAGE_BITS(a)
Definition: bnxt.h:156
#define RING_ALLOC_REQ_ENABLES_RX_BUF_SIZE_VALID
Definition: bnxt_hsi.h:5897
#define VALID_RING_CQ
Definition: bnxt.h:712
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition: io.h:183
static int wait_resp(struct bnxt *bp, u32 tmo, u16 len, const char *func)
Definition: bnxt.c:658
#define DBGP(...)
Definition: compiler.h:532
#define RING_ALLOC_REQ_ENABLES_NQ_RING_ID_VALID
Definition: bnxt_hsi.h:5896
#define u32
Definition: vga.h:21
uint64_t u64
Definition: stdint.h:25
#define BNXT_CQ_INTR_MODE(vf)
Definition: bnxt.h:160
#define VALID_RING_NQ
Definition: bnxt.h:719
#define STATUS_FAILURE
Definition: bnxt.h:59
#define STAT_CTX_ID
Definition: bnxt.h:173
#define RING_ALLOC_REQ_RING_TYPE_TX
Definition: bnxt_hsi.h:5900
#define VALID_RING_RX
Definition: bnxt.h:714
#define RING_ALLOC_REQ_RING_TYPE_RX
Definition: bnxt_hsi.h:5901
#define TX_RING_QID
Definition: bnxt.h:171
#define MAX_ETHERNET_PACKET_BUFFER_SIZE
Definition: bnxt.h:137
#define HWRM_RING_ALLOC
Definition: bnxt_hsi.h:159
#define RING_ALLOC_REQ_RING_TYPE_L2_CMPL
Definition: bnxt_hsi.h:5899
#define VALID_RING_TX
Definition: bnxt.h:713
#define RX_RING_QID
Definition: bnxt.h:172
#define RING_ALLOC_REQ_INT_MODE_POLL
Definition: bnxt_hsi.h:5955
uint32_t u32
Definition: stdint.h:23

References BNXT_CQ_INTR_MODE, bp, DBGP, FLAG_SET, hwrm_init(), HWRM_RING_ALLOC, LM_PAGE_BITS, MAX_ETHERNET_PACKET_BUFFER_SIZE, rc, RING_ALLOC_REQ_ENABLES_NQ_RING_ID_VALID, RING_ALLOC_REQ_ENABLES_RX_BUF_SIZE_VALID, RING_ALLOC_REQ_INT_MODE_POLL, RING_ALLOC_REQ_RING_TYPE_L2_CMPL, RING_ALLOC_REQ_RING_TYPE_NQ, RING_ALLOC_REQ_RING_TYPE_RX, RING_ALLOC_REQ_RING_TYPE_TX, hwrm_ring_alloc_output::ring_id, RX_RING_QID, STAT_CTX_ID, STATUS_FAILURE, STATUS_SUCCESS, TX_RING_QID, type, u16, u32, VALID_RING_CQ, VALID_RING_NQ, VALID_RING_RX, VALID_RING_TX, virt_to_bus(), and wait_resp().

Referenced by bnxt_hwrm_ring_alloc_cq(), bnxt_hwrm_ring_alloc_nq(), bnxt_hwrm_ring_alloc_rx(), and bnxt_hwrm_ring_alloc_tx().

◆ bnxt_hwrm_ring_alloc_cq()

static int bnxt_hwrm_ring_alloc_cq ( struct bnxt bp)
static

Definition at line 1680 of file bnxt.c.

1681 {
1682  DBGP ( "%s\n", __func__ );
1684 }
uint16_t bp
Definition: registers.h:23
static int bnxt_hwrm_ring_alloc(struct bnxt *bp, u8 type)
Definition: bnxt.c:1602
#define DBGP(...)
Definition: compiler.h:532
#define RING_ALLOC_REQ_RING_TYPE_L2_CMPL
Definition: bnxt_hsi.h:5899

References bnxt_hwrm_ring_alloc(), bp, DBGP, and RING_ALLOC_REQ_RING_TYPE_L2_CMPL.

◆ bnxt_hwrm_ring_alloc_tx()

static int bnxt_hwrm_ring_alloc_tx ( struct bnxt bp)
static

Definition at line 1686 of file bnxt.c.

1687 {
1688  DBGP ( "%s\n", __func__ );
1690 }
uint16_t bp
Definition: registers.h:23
static int bnxt_hwrm_ring_alloc(struct bnxt *bp, u8 type)
Definition: bnxt.c:1602
#define DBGP(...)
Definition: compiler.h:532
#define RING_ALLOC_REQ_RING_TYPE_TX
Definition: bnxt_hsi.h:5900

References bnxt_hwrm_ring_alloc(), bp, DBGP, and RING_ALLOC_REQ_RING_TYPE_TX.

◆ bnxt_hwrm_ring_alloc_rx()

static int bnxt_hwrm_ring_alloc_rx ( struct bnxt bp)
static

Definition at line 1692 of file bnxt.c.

1693 {
1694  DBGP ( "%s\n", __func__ );
1696 }
uint16_t bp
Definition: registers.h:23
static int bnxt_hwrm_ring_alloc(struct bnxt *bp, u8 type)
Definition: bnxt.c:1602
#define DBGP(...)
Definition: compiler.h:532
#define RING_ALLOC_REQ_RING_TYPE_RX
Definition: bnxt_hsi.h:5901

References bnxt_hwrm_ring_alloc(), bp, DBGP, and RING_ALLOC_REQ_RING_TYPE_RX.

◆ bnxt_hwrm_ring_free_cq()

static int bnxt_hwrm_ring_free_cq ( struct bnxt bp)
static

Definition at line 1698 of file bnxt.c.

1699 {
1700  int ret = STATUS_SUCCESS;
1701 
1702  DBGP ( "%s\n", __func__ );
1703  if ( ! ( FLAG_TEST ( bp->flag_hwrm, VALID_RING_CQ ) ) )
1704  return ret;
1705 
1706  ret = RING_FREE ( bp, bp->cq_ring_id, RING_FREE_REQ_RING_TYPE_L2_CMPL );
1707  if ( ret == STATUS_SUCCESS )
1708  FLAG_RESET ( bp->flag_hwrm, VALID_RING_CQ );
1709 
1710  return ret;
1711 }
#define STATUS_SUCCESS
Definition: bnxt.h:58
#define FLAG_TEST(f, b)
Definition: bnxt.h:46
#define RING_FREE(bp, rid, flag)
Definition: bnxt.h:850
uint16_t bp
Definition: registers.h:23
#define VALID_RING_CQ
Definition: bnxt.h:712
#define DBGP(...)
Definition: compiler.h:532
#define FLAG_RESET(f, b)
Definition: bnxt.h:47
#define RING_FREE_REQ_RING_TYPE_L2_CMPL
Definition: bnxt_hsi.h:5981

References bp, DBGP, FLAG_RESET, FLAG_TEST, RING_FREE, RING_FREE_REQ_RING_TYPE_L2_CMPL, STATUS_SUCCESS, and VALID_RING_CQ.

◆ bnxt_hwrm_ring_free_tx()

static int bnxt_hwrm_ring_free_tx ( struct bnxt bp)
static

Definition at line 1713 of file bnxt.c.

1714 {
1715  int ret = STATUS_SUCCESS;
1716 
1717  DBGP ( "%s\n", __func__ );
1718  if ( ! ( FLAG_TEST ( bp->flag_hwrm, VALID_RING_TX ) ) )
1719  return ret;
1720 
1721  ret = RING_FREE ( bp, bp->tx_ring_id, RING_FREE_REQ_RING_TYPE_TX );
1722  if ( ret == STATUS_SUCCESS )
1723  FLAG_RESET ( bp->flag_hwrm, VALID_RING_TX );
1724 
1725  return ret;
1726 }
#define STATUS_SUCCESS
Definition: bnxt.h:58
#define FLAG_TEST(f, b)
Definition: bnxt.h:46
#define RING_FREE(bp, rid, flag)
Definition: bnxt.h:850
#define RING_FREE_REQ_RING_TYPE_TX
Definition: bnxt_hsi.h:5982
uint16_t bp
Definition: registers.h:23
#define DBGP(...)
Definition: compiler.h:532
#define FLAG_RESET(f, b)
Definition: bnxt.h:47
#define VALID_RING_TX
Definition: bnxt.h:713

References bp, DBGP, FLAG_RESET, FLAG_TEST, RING_FREE, RING_FREE_REQ_RING_TYPE_TX, STATUS_SUCCESS, and VALID_RING_TX.

◆ bnxt_hwrm_ring_free_rx()

static int bnxt_hwrm_ring_free_rx ( struct bnxt bp)
static

Definition at line 1728 of file bnxt.c.

1729 {
1730  int ret = STATUS_SUCCESS;
1731 
1732  DBGP ( "%s\n", __func__ );
1733  if ( ! ( FLAG_TEST ( bp->flag_hwrm, VALID_RING_RX ) ) )
1734  return ret;
1735 
1736  ret = RING_FREE ( bp, bp->rx_ring_id, RING_FREE_REQ_RING_TYPE_RX );
1737  if ( ret == STATUS_SUCCESS )
1738  FLAG_RESET ( bp->flag_hwrm, VALID_RING_RX );
1739 
1740  return ret;
1741 }
#define STATUS_SUCCESS
Definition: bnxt.h:58
#define FLAG_TEST(f, b)
Definition: bnxt.h:46
#define RING_FREE(bp, rid, flag)
Definition: bnxt.h:850
uint16_t bp
Definition: registers.h:23
#define DBGP(...)
Definition: compiler.h:532
#define FLAG_RESET(f, b)
Definition: bnxt.h:47
#define VALID_RING_RX
Definition: bnxt.h:714
#define RING_FREE_REQ_RING_TYPE_RX
Definition: bnxt_hsi.h:5983

References bp, DBGP, FLAG_RESET, FLAG_TEST, RING_FREE, RING_FREE_REQ_RING_TYPE_RX, STATUS_SUCCESS, and VALID_RING_RX.

◆ bnxt_hwrm_ring_alloc_nq()

static int bnxt_hwrm_ring_alloc_nq ( struct bnxt bp)
static

Definition at line 1743 of file bnxt.c.

1744 {
1745  if ( !bp->thor )
1746  return STATUS_SUCCESS;
1748 }
#define RING_ALLOC_REQ_RING_TYPE_NQ
Definition: bnxt_hsi.h:5904
#define STATUS_SUCCESS
Definition: bnxt.h:58
uint16_t bp
Definition: registers.h:23
static int bnxt_hwrm_ring_alloc(struct bnxt *bp, u8 type)
Definition: bnxt.c:1602

References bnxt_hwrm_ring_alloc(), bp, RING_ALLOC_REQ_RING_TYPE_NQ, and STATUS_SUCCESS.

◆ bnxt_hwrm_ring_free_nq()

static int bnxt_hwrm_ring_free_nq ( struct bnxt bp)
static

Definition at line 1750 of file bnxt.c.

1751 {
1752  int ret = STATUS_SUCCESS;
1753 
1754  if ( !bp->thor )
1755  return STATUS_SUCCESS;
1756 
1757  DBGP ( "%s\n", __func__ );
1758  if ( ! ( FLAG_TEST ( bp->flag_hwrm, VALID_RING_NQ ) ) )
1759  return ret;
1760 
1761  ret = RING_FREE ( bp, bp->nq_ring_id, RING_FREE_REQ_RING_TYPE_NQ );
1762  if ( ret == STATUS_SUCCESS )
1763  FLAG_RESET ( bp->flag_hwrm, VALID_RING_NQ );
1764 
1765  return ret;
1766 }
#define STATUS_SUCCESS
Definition: bnxt.h:58
#define FLAG_TEST(f, b)
Definition: bnxt.h:46
#define RING_FREE(bp, rid, flag)
Definition: bnxt.h:850
uint16_t bp
Definition: registers.h:23
#define DBGP(...)
Definition: compiler.h:532
#define VALID_RING_NQ
Definition: bnxt.h:719
#define FLAG_RESET(f, b)
Definition: bnxt.h:47
#define RING_FREE_REQ_RING_TYPE_NQ
Definition: bnxt_hsi.h:5986

References bp, DBGP, FLAG_RESET, FLAG_TEST, RING_FREE, RING_FREE_REQ_RING_TYPE_NQ, STATUS_SUCCESS, and VALID_RING_NQ.

◆ bnxt_hwrm_vnic_alloc()

static int bnxt_hwrm_vnic_alloc ( struct bnxt bp)
static

Definition at line 1768 of file bnxt.c.

1769 {
1770  u16 cmd_len = ( u16 )sizeof ( struct hwrm_vnic_alloc_input );
1771  struct hwrm_vnic_alloc_input *req;
1772  struct hwrm_vnic_alloc_output *resp;
1773  int rc;
1774 
1775  DBGP ( "%s\n", __func__ );
1776  req = ( struct hwrm_vnic_alloc_input * )bp->hwrm_addr_req;
1777  resp = ( struct hwrm_vnic_alloc_output * )bp->hwrm_addr_resp;
1778  hwrm_init ( bp, ( void * )req, ( u16 )HWRM_VNIC_ALLOC, cmd_len );
1779  req->flags = VNIC_ALLOC_REQ_FLAGS_DEFAULT;
1780  rc = wait_resp ( bp, bp->hwrm_cmd_timeout, cmd_len, __func__ );
1781  if ( rc ) {
1782  DBGP ( "- %s ( ): Failed\n", __func__ );
1783  return STATUS_FAILURE;
1784  }
1785 
1786  FLAG_SET ( bp->flag_hwrm, VALID_VNIC_ID );
1787  bp->vnic_id = resp->vnic_id;
1788  return STATUS_SUCCESS;
1789 }
#define u16
Definition: vga.h:20
uint16_t u16
Definition: stdint.h:21
#define FLAG_SET(f, b)
Definition: bnxt.h:45
#define STATUS_SUCCESS
Definition: bnxt.h:58
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static void hwrm_init(struct bnxt *bp, struct input *req, u16 cmd, u16 len)
Definition: bnxt.c:622
uint16_t bp
Definition: registers.h:23
#define VALID_VNIC_ID
Definition: bnxt.h:716
static int wait_resp(struct bnxt *bp, u32 tmo, u16 len, const char *func)
Definition: bnxt.c:658
#define DBGP(...)
Definition: compiler.h:532
#define STATUS_FAILURE
Definition: bnxt.h:59
#define HWRM_VNIC_ALLOC
Definition: bnxt_hsi.h:148
#define VNIC_ALLOC_REQ_FLAGS_DEFAULT
Definition: bnxt_hsi.h:5454

References bp, DBGP, FLAG_SET, hwrm_init(), HWRM_VNIC_ALLOC, rc, STATUS_FAILURE, STATUS_SUCCESS, u16, VALID_VNIC_ID, VNIC_ALLOC_REQ_FLAGS_DEFAULT, hwrm_vnic_alloc_output::vnic_id, and wait_resp().

◆ bnxt_hwrm_vnic_free()

static int bnxt_hwrm_vnic_free ( struct bnxt bp)
static

Definition at line 1791 of file bnxt.c.

1792 {
1793  u16 cmd_len = ( u16 )sizeof ( struct hwrm_vnic_free_input );
1794  struct hwrm_vnic_free_input *req;
1795  int rc;
1796 
1797  DBGP ( "%s\n", __func__ );
1798  if ( ! ( FLAG_TEST ( bp->flag_hwrm, VALID_VNIC_ID ) ) )
1799  return STATUS_SUCCESS;
1800 
1801  req = ( struct hwrm_vnic_free_input * )bp->hwrm_addr_req;
1802  hwrm_init ( bp, ( void * )req, ( u16 )HWRM_VNIC_FREE, cmd_len );
1803  req->vnic_id = bp->vnic_id;
1804  rc = wait_resp ( bp, bp->hwrm_cmd_timeout, cmd_len, __func__ );
1805  if ( rc ) {
1806  DBGP ( "- %s ( ): Failed\n", __func__ );
1807  return STATUS_FAILURE;
1808  }
1809 
1810  FLAG_RESET ( bp->flag_hwrm, VALID_VNIC_ID );
1811  return STATUS_SUCCESS;
1812 }
#define u16
Definition: vga.h:20
uint16_t u16
Definition: stdint.h:21
#define STATUS_SUCCESS
Definition: bnxt.h:58
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static void hwrm_init(struct bnxt *bp, struct input *req, u16 cmd, u16 len)
Definition: bnxt.c:622
#define FLAG_TEST(f, b)
Definition: bnxt.h:46
uint16_t bp
Definition: registers.h:23
#define VALID_VNIC_ID
Definition: bnxt.h:716
static int wait_resp(struct bnxt *bp, u32 tmo, u16 len, const char *func)
Definition: bnxt.c:658
#define DBGP(...)
Definition: compiler.h:532
#define STATUS_FAILURE
Definition: bnxt.h:59
#define FLAG_RESET(f, b)
Definition: bnxt.h:47
#define HWRM_VNIC_FREE
Definition: bnxt_hsi.h:149

References bp, DBGP, FLAG_RESET, FLAG_TEST, hwrm_init(), HWRM_VNIC_FREE, rc, STATUS_FAILURE, STATUS_SUCCESS, u16, VALID_VNIC_ID, hwrm_vnic_free_input::vnic_id, and wait_resp().

◆ bnxt_hwrm_vnic_cfg()

static int bnxt_hwrm_vnic_cfg ( struct bnxt bp)
static

Definition at line 1814 of file bnxt.c.

1815 {
1816  u16 cmd_len = ( u16 )sizeof ( struct hwrm_vnic_cfg_input );
1817  struct hwrm_vnic_cfg_input *req;
1818 
1819  DBGP ( "%s\n", __func__ );
1820  req = ( struct hwrm_vnic_cfg_input * )bp->hwrm_addr_req;
1821  hwrm_init ( bp, ( void * )req, ( u16 )HWRM_VNIC_CFG, cmd_len );
1823  req->mru = bp->mtu;
1824 
1825  if ( bp->thor ) {
1828  req->default_rx_ring_id = bp->rx_ring_id;
1829  req->default_cmpl_ring_id = bp->cq_ring_id;
1830  } else {
1832  req->dflt_ring_grp = bp->ring_grp_id;
1833  }
1834 
1836  req->vnic_id = bp->vnic_id;
1837  return wait_resp ( bp, bp->hwrm_cmd_timeout, cmd_len, __func__ );
1838 }
#define VNIC_CFG_REQ_ENABLES_MRU
Definition: bnxt_hsi.h:5510
#define u16
Definition: vga.h:20
uint16_t u16
Definition: stdint.h:21
static void hwrm_init(struct bnxt *bp, struct input *req, u16 cmd, u16 len)
Definition: bnxt.c:622
uint16_t bp
Definition: registers.h:23
__le16 default_rx_ring_id
Definition: bnxt_hsi.h:5519
#define VNIC_CFG_REQ_ENABLES_DEFAULT_CMPL_RING_ID
Definition: bnxt_hsi.h:5512
static int wait_resp(struct bnxt *bp, u32 tmo, u16 len, const char *func)
Definition: bnxt.c:658
#define DBGP(...)
Definition: compiler.h:532
#define VNIC_CFG_REQ_ENABLES_DFLT_RING_GRP
Definition: bnxt_hsi.h:5506
#define VNIC_CFG_REQ_ENABLES_DEFAULT_RX_RING_ID
Definition: bnxt_hsi.h:5511
__le16 default_cmpl_ring_id
Definition: bnxt_hsi.h:5520
#define HWRM_VNIC_CFG
Definition: bnxt_hsi.h:150
#define VNIC_CFG_REQ_FLAGS_VLAN_STRIP_MODE
Definition: bnxt_hsi.h:5499

References bp, DBGP, hwrm_vnic_cfg_input::default_cmpl_ring_id, hwrm_vnic_cfg_input::default_rx_ring_id, hwrm_vnic_cfg_input::dflt_ring_grp, hwrm_vnic_cfg_input::enables, hwrm_vnic_cfg_input::flags, hwrm_init(), HWRM_VNIC_CFG, hwrm_vnic_cfg_input::mru, u16, VNIC_CFG_REQ_ENABLES_DEFAULT_CMPL_RING_ID, VNIC_CFG_REQ_ENABLES_DEFAULT_RX_RING_ID, VNIC_CFG_REQ_ENABLES_DFLT_RING_GRP, VNIC_CFG_REQ_ENABLES_MRU, VNIC_CFG_REQ_FLAGS_VLAN_STRIP_MODE, hwrm_vnic_cfg_input::vnic_id, and wait_resp().

◆ bnxt_set_rx_mask()

static int bnxt_set_rx_mask ( struct bnxt bp)
static

Definition at line 1840 of file bnxt.c.

1841 {
1842  return bnxt_hwrm_set_rx_mask ( bp, RX_MASK );
1843 }
uint16_t bp
Definition: registers.h:23
#define RX_MASK
Definition: bnxt.h:165
static int bnxt_hwrm_set_rx_mask(struct bnxt *bp, u32 rx_mask)
Definition: bnxt.c:1128

References bnxt_hwrm_set_rx_mask(), bp, and RX_MASK.

◆ bnxt_reset_rx_mask()

static int bnxt_reset_rx_mask ( struct bnxt bp)
static

Definition at line 1845 of file bnxt.c.

1846 {
1847  return bnxt_hwrm_set_rx_mask ( bp, 0 );
1848 }
uint16_t bp
Definition: registers.h:23
static int bnxt_hwrm_set_rx_mask(struct bnxt *bp, u32 rx_mask)
Definition: bnxt.c:1128

References bnxt_hwrm_set_rx_mask(), and bp.

◆ bnxt_hwrm_run()

int bnxt_hwrm_run ( hwrm_func_t  cmds[],
struct bnxt bp 
)

Definition at line 1906 of file bnxt.c.

1907 {
1908  hwrm_func_t *ptr;
1909  int ret;
1910 
1911  for ( ptr = cmds; *ptr; ++ptr ) {
1912  memset ( bp->hwrm_addr_req, 0, REQ_BUFFER_SIZE );
1913  memset ( bp->hwrm_addr_resp, 0, RESP_BUFFER_SIZE );
1914  ret = ( *ptr ) ( bp );
1915  if ( ret ) {
1916  DBGP ( "- %s ( ): Failed\n", __func__ );
1917  return STATUS_FAILURE;
1918  }
1919  }
1920  return STATUS_SUCCESS;
1921 }
#define STATUS_SUCCESS
Definition: bnxt.h:58
#define RESP_BUFFER_SIZE
Definition: bnxt.h:154
int(* hwrm_func_t)(struct bnxt *bp)
Definition: bnxt.c:1850
uint16_t bp
Definition: registers.h:23
#define DBGP(...)
Definition: compiler.h:532
#define REQ_BUFFER_SIZE
Definition: bnxt.h:153
#define STATUS_FAILURE
Definition: bnxt.h:59
void * memset(void *dest, int character, size_t len) __nonnull

References bp, DBGP, memset(), REQ_BUFFER_SIZE, RESP_BUFFER_SIZE, STATUS_FAILURE, and STATUS_SUCCESS.

◆ bnxt_open()

static int bnxt_open ( struct net_device dev)
static

Definition at line 1928 of file bnxt.c.

1929 {
1930  struct bnxt *bp = netdev_priv ( dev );
1931 
1932  DBGP ( "%s\n", __func__ );
1933  bnxt_mm_nic ( bp );
1934  return (bnxt_up_nic ( bp ));
1935 }
static void * netdev_priv(struct net_device *netdev)
Get driver private area for this network device.
Definition: netdevice.h:578
uint16_t bp
Definition: registers.h:23
void bnxt_mm_nic(struct bnxt *bp)
Definition: bnxt.c:525
#define DBGP(...)
Definition: compiler.h:532
#define bnxt_up_nic(bp)
Definition: bnxt.c:1926
struct net_device * dev
Definition: bnxt.h:739
Definition: bnxt.h:721

References bnxt_mm_nic(), bnxt_up_nic, bp, DBGP, bnxt::dev, and netdev_priv().

◆ bnxt_tx_adjust_pkt()

static void bnxt_tx_adjust_pkt ( struct bnxt bp,
struct io_buffer iob 
)
static

Definition at line 1937 of file bnxt.c.

1938 {
1939  u16 prev_len = iob_len ( iob );
1940 
1941  bp->vlan_tx = bnxt_get_pkt_vlan ( ( char * )iob->data );
1942  if ( !bp->vlan_tx && bp->vlan_id )
1943  bnxt_add_vlan ( iob, bp->vlan_id );
1944 
1945  dbg_tx_vlan ( bp, ( char * )iob->data, prev_len, iob_len ( iob ) );
1946  if ( iob_len ( iob ) != prev_len )
1947  prev_len = iob_len ( iob );
1948 
1949  iob_pad ( iob, ETH_ZLEN );
1950  dbg_tx_pad ( prev_len, iob_len ( iob ) );
1951 }
uint16_t u16
Definition: stdint.h:21
#define dbg_tx_vlan(bp, src, plen, len)
Definition: bnxt_dbg.h:578
uint16_t bp
Definition: registers.h:23
void bnxt_add_vlan(struct io_buffer *iob, u16 vlan)
Definition: bnxt.c:235
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:155
#define ETH_ZLEN
Definition: if_ether.h:10
void * data
Start of data.
Definition: iobuf.h:48
static u16 bnxt_get_pkt_vlan(char *src)
Definition: bnxt.c:249
#define dbg_tx_pad(plen, len)
Definition: bnxt_dbg.h:579
void iob_pad(struct io_buffer *iobuf, size_t min_len)
Pad I/O buffer.
Definition: iobpad.c:49

References bnxt_add_vlan(), bnxt_get_pkt_vlan(), bp, io_buffer::data, dbg_tx_pad, dbg_tx_vlan, ETH_ZLEN, iob_len(), and iob_pad().

Referenced by bnxt_tx().

◆ bnxt_tx()

static int bnxt_tx ( struct net_device dev,
struct io_buffer iob 
)
static

Definition at line 1953 of file bnxt.c.

1954 {
1955  struct bnxt *bp = netdev_priv ( dev );
1956  u16 len, entry;
1957  dma_addr_t mapping;
1958 
1959  if ( bnxt_tx_avail ( bp ) < 1 ) {
1960  DBGP ( "- %s ( ): Failed no bd's available\n", __func__ );
1961  return -ENOBUFS;
1962  }
1963 
1964  bnxt_tx_adjust_pkt ( bp, iob );
1965  entry = bp->tx.prod_id;
1966  mapping = virt_to_bus ( iob->data );
1967  len = iob_len ( iob );
1968  bp->tx.iob[entry] = iob;
1969  bnxt_set_txq ( bp, entry, mapping, len );
1970  entry = NEXT_IDX ( entry, bp->tx.ring_cnt );
1971  dump_tx_pkt ( ( u8 * )iob->data, len, bp->tx.prod_id );
1972  /* Packets are ready, update Tx producer idx local and on card. */
1973  bnxt_db_tx ( bp, ( u32 )entry );
1974  bp->tx.prod_id = entry;
1975  bp->tx.cnt_req++;
1976  /* memory barrier */
1977  mb ( );
1978  return 0;
1979 }
uint16_t u16
Definition: stdint.h:21
static void * netdev_priv(struct net_device *netdev)
Get driver private area for this network device.
Definition: netdevice.h:578
static void bnxt_db_tx(struct bnxt *bp, u32 idx)
Definition: bnxt.c:226
uint16_t bp
Definition: registers.h:23
static u32 bnxt_tx_avail(struct bnxt *bp)
Definition: bnxt.c:276
unsigned long dma_addr_t
Definition: bnx2.h:20
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition: io.h:183
#define DBGP(...)
Definition: compiler.h:532
static void bnxt_tx_adjust_pkt(struct bnxt *bp, struct io_buffer *iob)
Definition: bnxt.c:1937
void bnxt_set_txq(struct bnxt *bp, int entry, dma_addr_t mapping, int len)
Definition: bnxt.c:288
union aes_table_entry entry[256]
Table entries, indexed by S(N)
Definition: aes.c:26
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:155
#define dump_tx_pkt(pkt, len, idx)
Definition: bnxt_dbg.h:581
struct net_device * dev
Definition: bnxt.h:739
uint32_t len
Length.
Definition: ena.h:14
#define ENOBUFS
No buffer space available.
Definition: errno.h:498
void * data
Start of data.
Definition: iobuf.h:48
void mb(void)
Memory barrier.
#define NEXT_IDX(N, S)
Definition: bnxt.h:158
uint8_t u8
Definition: stdint.h:19
uint32_t u32
Definition: stdint.h:23
Definition: bnxt.h:721

References bnxt_db_tx(), bnxt_set_txq(), bnxt_tx_adjust_pkt(), bnxt_tx_avail(), bp, io_buffer::data, DBGP, bnxt::dev, dump_tx_pkt, ENOBUFS, entry, iob_len(), len, mb(), netdev_priv(), NEXT_IDX, and virt_to_bus().

◆ bnxt_adv_nq_index()

static void bnxt_adv_nq_index ( struct bnxt bp,
u16  cnt 
)
static

Definition at line 1981 of file bnxt.c.

1982 {
1983  u16 cons_id;
1984 
1985  cons_id = bp->nq.cons_id + cnt;
1986  if ( cons_id >= bp->nq.ring_cnt ) {
1987  /* Toggle completion bit when the ring wraps. */
1988  bp->nq.completion_bit ^= 1;
1989  cons_id = cons_id - bp->nq.ring_cnt;
1990  }
1991  bp->nq.cons_id = cons_id;
1992 }
uint16_t u16
Definition: stdint.h:21
uint16_t bp
Definition: registers.h:23

References bp.

Referenced by bnxt_service_nq().

◆ bnxt_service_nq()

static void bnxt_service_nq ( struct net_device dev)
static

Definition at line 2058 of file bnxt.c.

2059 {
2060  struct bnxt *bp = netdev_priv (