iPXE
Data Structures | Macros | Functions | Variables
sfc_hunt.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <byteswap.h>
#include <ipxe/io.h>
#include <ipxe/pci.h>
#include <ipxe/malloc.h>
#include <ipxe/ethernet.h>
#include <ipxe/iobuf.h>
#include <ipxe/netdevice.h>
#include "efx_hunt.h"
#include "efx_bitfield.h"
#include "ef10_regs.h"
#include "mc_driver_pcol.h"
#include <ipxe/if_ether.h>

Go to the source code of this file.

Data Structures

struct  hunt_nic
 

Macros

#define HUNTINGTON_NVRAM_CHUNK   0x80
 
#define HUNTINGTON_NVS_MAX_LENGTH   0x1000
 
#define EMCDI_IO(code)   EUNIQ(EINFO_EIO, (code))
 
#define MIN(a, b)   ((a) < (b) ? (a) : (b))
 
#define MAX(_a, _b)   ((_a) > (_b) ? (_a) : (_b))
 
#define MCDI_PORT_SPEED_CAPS
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
static int hunt_nic_is_primary (struct hunt_nic *hunt)
 
static int hunt_mcdi_init (struct hunt_nic *hunt)
 
static void hunt_mcdi_copyin (struct hunt_nic *hunt, unsigned int cmd, uint8_t *inbuf, size_t inlen)
 
static void hunt_mcdi_copyout (struct hunt_nic *hunt, uint8_t *outbuf, size_t outlen)
 
static int hunt_mcdi_request_poll (struct hunt_nic *hunt, bool quiet)
 
static void hunt_mcdi_fini (struct hunt_nic *hunt)
 
int _hunt_mcdi (struct efx_nic *efx, unsigned int cmd, const efx_dword_t *inbuf, size_t inlen, efx_dword_t *outbuf, size_t outlen, size_t *outlen_actual, bool quiet)
 
static int hunt_mcdi (struct hunt_nic *hunt, struct efx_mcdi_req_s *req)
 
static int hunt_mcdi_quiet (struct hunt_nic *hunt, struct efx_mcdi_req_s *req)
 
static int hunt_get_workarounds (struct hunt_nic *hunt, uint32_t *implemented, uint32_t *enabled)
 
static int hunt_enable_workaround_35388 (struct hunt_nic *hunt)
 
static int hunt_workaround_35388 (struct hunt_nic *hunt)
 
static int hunt_get_port_assignment (struct hunt_nic *hunt)
 
static int hunt_mac_addr (struct hunt_nic *hunt, uint8_t *ll_addr)
 
static int hunt_get_phy_cfg (struct hunt_nic *hunt)
 
static int hunt_driver_attach (struct hunt_nic *hunt, int attach)
 
static int hunt_reset (struct hunt_nic *hunt)
 
static void hunt_clear_udp_tunnel_ports (struct hunt_nic *hunt)
 
static int hunt_set_mac (struct hunt_nic *hunt)
 
static int hunt_alloc_vis (struct hunt_nic *hunt)
 
static void hunt_free_vis (struct hunt_nic *hunt)
 
static int hunt_check_link (struct hunt_nic *hunt)
 
static int hunt_tx_init (struct net_device *netdev, struct hunt_nic *hunt)
 
static void hunt_tx_fini (struct hunt_nic *hunt)
 
static int hunt_rx_filter_insert (struct net_device *netdev, struct hunt_nic *hunt, int multicast)
 
static int hunt_rx_filter_remove (struct hunt_nic *hunt, int multicast)
 
static int hunt_get_mac (struct hunt_nic *hunt)
 
static int hunt_rx_filter_init (struct net_device *netdev, struct hunt_nic *hunt)
 
static int hunt_rx_init (struct net_device *netdev, struct hunt_nic *hunt)
 
static void hunt_rx_filter_fini (struct hunt_nic *hunt)
 
static void hunt_rx_fini (struct hunt_nic *hunt)
 
static int hunt_ev_init (struct net_device *netdev, struct hunt_nic *hunt)
 
static void hunt_ev_fini (struct hunt_nic *hunt)
 
static void hunt_poll (struct net_device *netdev)
 
static int hunt_open (struct net_device *netdev)
 
static void hunt_close (struct net_device *netdev)
 
static int hunt_probe (struct pci_device *pci)
 
static void hunt_remove (struct pci_device *pci)
 

Variables

struct hunt_nicprimary_nics = NULL
 
static struct net_device_operations hunt_operations
 
const struct efx_nic_type hunt_nic_type
 
static struct pci_device_id hunt_nics []
 
struct pci_driver hunt_driver __pci_driver
 

Macro Definition Documentation

◆ HUNTINGTON_NVRAM_CHUNK

#define HUNTINGTON_NVRAM_CHUNK   0x80

Definition at line 39 of file sfc_hunt.c.

◆ HUNTINGTON_NVS_MAX_LENGTH

#define HUNTINGTON_NVS_MAX_LENGTH   0x1000

Definition at line 40 of file sfc_hunt.c.

◆ EMCDI_IO

#define EMCDI_IO (   code)    EUNIQ(EINFO_EIO, (code))

Definition at line 42 of file sfc_hunt.c.

◆ MIN

#define MIN (   a,
  b 
)    ((a) < (b) ? (a) : (b))

Definition at line 45 of file sfc_hunt.c.

◆ MAX

#define MAX (   _a,
  _b 
)    ((_a) > (_b) ? (_a) : (_b))

Definition at line 48 of file sfc_hunt.c.

◆ MCDI_PORT_SPEED_CAPS

#define MCDI_PORT_SPEED_CAPS
Value:
#define MC_CMD_PHY_CAP_1000HDX_LBN
#define MC_CMD_PHY_CAP_1000FDX_LBN
#define MC_CMD_PHY_CAP_40000FDX_LBN
#define MC_CMD_PHY_CAP_10000FDX_LBN
#define MC_CMD_PHY_CAP_10HDX_LBN
#define MC_CMD_PHY_CAP_100FDX_LBN
#define MC_CMD_PHY_CAP_10FDX_LBN
#define MC_CMD_PHY_CAP_100HDX_LBN

Definition at line 661 of file sfc_hunt.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ hunt_nic_is_primary()

static int hunt_nic_is_primary ( struct hunt_nic hunt)
static

Definition at line 82 of file sfc_hunt.c.

83 {
84  return (hunt->flags & (1 << MC_CMD_DRV_ATTACH_EXT_OUT_FLAG_PRIMARY));
85 }
#define MC_CMD_DRV_ATTACH_EXT_OUT_FLAG_PRIMARY
u32 flags
Definition: sfc_hunt.c:79

References hunt_nic::flags, and MC_CMD_DRV_ATTACH_EXT_OUT_FLAG_PRIMARY.

Referenced by hunt_probe().

◆ hunt_mcdi_init()

static int hunt_mcdi_init ( struct hunt_nic hunt)
static

Definition at line 97 of file sfc_hunt.c.

98 {
99  size_t max_msg_size;
100  int rc;
101 
102  /* The MCDI message has two 32-bit headers (the MCDI header and the
103  * MCDI v2 extended command) and then up to MCDI_CTL_SDU_LEN_MAX_V2
104  * bytes of payload
105  */
106  max_msg_size = 2 * sizeof(efx_dword_t) + MCDI_CTL_SDU_LEN_MAX_V2;
107 
108  hunt->mcdi.iob = alloc_iob(max_msg_size);
109  if (!hunt->mcdi.iob) {
110  rc = -ENOMEM;
111  return rc;
112  }
113  return 0;
114 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
struct io_buffer * iob
Definition: sfc_hunt.c:73
union efx_dword efx_dword_t
A doubleword (4 byte) datatype - little-endian in HW.
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
struct hunt_nic::@102 mcdi
#define MCDI_CTL_SDU_LEN_MAX_V2

References alloc_iob(), ENOMEM, hunt_nic::iob, hunt_nic::mcdi, MCDI_CTL_SDU_LEN_MAX_V2, and rc.

Referenced by hunt_probe().

◆ hunt_mcdi_copyin()

static void hunt_mcdi_copyin ( struct hunt_nic hunt,
unsigned int  cmd,
uint8_t inbuf,
size_t  inlen 
)
static

Definition at line 116 of file sfc_hunt.c.

120 {
121  efx_dword_t hdr[2];
122  uint32_t seqno;
123  unsigned int xflags;
124  size_t hdr_len;
125  u8 *pdu = hunt->mcdi.iob->data;
126 
127  seqno = hunt->mcdi.seqno & MCDI_SEQ_MASK;
128 
129  xflags = 0;
130 
132  MCDI_HEADER_CODE, MC_CMD_V2_EXTN,
133  MCDI_HEADER_RESYNC, 1,
134  MCDI_HEADER_DATALEN, 0,
135  MCDI_HEADER_SEQ, seqno,
136  MCDI_HEADER_ERROR, 0,
137  MCDI_HEADER_RESPONSE, 0,
138  MCDI_HEADER_XFLAGS, xflags);
140  MC_CMD_V2_EXTN_IN_EXTENDED_CMD, cmd,
141  MC_CMD_V2_EXTN_IN_ACTUAL_LEN, inlen);
142 
143  hdr_len = sizeof(hdr);
144 
145  memcpy(pdu, &hdr, hdr_len);
147  memcpy(pdu + hdr_len, inbuf, inlen);
148 
149  wmb(); /* Sync the data before ringing the doorbell */
150 
151  /* Ring the doorbell to post the command DMA address to the MC */
152  hunt->mcdi.dma_addr = virt_to_bus(hunt->mcdi.iob->data);
153 
154  assert((hunt->mcdi.dma_addr & 0xFF) == 0);
155 
156  _efx_writel(&hunt->efx,
157  cpu_to_le32((u64)hunt->mcdi.dma_addr >> 32),
159 
160  _efx_writel(&hunt->efx,
161  cpu_to_le32((u32)hunt->mcdi.dma_addr),
163 }
wmb()
struct io_buffer * iob
Definition: sfc_hunt.c:73
uint64_t dma_addr
Definition: sfc_hunt.c:74
struct golan_inbox_hdr hdr
Message header.
Definition: CIB_PRM.h:28
#define ER_DZ_MC_DB_LWRD
Definition: ef10_regs.h:70
static void _efx_writel(struct efx_nic *efx, uint32_t value, unsigned int reg)
Definition: efx_common.h:205
A doubleword (4 byte) datatype - little-endian in HW.
Definition: efx_bitfield.h:87
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition: io.h:183
#define ER_DZ_MC_DB_HWRD
Definition: ef10_regs.h:75
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
struct efx_nic efx
Definition: sfc_hunt.c:54
uint64_t u64
Definition: stdint.h:25
#define cpu_to_le32(value)
Definition: byteswap.h:107
unsigned int seqno
Definition: sfc_hunt.c:68
struct hunt_nic::@102 mcdi
unsigned int uint32_t
Definition: stdint.h:12
#define EFX_POPULATE_DWORD_2(dword,...)
Definition: efx_bitfield.h:421
#define MCDI_SEQ_MASK
Definition: mcdi.h:28
void * data
Start of data.
Definition: iobuf.h:48
#define EFX_POPULATE_DWORD_7(dword,...)
Definition: efx_bitfield.h:411
__be32 inlen
Definition: CIB_PRM.h:30
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29
#define MCDI_CTL_SDU_LEN_MAX_V2
uint8_t u8
Definition: stdint.h:19
#define MC_CMD_V2_EXTN
uint32_t u32
Definition: stdint.h:23

References _efx_writel(), assert(), cmd, cpu_to_le32, io_buffer::data, hunt_nic::dma_addr, hunt_nic::efx, EFX_POPULATE_DWORD_2, EFX_POPULATE_DWORD_7, ER_DZ_MC_DB_HWRD, ER_DZ_MC_DB_LWRD, hdr, inlen, hunt_nic::iob, MC_CMD_V2_EXTN, hunt_nic::mcdi, MCDI_CTL_SDU_LEN_MAX_V2, MCDI_SEQ_MASK, memcpy(), hunt_nic::seqno, virt_to_bus(), and wmb().

Referenced by _hunt_mcdi().

◆ hunt_mcdi_copyout()

static void hunt_mcdi_copyout ( struct hunt_nic hunt,
uint8_t outbuf,
size_t  outlen 
)
static

Definition at line 165 of file sfc_hunt.c.

167 {
168  size_t offset;
169  const u8 *pdu = hunt->mcdi.iob->data;
170 
171  offset = hunt->mcdi.resp_hdr_len;
172 
173  if (outlen > 0)
174  memcpy(outbuf, pdu+offset, outlen);
175 }
struct io_buffer * iob
Definition: sfc_hunt.c:73
__be32 outlen
Definition: CIB_PRM.h:41
size_t resp_hdr_len
Definition: sfc_hunt.c:70
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static userptr_t size_t offset
Offset of the first segment within the content.
Definition: deflate.h:259
struct hunt_nic::@102 mcdi
void * data
Start of data.
Definition: iobuf.h:48
uint8_t u8
Definition: stdint.h:19

References io_buffer::data, hunt_nic::iob, hunt_nic::mcdi, memcpy(), offset, outlen, and hunt_nic::resp_hdr_len.

Referenced by _hunt_mcdi().

◆ hunt_mcdi_request_poll()

static int hunt_mcdi_request_poll ( struct hunt_nic hunt,
bool  quiet 
)
static

Definition at line 177 of file sfc_hunt.c.

178 {
179  unsigned int resplen, respseq, error;
180  unsigned long finish;
181  efx_dword_t errdword;
182  efx_qword_t qword;
183  const efx_dword_t *pdu = hunt->mcdi.iob->data;
184  const u8 *pdu1 = hunt->mcdi.iob->data;
185  int delay, rc;
186 
187  /* Spin for up to 5s, polling at intervals of 10us, 20us, ... ~100ms */
188  finish = currticks() + (5 * TICKS_PER_SEC);
189  delay = 10;
190  while (1) {
191  udelay(delay);
192 
193  /* Check for an MCDI response */
194  if (EFX_DWORD_FIELD(*pdu, MCDI_HEADER_RESPONSE))
195  break;
196 
197  if (currticks() >= finish)
198  return -ETIMEDOUT;
199 
200  if (delay < 100000)
201  delay *= 2;
202  }
203 
204  memcpy(&qword, pdu1, 8);
205 
206  /* qword.dword[0] is the MCDI header; qword.dword[1] is the MCDI v2
207  * extended command
208  */
209  respseq = EFX_DWORD_FIELD(qword.dword[0], MCDI_HEADER_SEQ);
210  error = EFX_DWORD_FIELD(qword.dword[0], MCDI_HEADER_ERROR);
211  resplen = EFX_DWORD_FIELD(qword.dword[1], MC_CMD_V2_EXTN_IN_ACTUAL_LEN);
212 
213  if (error && resplen == 0) {
214  if (!quiet)
215  DBGC(hunt, "MC rebooted\n");
216  return -EIO;
217  } else if ((respseq ^ hunt->mcdi.seqno) & MCDI_SEQ_MASK) {
218  if (!quiet)
219  DBGC(hunt, "MC response mismatch rxseq 0x%x txseq "
220  "0x%x\n", respseq, hunt->mcdi.seqno);
221  return -EIO;
222  } else if (error) {
223  memcpy(&errdword, pdu1 + 8, 4);
224  rc = EFX_DWORD_FIELD(errdword, EFX_DWORD_0);
225  switch (rc) {
226  case MC_CMD_ERR_ENOENT:
227  return -ENOENT;
228  case MC_CMD_ERR_EINTR:
229  return -EINTR;
230  case MC_CMD_ERR_EACCES:
231  return -EACCES;
232  case MC_CMD_ERR_EBUSY:
233  return -EBUSY;
234  case MC_CMD_ERR_EINVAL:
235  return -EINVAL;
236  case MC_CMD_ERR_EDEADLK:
237  return -EDEADLK;
238  case MC_CMD_ERR_ENOSYS:
239  return -ENOSYS;
240  case MC_CMD_ERR_ETIME:
241  return -ETIME;
242  case MC_CMD_ERR_EPERM:
243  return -EPERM;
244  default:
245  /* Return the MC error in an I/O error. */
246  return EMCDI_IO(rc & 0xff);
247  }
248  }
249  hunt->mcdi.resp_hdr_len = 8;
250  hunt->mcdi.resp_data_len = resplen;
251 
252  return 0;
253 }
#define MC_CMD_ERR_ENOENT
#define EINVAL
Invalid argument.
Definition: errno.h:428
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
struct io_buffer * iob
Definition: sfc_hunt.c:73
#define TICKS_PER_SEC
Number of ticks per second.
Definition: timer.h:15
#define EBUSY
Device or resource busy.
Definition: errno.h:338
efx_dword_t dword[2]
Definition: efx_bitfield.h:95
struct arbelprm_completion_with_error error
Definition: arbel.h:12
#define DBGC(...)
Definition: compiler.h:505
#define ENOENT
No such file or directory.
Definition: errno.h:514
#define MC_CMD_ERR_EBUSY
#define EACCES
Permission denied.
Definition: errno.h:298
#define MC_CMD_ERR_EINTR
#define MC_CMD_ERR_EINVAL
A doubleword (4 byte) datatype - little-endian in HW.
Definition: efx_bitfield.h:87
size_t resp_hdr_len
Definition: sfc_hunt.c:70
#define MC_CMD_ERR_EPERM
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define EINTR
Interrupted function call.
Definition: errno.h:423
#define EDEADLK
Resource deadlock avoided.
Definition: errno.h:368
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
#define MC_CMD_ERR_ENOSYS
#define MC_CMD_ERR_ETIME
#define MC_CMD_ERR_EACCES
unsigned int seqno
Definition: sfc_hunt.c:68
size_t resp_data_len
Definition: sfc_hunt.c:71
struct hunt_nic::@102 mcdi
#define EMCDI_IO(code)
Definition: sfc_hunt.c:42
#define ETIME
Timer expired.
Definition: errno.h:664
#define EFX_DWORD_FIELD(dword, field)
Definition: efx_bitfield.h:197
#define MCDI_SEQ_MASK
Definition: mcdi.h:28
#define EPERM
Operation not permitted.
Definition: errno.h:614
uint16_t delay
Forward delay.
Definition: stp.h:40
void * data
Start of data.
Definition: iobuf.h:48
#define EIO
Input/output error.
Definition: errno.h:433
#define ENOSYS
Function not implemented.
Definition: errno.h:564
#define MC_CMD_ERR_EDEADLK
unsigned long currticks(void)
Get current system time in ticks.
Definition: timer.c:42
#define ETIMEDOUT
Connection timed out.
Definition: errno.h:669
A quadword (8 byte) datatype - little-endian in HW.
Definition: efx_bitfield.h:92
uint8_t u8
Definition: stdint.h:19

References currticks(), io_buffer::data, DBGC, delay, efx_qword::dword, EACCES, EBUSY, EDEADLK, EFX_DWORD_FIELD, EINTR, EINVAL, EIO, EMCDI_IO, ENOENT, ENOSYS, EPERM, error, ETIME, ETIMEDOUT, hunt_nic::iob, MC_CMD_ERR_EACCES, MC_CMD_ERR_EBUSY, MC_CMD_ERR_EDEADLK, MC_CMD_ERR_EINTR, MC_CMD_ERR_EINVAL, MC_CMD_ERR_ENOENT, MC_CMD_ERR_ENOSYS, MC_CMD_ERR_EPERM, MC_CMD_ERR_ETIME, hunt_nic::mcdi, MCDI_SEQ_MASK, memcpy(), rc, hunt_nic::resp_data_len, hunt_nic::resp_hdr_len, hunt_nic::seqno, TICKS_PER_SEC, and udelay().

Referenced by _hunt_mcdi().

◆ hunt_mcdi_fini()

static void hunt_mcdi_fini ( struct hunt_nic hunt)
static

Definition at line 255 of file sfc_hunt.c.

256 {
257  free_iob(hunt->mcdi.iob);
258 }
struct io_buffer * iob
Definition: sfc_hunt.c:73
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
Definition: iobuf.c:146
struct hunt_nic::@102 mcdi

References free_iob(), hunt_nic::iob, and hunt_nic::mcdi.

Referenced by hunt_probe(), and hunt_remove().

◆ _hunt_mcdi()

int _hunt_mcdi ( struct efx_nic efx,
unsigned int  cmd,
const efx_dword_t inbuf,
size_t  inlen,
efx_dword_t outbuf,
size_t  outlen,
size_t outlen_actual,
bool  quiet 
)

Definition at line 260 of file sfc_hunt.c.

264 {
265  int rc;
266  struct hunt_nic *hunt = (struct hunt_nic *) efx;
267  size_t local_outlen_actual;
268 
269  if (outlen_actual == NULL)
270  outlen_actual = &local_outlen_actual;
271 
272  ++hunt->mcdi.seqno;
273  hunt_mcdi_copyin(hunt, cmd, (uint8_t *) inbuf, inlen);
274 
275  rc = hunt_mcdi_request_poll(hunt, quiet);
276  if (rc != 0) {
277  if (!quiet)
278  DBGC(hunt, "MC response to cmd 0x%x: %s\n",
279  cmd, strerror(rc));
280  return rc;
281  }
282 
283  *outlen_actual = hunt->mcdi.resp_data_len;
284 
285  hunt_mcdi_copyout(hunt, (uint8_t *) outbuf, outlen);
286 
287  return 0;
288 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static int hunt_mcdi_request_poll(struct hunt_nic *hunt, bool quiet)
Definition: sfc_hunt.c:177
#define DBGC(...)
Definition: compiler.h:505
__be32 outlen
Definition: CIB_PRM.h:41
struct efx_nic efx
Definition: sfc_hunt.c:54
static void hunt_mcdi_copyout(struct hunt_nic *hunt, uint8_t *outbuf, size_t outlen)
Definition: sfc_hunt.c:165
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
unsigned int seqno
Definition: sfc_hunt.c:68
size_t resp_data_len
Definition: sfc_hunt.c:71
struct hunt_nic::@102 mcdi
unsigned char uint8_t
Definition: stdint.h:10
static void hunt_mcdi_copyin(struct hunt_nic *hunt, unsigned int cmd, uint8_t *inbuf, size_t inlen)
Definition: sfc_hunt.c:116
__be32 inlen
Definition: CIB_PRM.h:30
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29

References cmd, DBGC, hunt_nic::efx, hunt_mcdi_copyin(), hunt_mcdi_copyout(), hunt_mcdi_request_poll(), inlen, hunt_nic::mcdi, NULL, outlen, rc, hunt_nic::resp_data_len, hunt_nic::seqno, and strerror().

Referenced by hunt_mcdi(), and hunt_mcdi_quiet().

◆ hunt_mcdi()

static int hunt_mcdi ( struct hunt_nic hunt,
struct efx_mcdi_req_s req 
)
static

Definition at line 290 of file sfc_hunt.c.

291 {
292  return _hunt_mcdi(&hunt->efx, req->emr_cmd,
293  (const efx_dword_t *) req->emr_in_buf,
294  req->emr_in_length,
295  (efx_dword_t *) req->emr_out_buf, req->emr_out_length,
296  &req->emr_out_length_used, false);
297 }
size_t emr_in_length
Definition: efx_hunt.h:47
efx_dword_t * emr_out_buf
Definition: efx_hunt.h:49
size_t emr_out_length_used
Definition: efx_hunt.h:51
A doubleword (4 byte) datatype - little-endian in HW.
Definition: efx_bitfield.h:87
size_t emr_out_length
Definition: efx_hunt.h:50
struct efx_nic efx
Definition: sfc_hunt.c:54
efx_dword_t * emr_in_buf
Definition: efx_hunt.h:46
unsigned int emr_cmd
Definition: efx_hunt.h:45
int _hunt_mcdi(struct efx_nic *efx, unsigned int cmd, const efx_dword_t *inbuf, size_t inlen, efx_dword_t *outbuf, size_t outlen, size_t *outlen_actual, bool quiet)
Definition: sfc_hunt.c:260

References _hunt_mcdi(), hunt_nic::efx, efx_mcdi_req_s::emr_cmd, efx_mcdi_req_s::emr_in_buf, efx_mcdi_req_s::emr_in_length, efx_mcdi_req_s::emr_out_buf, efx_mcdi_req_s::emr_out_length, and efx_mcdi_req_s::emr_out_length_used.

Referenced by hunt_alloc_vis(), hunt_check_link(), hunt_driver_attach(), hunt_enable_workaround_35388(), hunt_ev_fini(), hunt_ev_init(), hunt_free_vis(), hunt_get_mac(), hunt_get_phy_cfg(), hunt_get_port_assignment(), hunt_get_workarounds(), hunt_mac_addr(), hunt_reset(), hunt_rx_filter_insert(), hunt_rx_filter_remove(), hunt_rx_fini(), hunt_rx_init(), hunt_set_mac(), hunt_tx_fini(), and hunt_tx_init().

◆ hunt_mcdi_quiet()

static int hunt_mcdi_quiet ( struct hunt_nic hunt,
struct efx_mcdi_req_s req 
)
static

Definition at line 299 of file sfc_hunt.c.

300 {
301  return _hunt_mcdi(&hunt->efx, req->emr_cmd,
302  (const efx_dword_t *) req->emr_in_buf,
303  req->emr_in_length,
304  (efx_dword_t *) req->emr_out_buf, req->emr_out_length,
305  &req->emr_out_length_used, true);
306 }
size_t emr_in_length
Definition: efx_hunt.h:47
efx_dword_t * emr_out_buf
Definition: efx_hunt.h:49
size_t emr_out_length_used
Definition: efx_hunt.h:51
A doubleword (4 byte) datatype - little-endian in HW.
Definition: efx_bitfield.h:87
size_t emr_out_length
Definition: efx_hunt.h:50
struct efx_nic efx
Definition: sfc_hunt.c:54
efx_dword_t * emr_in_buf
Definition: efx_hunt.h:46
unsigned int emr_cmd
Definition: efx_hunt.h:45
int _hunt_mcdi(struct efx_nic *efx, unsigned int cmd, const efx_dword_t *inbuf, size_t inlen, efx_dword_t *outbuf, size_t outlen, size_t *outlen_actual, bool quiet)
Definition: sfc_hunt.c:260

References _hunt_mcdi(), hunt_nic::efx, efx_mcdi_req_s::emr_cmd, efx_mcdi_req_s::emr_in_buf, efx_mcdi_req_s::emr_in_length, efx_mcdi_req_s::emr_out_buf, efx_mcdi_req_s::emr_out_length, and efx_mcdi_req_s::emr_out_length_used.

Referenced by hunt_clear_udp_tunnel_ports().

◆ hunt_get_workarounds()

static int hunt_get_workarounds ( struct hunt_nic hunt,
uint32_t implemented,
uint32_t enabled 
)
static

Definition at line 315 of file sfc_hunt.c.

317 {
318  struct efx_mcdi_req_s req;
320  int rc;
321 
322  *implemented = *enabled = 0;
323 
324  req.emr_cmd = MC_CMD_GET_WORKAROUNDS;
325  req.emr_in_buf = NULL;
326  req.emr_in_length = 0;
327  req.emr_out_buf = outbuf;
328  req.emr_out_length = sizeof(outbuf);
329 
330  rc = hunt_mcdi(hunt, &req);
331 
332  if (rc)
333  return rc;
334 
335  if (req.emr_out_length_used < MC_CMD_GET_WORKAROUNDS_OUT_LEN)
336  return -EMSGSIZE;
337 
338  *implemented = MCDI_DWORD(outbuf, GET_WORKAROUNDS_OUT_IMPLEMENTED);
339  *enabled = MCDI_DWORD(outbuf, GET_WORKAROUNDS_OUT_ENABLED);
340  return 0;
341 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define MCDI_DWORD(_buf, _field)
Definition: mcdi.h:53
uint32_t enabled
Bitmask of enabled AENQ groups (host -> device)
Definition: ena.h:14
#define MC_CMD_GET_WORKAROUNDS
#define EMSGSIZE
Message too long.
Definition: errno.h:463
#define MCDI_DECLARE_BUF(_name, _len)
Definition: mcdi.h:35
#define MC_CMD_GET_WORKAROUNDS_OUT_LEN
static int hunt_mcdi(struct hunt_nic *hunt, struct efx_mcdi_req_s *req)
Definition: sfc_hunt.c:290
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
MCDI request structure.
Definition: efx_hunt.h:44

References efx_mcdi_req_s::emr_cmd, efx_mcdi_req_s::emr_in_buf, efx_mcdi_req_s::emr_in_length, efx_mcdi_req_s::emr_out_buf, efx_mcdi_req_s::emr_out_length, efx_mcdi_req_s::emr_out_length_used, EMSGSIZE, enabled, hunt_mcdi(), MC_CMD_GET_WORKAROUNDS, MC_CMD_GET_WORKAROUNDS_OUT_LEN, MCDI_DECLARE_BUF, MCDI_DWORD, NULL, and rc.

Referenced by hunt_workaround_35388().

◆ hunt_enable_workaround_35388()

static int hunt_enable_workaround_35388 ( struct hunt_nic hunt)
static

Definition at line 343 of file sfc_hunt.c.

344 {
345  struct efx_mcdi_req_s req;
347 
348  req.emr_cmd = MC_CMD_WORKAROUND;
349  req.emr_in_buf = payload;
350  req.emr_in_length = MC_CMD_WORKAROUND_IN_LEN;
351  req.emr_out_buf = NULL;
352  req.emr_out_length = 0;
353 
354  MCDI_SET_DWORD(req.emr_in_buf, WORKAROUND_IN_TYPE,
356  MCDI_SET_DWORD(req.emr_in_buf, WORKAROUND_IN_ENABLED, 1);
357 
358  /* If the firmware doesn't support this workaround, hunt_mcdi() will
359  * return -EINVAL from hunt_mcdi_request_poll().
360  */
361  return hunt_mcdi(hunt, &req);
362 }
#define MCDI_SET_DWORD(_buf, _field, _value)
Definition: mcdi.h:51
#define MC_CMD_WORKAROUND_IN_LEN
#define MCDI_DECLARE_BUF(_name, _len)
Definition: mcdi.h:35
static int hunt_mcdi(struct hunt_nic *hunt, struct efx_mcdi_req_s *req)
Definition: sfc_hunt.c:290
#define MC_CMD_WORKAROUND
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
#define MC_CMD_WORKAROUND_BUG35388
MCDI request structure.
Definition: efx_hunt.h:44

References efx_mcdi_req_s::emr_cmd, efx_mcdi_req_s::emr_in_buf, efx_mcdi_req_s::emr_in_length, efx_mcdi_req_s::emr_out_buf, efx_mcdi_req_s::emr_out_length, hunt_mcdi(), MC_CMD_WORKAROUND, MC_CMD_WORKAROUND_BUG35388, MC_CMD_WORKAROUND_IN_LEN, MCDI_DECLARE_BUF, MCDI_SET_DWORD, and NULL.

Referenced by hunt_workaround_35388().

◆ hunt_workaround_35388()

static int hunt_workaround_35388 ( struct hunt_nic hunt)
static

Definition at line 364 of file sfc_hunt.c.

365 {
366  uint32_t implemented, enabled;
367  int rc = hunt_get_workarounds(hunt, &implemented, &enabled);
368 
369  if (rc < 0)
370  return 0;
371  if (!(implemented & MC_CMD_GET_WORKAROUNDS_OUT_BUG35388))
372  return 0;
374  return 1;
375 
377  if (rc == 0)
378  return 1; /* Workaround is enabled */
379  else
380  return 0;
381 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
uint32_t enabled
Bitmask of enabled AENQ groups (host -> device)
Definition: ena.h:14
#define MC_CMD_GET_WORKAROUNDS_OUT_BUG35388
static int hunt_get_workarounds(struct hunt_nic *hunt, uint32_t *implemented, uint32_t *enabled)
Definition: sfc_hunt.c:315
static int hunt_enable_workaround_35388(struct hunt_nic *hunt)
Definition: sfc_hunt.c:343
unsigned int uint32_t
Definition: stdint.h:12

References enabled, hunt_enable_workaround_35388(), hunt_get_workarounds(), MC_CMD_GET_WORKAROUNDS_OUT_BUG35388, and rc.

Referenced by hunt_probe().

◆ hunt_get_port_assignment()

static int hunt_get_port_assignment ( struct hunt_nic hunt)
static

Definition at line 383 of file sfc_hunt.c.

384 {
385  struct efx_mcdi_req_s req;
387  int rc;
388 
389  req.emr_cmd = MC_CMD_GET_PORT_ASSIGNMENT;
390  req.emr_in_buf = NULL;
391  req.emr_in_length = 0;
392  req.emr_out_buf = outbuf;
393  req.emr_out_length = sizeof(outbuf);
394 
395  rc = hunt_mcdi(hunt, &req);
396  if (rc != 0)
397  return rc;
398 
399  hunt->efx.port = MCDI_DWORD(req.emr_out_buf,
400  GET_PORT_ASSIGNMENT_OUT_PORT);
401  return 0;
402 }
int port
Definition: efx_common.h:152
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define MCDI_DWORD(_buf, _field)
Definition: mcdi.h:53
#define MC_CMD_GET_PORT_ASSIGNMENT
struct efx_nic efx
Definition: sfc_hunt.c:54
#define MCDI_DECLARE_BUF(_name, _len)
Definition: mcdi.h:35
static int hunt_mcdi(struct hunt_nic *hunt, struct efx_mcdi_req_s *req)
Definition: sfc_hunt.c:290
#define MC_CMD_GET_PORT_ASSIGNMENT_OUT_LEN
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
MCDI request structure.
Definition: efx_hunt.h:44

References hunt_nic::efx, efx_mcdi_req_s::emr_cmd, efx_mcdi_req_s::emr_in_buf, efx_mcdi_req_s::emr_in_length, efx_mcdi_req_s::emr_out_buf, efx_mcdi_req_s::emr_out_length, hunt_mcdi(), MC_CMD_GET_PORT_ASSIGNMENT, MC_CMD_GET_PORT_ASSIGNMENT_OUT_LEN, MCDI_DECLARE_BUF, MCDI_DWORD, NULL, efx_nic::port, and rc.

Referenced by hunt_probe().

◆ hunt_mac_addr()

static int hunt_mac_addr ( struct hunt_nic hunt,
uint8_t ll_addr 
)
static

Definition at line 404 of file sfc_hunt.c.

405 {
406  struct efx_mcdi_req_s req;
408  int rc;
409 
410  req.emr_cmd = MC_CMD_GET_MAC_ADDRESSES;
411  req.emr_in_buf = NULL;
412  req.emr_in_length = 0;
413  req.emr_out_buf = outbuf;
414  req.emr_out_length = MC_CMD_GET_MAC_ADDRESSES_OUT_LEN;
415 
416  rc = hunt_mcdi(hunt, &req);
417  if (rc != 0)
418  return rc;
419 
420  if (req.emr_out_length_used < MC_CMD_GET_MAC_ADDRESSES_OUT_LEN)
421  return -EMSGSIZE;
422 
423  memcpy(ll_addr,
424  MCDI_PTR(req.emr_out_buf, GET_MAC_ADDRESSES_OUT_MAC_ADDR_BASE),
425  ETH_ALEN);
426 
427  return 0;
428 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define MC_CMD_GET_MAC_ADDRESSES_OUT_LEN
#define MCDI_PTR(_buf, _field)
Definition: mcdi.h:41
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define EMSGSIZE
Message too long.
Definition: errno.h:463
#define MCDI_DECLARE_BUF(_name, _len)
Definition: mcdi.h:35
#define MC_CMD_GET_MAC_ADDRESSES
#define ETH_ALEN
Definition: if_ether.h:8
static int hunt_mcdi(struct hunt_nic *hunt, struct efx_mcdi_req_s *req)
Definition: sfc_hunt.c:290
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
MCDI request structure.
Definition: efx_hunt.h:44

References efx_mcdi_req_s::emr_cmd, efx_mcdi_req_s::emr_in_buf, efx_mcdi_req_s::emr_in_length, efx_mcdi_req_s::emr_out_buf, efx_mcdi_req_s::emr_out_length, efx_mcdi_req_s::emr_out_length_used, EMSGSIZE, ETH_ALEN, hunt_mcdi(), MC_CMD_GET_MAC_ADDRESSES, MC_CMD_GET_MAC_ADDRESSES_OUT_LEN, MCDI_DECLARE_BUF, MCDI_PTR, memcpy(), NULL, and rc.

Referenced by hunt_probe().

◆ hunt_get_phy_cfg()

static int hunt_get_phy_cfg ( struct hunt_nic hunt)
static

Definition at line 430 of file sfc_hunt.c.

431 {
432  struct efx_mcdi_req_s req;
434  int rc;
435 
436  req.emr_cmd = MC_CMD_GET_PHY_CFG;
437  req.emr_in_buf = NULL;
438  req.emr_in_length = 0;
439  req.emr_out_buf = outbuf;
440  req.emr_out_length = sizeof(outbuf);
441 
442  rc = hunt_mcdi(hunt, &req);
443  if (rc != 0)
444  return rc;
445 
446  if (req.emr_out_length_used < MC_CMD_GET_PHY_CFG_OUT_LEN)
447  return -EMSGSIZE;
448 
449  hunt->phy_cap_mask = hunt->phy_cap =
450  MCDI_DWORD(req.emr_out_buf, GET_PHY_CFG_OUT_SUPPORTED_CAP);
451  DBGC2(hunt, "GET_PHY_CFG: flags=%x, caps=%x\n", rc, hunt->phy_cap);
452  return 0;
453 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define MCDI_DWORD(_buf, _field)
Definition: mcdi.h:53
#define EMSGSIZE
Message too long.
Definition: errno.h:463
#define MCDI_DECLARE_BUF(_name, _len)
Definition: mcdi.h:35
unsigned int phy_cap
Definition: sfc_hunt.c:58
#define MC_CMD_GET_PHY_CFG_OUT_LEN
#define DBGC2(...)
Definition: compiler.h:522
static int hunt_mcdi(struct hunt_nic *hunt, struct efx_mcdi_req_s *req)
Definition: sfc_hunt.c:290
unsigned int phy_cap_mask
Definition: sfc_hunt.c:57
#define MC_CMD_GET_PHY_CFG
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
MCDI request structure.
Definition: efx_hunt.h:44

References DBGC2, efx_mcdi_req_s::emr_cmd, efx_mcdi_req_s::emr_in_buf, efx_mcdi_req_s::emr_in_length, efx_mcdi_req_s::emr_out_buf, efx_mcdi_req_s::emr_out_length, efx_mcdi_req_s::emr_out_length_used, EMSGSIZE, hunt_mcdi(), MC_CMD_GET_PHY_CFG, MC_CMD_GET_PHY_CFG_OUT_LEN, MCDI_DECLARE_BUF, MCDI_DWORD, NULL, hunt_nic::phy_cap, hunt_nic::phy_cap_mask, and rc.

Referenced by hunt_probe().

◆ hunt_driver_attach()

static int hunt_driver_attach ( struct hunt_nic hunt,
int  attach 
)
static

Definition at line 455 of file sfc_hunt.c.

456 {
457  struct efx_mcdi_req_s req;
460  int rc;
461 
462  req.emr_cmd = MC_CMD_DRV_ATTACH;
463  req.emr_in_buf = inbuf;
464  req.emr_in_length = sizeof(inbuf);
465  req.emr_out_buf = outbuf;
466  req.emr_out_length = sizeof(outbuf);
467 
468  /* Set the PREBOOT flag to indicate later instances of attach should
469  * force an ENTITY RESET
470  */
471  if (attach)
472  attach |= 1 << MC_CMD_DRV_PREBOOT_LBN;
473 
474  MCDI_SET_DWORD(req.emr_in_buf, DRV_ATTACH_IN_NEW_STATE, attach);
475  MCDI_SET_DWORD(req.emr_in_buf, DRV_ATTACH_IN_UPDATE, 1);
476  MCDI_SET_DWORD(req.emr_in_buf, DRV_ATTACH_IN_FIRMWARE_ID,
478 
479  rc = hunt_mcdi(hunt, &req);
480  if (rc != 0)
481  return rc;
482 
483  if (req.emr_out_length_used < MC_CMD_DRV_ATTACH_OUT_LEN)
484  return -EMSGSIZE;
485 
486  hunt->flags = MCDI_DWORD(outbuf, DRV_ATTACH_EXT_OUT_FUNC_FLAGS);
487 
488  return 0;
489 }
#define MCDI_SET_DWORD(_buf, _field, _value)
Definition: mcdi.h:51
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define MCDI_DWORD(_buf, _field)
Definition: mcdi.h:53
#define MC_CMD_FW_DONT_CARE
#define MC_CMD_DRV_ATTACH_OUT_LEN
#define MC_CMD_DRV_PREBOOT_LBN
#define MC_CMD_DRV_ATTACH
#define EMSGSIZE
Message too long.
Definition: errno.h:463
#define MCDI_DECLARE_BUF(_name, _len)
Definition: mcdi.h:35
u32 flags
Definition: sfc_hunt.c:79
static int hunt_mcdi(struct hunt_nic *hunt, struct efx_mcdi_req_s *req)
Definition: sfc_hunt.c:290
#define MC_CMD_DRV_ATTACH_IN_LEN
#define MC_CMD_DRV_ATTACH_EXT_OUT_LEN
MCDI request structure.
Definition: efx_hunt.h:44

References efx_mcdi_req_s::emr_cmd, efx_mcdi_req_s::emr_in_buf, efx_mcdi_req_s::emr_in_length, efx_mcdi_req_s::emr_out_buf, efx_mcdi_req_s::emr_out_length, efx_mcdi_req_s::emr_out_length_used, EMSGSIZE, hunt_nic::flags, hunt_mcdi(), MC_CMD_DRV_ATTACH, MC_CMD_DRV_ATTACH_EXT_OUT_LEN, MC_CMD_DRV_ATTACH_IN_LEN, MC_CMD_DRV_ATTACH_OUT_LEN, MC_CMD_DRV_PREBOOT_LBN, MC_CMD_FW_DONT_CARE, MCDI_DECLARE_BUF, MCDI_DWORD, MCDI_SET_DWORD, and rc.

Referenced by hunt_probe(), and hunt_remove().

◆ hunt_reset()

static int hunt_reset ( struct hunt_nic hunt)
static

Definition at line 491 of file sfc_hunt.c.

492 {
493  struct efx_mcdi_req_s req;
495 
496  req.emr_cmd = MC_CMD_ENTITY_RESET;
497  req.emr_in_buf = inbuf;
498  req.emr_in_length = sizeof(inbuf);
499  req.emr_out_buf = NULL;
500  req.emr_out_length = 0;
501 
502  MCDI_POPULATE_DWORD_1(req.emr_in_buf, ENTITY_RESET_IN_FLAG,
503  ENTITY_RESET_IN_FUNCTION_RESOURCE_RESET, 1);
504  return hunt_mcdi(hunt, &req);
505 }
#define MCDI_POPULATE_DWORD_1(_buf, _field, _name1, _value1)
Definition: mcdi.h:55
#define MCDI_DECLARE_BUF(_name, _len)
Definition: mcdi.h:35
#define MC_CMD_ENTITY_RESET_IN_LEN
static int hunt_mcdi(struct hunt_nic *hunt, struct efx_mcdi_req_s *req)
Definition: sfc_hunt.c:290
#define MC_CMD_ENTITY_RESET
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
MCDI request structure.
Definition: efx_hunt.h:44

References efx_mcdi_req_s::emr_cmd, efx_mcdi_req_s::emr_in_buf, efx_mcdi_req_s::emr_in_length, efx_mcdi_req_s::emr_out_buf, efx_mcdi_req_s::emr_out_length, hunt_mcdi(), MC_CMD_ENTITY_RESET, MC_CMD_ENTITY_RESET_IN_LEN, MCDI_DECLARE_BUF, MCDI_POPULATE_DWORD_1, and NULL.

Referenced by hunt_close(), and hunt_probe().

◆ hunt_clear_udp_tunnel_ports()

static void hunt_clear_udp_tunnel_ports ( struct hunt_nic hunt)
static

Definition at line 507 of file sfc_hunt.c.

508 {
511  struct efx_mcdi_req_s req;
512  int rc;
513 
515  MCDI_SET_DWORD(inbuf, SET_TUNNEL_ENCAP_UDP_PORTS_IN_FLAGS,
517 
518  req.emr_cmd = MC_CMD_SET_TUNNEL_ENCAP_UDP_PORTS;
519  req.emr_in_buf = inbuf;
520  req.emr_in_length = sizeof(inbuf);
521  req.emr_out_buf = outbuf;
522  req.emr_out_length = sizeof(outbuf);
523 
524  rc = hunt_mcdi_quiet(hunt, &req);
525  if (rc)
526  return;
527 
528  if (MCDI_DWORD(outbuf, SET_TUNNEL_ENCAP_UDP_PORTS_OUT_FLAGS) &
530  DBGC(hunt,
531  "Rebooting MC due to clearing UDP tunnel port list\n");
532  /* Delay for the MC reboot to complete. */
533  mdelay(100);
534  }
535 }
#define MCDI_SET_DWORD(_buf, _field, _value)
Definition: mcdi.h:51
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define DBGC(...)
Definition: compiler.h:505
#define MCDI_DWORD(_buf, _field)
Definition: mcdi.h:53
static int hunt_mcdi_quiet(struct hunt_nic *hunt, struct efx_mcdi_req_s *req)
Definition: sfc_hunt.c:299
#define MC_CMD_SET_TUNNEL_ENCAP_UDP_PORTS
#define MC_CMD_SET_TUNNEL_ENCAP_UDP_PORTS_OUT_LEN
#define MCDI_DECLARE_BUF(_name, _len)
Definition: mcdi.h:35
#define MC_CMD_SET_TUNNEL_ENCAP_UDP_PORTS_IN_UNLOADING_LBN
#define MC_CMD_SET_TUNNEL_ENCAP_UDP_PORTS_OUT_RESETTING_LBN
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition: timer.c:78
#define MC_CMD_SET_TUNNEL_ENCAP_UDP_PORTS_IN_LENMAX
MCDI request structure.
Definition: efx_hunt.h:44
void * memset(void *dest, int character, size_t len) __nonnull

References DBGC, efx_mcdi_req_s::emr_cmd, efx_mcdi_req_s::emr_in_buf, efx_mcdi_req_s::emr_in_length, efx_mcdi_req_s::emr_out_buf, efx_mcdi_req_s::emr_out_length, hunt_mcdi_quiet(), MC_CMD_SET_TUNNEL_ENCAP_UDP_PORTS, MC_CMD_SET_TUNNEL_ENCAP_UDP_PORTS_IN_LENMAX, MC_CMD_SET_TUNNEL_ENCAP_UDP_PORTS_IN_UNLOADING_LBN, MC_CMD_SET_TUNNEL_ENCAP_UDP_PORTS_OUT_LEN, MC_CMD_SET_TUNNEL_ENCAP_UDP_PORTS_OUT_RESETTING_LBN, MCDI_DECLARE_BUF, MCDI_DWORD, MCDI_SET_DWORD, mdelay(), memset(), and rc.

Referenced by hunt_probe().

◆ hunt_set_mac()

static int hunt_set_mac ( struct hunt_nic hunt)
static

Definition at line 537 of file sfc_hunt.c.

538 {
539  struct net_device *netdev = hunt->efx.netdev;
540  struct efx_mcdi_req_s req;
542  unsigned int fcntl;
543  int rc;
544 
545  req.emr_cmd = MC_CMD_SET_MAC;
546  req.emr_in_buf = payload;
547  req.emr_in_length = MC_CMD_SET_MAC_IN_LEN;
548  req.emr_out_buf = NULL;
549  req.emr_out_length = 0;
550 
551  MCDI_SET_DWORD(req.emr_in_buf, SET_MAC_IN_MTU,
553  MCDI_SET_DWORD(req.emr_in_buf, SET_MAC_IN_DRAIN, 0);
554  memcpy(MCDI_PTR(req.emr_in_buf, SET_MAC_IN_ADDR),
556  MCDI_SET_DWORD(req.emr_in_buf, SET_MAC_IN_REJECT, 0);
557 
558  /* If the PHY supports autnegotiation, then configure the MAC to match
559  * the negotiated settings. Otherwise force the MAC to TX and RX flow
560  * control.
561  */
562  if (hunt->phy_cap_mask & (1 << MC_CMD_PHY_CAP_AN_LBN))
563  fcntl = MC_CMD_FCNTL_AUTO;
564  else
565  fcntl = MC_CMD_FCNTL_BIDIR;
566  MCDI_SET_DWORD(req.emr_in_buf, SET_MAC_IN_FCNTL, fcntl);
567 
568  rc = hunt_mcdi(hunt, &req);
569  /* Ignore failure for permissions reasons */
570  if (rc == -EPERM)
571  rc = 0;
572  return rc;
573 }
#define MCDI_SET_DWORD(_buf, _field, _value)
Definition: mcdi.h:51
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define MC_CMD_FCNTL_AUTO
#define MCDI_PTR(_buf, _field)
Definition: mcdi.h:41
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define ETH_FRAME_LEN
Definition: if_ether.h:11
struct efx_nic efx
Definition: sfc_hunt.c:54
static struct net_device * netdev
Definition: gdbudp.c:52
#define EFX_MAC_FRAME_LEN(_mtu)
Definition: efx_common.h:190
#define MC_CMD_SET_MAC
#define MCDI_DECLARE_BUF(_name, _len)
Definition: mcdi.h:35
A network device.
Definition: netdevice.h:352
#define ETH_ALEN
Definition: if_ether.h:8
#define EPERM
Operation not permitted.
Definition: errno.h:614
static int hunt_mcdi(struct hunt_nic *hunt, struct efx_mcdi_req_s *req)
Definition: sfc_hunt.c:290
unsigned int phy_cap_mask
Definition: sfc_hunt.c:57
#define MC_CMD_FCNTL_BIDIR
#define MC_CMD_PHY_CAP_AN_LBN
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
Definition: netdevice.h:387
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
#define MC_CMD_SET_MAC_IN_LEN
struct net_device * netdev
Definition: efx_common.h:148
MCDI request structure.
Definition: efx_hunt.h:44

References hunt_nic::efx, EFX_MAC_FRAME_LEN, efx_mcdi_req_s::emr_cmd, efx_mcdi_req_s::emr_in_buf, efx_mcdi_req_s::emr_in_length, efx_mcdi_req_s::emr_out_buf, efx_mcdi_req_s::emr_out_length, EPERM, ETH_ALEN, ETH_FRAME_LEN, hunt_mcdi(), net_device::ll_addr, MC_CMD_FCNTL_AUTO, MC_CMD_FCNTL_BIDIR, MC_CMD_PHY_CAP_AN_LBN, MC_CMD_SET_MAC, MC_CMD_SET_MAC_IN_LEN, MCDI_DECLARE_BUF, MCDI_PTR, MCDI_SET_DWORD, memcpy(), netdev, efx_nic::netdev, NULL, hunt_nic::phy_cap_mask, and rc.

Referenced by hunt_open().

◆ hunt_alloc_vis()

static int hunt_alloc_vis ( struct hunt_nic hunt)
static

Definition at line 575 of file sfc_hunt.c.

576 {
577  struct efx_mcdi_req_s req;
579 
580  req.emr_cmd = MC_CMD_ALLOC_VIS;
581  req.emr_in_buf = inbuf;
582  req.emr_in_length = sizeof(inbuf);
583  req.emr_out_buf = NULL;
584  req.emr_out_length = 0;
585 
586  MCDI_SET_DWORD(req.emr_in_buf, ALLOC_VIS_IN_MIN_VI_COUNT, 1);
587  MCDI_SET_DWORD(req.emr_in_buf, ALLOC_VIS_IN_MAX_VI_COUNT, 1);
588 
589  return hunt_mcdi(hunt, &req);
590 }
#define MCDI_SET_DWORD(_buf, _field, _value)
Definition: mcdi.h:51
#define MCDI_DECLARE_BUF(_name, _len)
Definition: mcdi.h:35
#define MC_CMD_ALLOC_VIS_IN_LEN
static int hunt_mcdi(struct hunt_nic *hunt, struct efx_mcdi_req_s *req)
Definition: sfc_hunt.c:290
#define MC_CMD_ALLOC_VIS
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
MCDI request structure.
Definition: efx_hunt.h:44

References efx_mcdi_req_s::emr_cmd, efx_mcdi_req_s::emr_in_buf, efx_mcdi_req_s::emr_in_length, efx_mcdi_req_s::emr_out_buf, efx_mcdi_req_s::emr_out_length, hunt_mcdi(), MC_CMD_ALLOC_VIS, MC_CMD_ALLOC_VIS_IN_LEN, MCDI_DECLARE_BUF, MCDI_SET_DWORD, and NULL.

Referenced by hunt_open().

◆ hunt_free_vis()

static void hunt_free_vis ( struct hunt_nic hunt)
static

Definition at line 592 of file sfc_hunt.c.

593 {
594  struct efx_mcdi_req_s req;
595  int rc;
596 
597  req.emr_cmd = MC_CMD_FREE_VIS;
598  req.emr_in_buf = NULL;
599  req.emr_in_length = 0;
600  req.emr_out_buf = NULL;
601  req.emr_out_length = 0;
602 
603  rc = hunt_mcdi(hunt, &req);
604  if (rc != 0)
605  DBGC(hunt, "MC_CMD_FREE_VIS Failed\n");
606 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define DBGC(...)
Definition: compiler.h:505
#define MC_CMD_FREE_VIS
static int hunt_mcdi(struct hunt_nic *hunt, struct efx_mcdi_req_s *req)
Definition: sfc_hunt.c:290
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
MCDI request structure.
Definition: efx_hunt.h:44

References DBGC, efx_mcdi_req_s::emr_cmd, efx_mcdi_req_s::emr_in_buf, efx_mcdi_req_s::emr_in_length, efx_mcdi_req_s::emr_out_buf, efx_mcdi_req_s::emr_out_length, hunt_mcdi(), MC_CMD_FREE_VIS, NULL, and rc.

Referenced by hunt_close(), and hunt_open().

◆ hunt_check_link()

static int hunt_check_link ( struct hunt_nic hunt)
static

Definition at line 615 of file sfc_hunt.c.

616 {
617  struct efx_mcdi_req_s req;
619  unsigned int flags, speed;
620  bool up;
621  int rc;
622  static bool link_state = false;
623 
624  req.emr_cmd = MC_CMD_GET_LINK;
625  req.emr_in_buf = NULL;
626  req.emr_in_length = 0;
627  req.emr_out_buf = outbuf;
628  req.emr_out_length = sizeof(outbuf);
629 
630  rc = hunt_mcdi(hunt, &req);
631  if (rc != 0)
632  return rc;
633 
634  if (req.emr_out_length_used < MC_CMD_GET_LINK_OUT_LEN)
635  return -EMSGSIZE;
636 
637  flags = MCDI_DWORD(req.emr_out_buf, GET_LINK_OUT_FLAGS);
638  up = !!(flags & (1 << MC_CMD_GET_LINK_OUT_LINK_UP_LBN));
639  speed = MCDI_DWORD(req.emr_out_buf, GET_LINK_OUT_LINK_SPEED);
640 
641  /* Set netdev_link_*() based on the link status from the MC */
642  if (up && speed)
643  netdev_link_up(hunt->efx.netdev);
644  else
645  netdev_link_down(hunt->efx.netdev);
646 
647  if (up != link_state) {
648  DBGC(hunt, "Link %s, flags=%x, our caps=%x, lpa=%x, speed=%d, fcntl=%x, mac_fault=%x\n",
649  (up? "up": "down"), flags,
650  MCDI_DWORD(req.emr_out_buf, GET_LINK_OUT_CAP),
651  MCDI_DWORD(req.emr_out_buf, GET_LINK_OUT_LP_CAP),
652  speed,
653  MCDI_DWORD(req.emr_out_buf, GET_LINK_OUT_FCNTL),
654  MCDI_DWORD(req.emr_out_buf, GET_LINK_OUT_MAC_FAULT));
655  link_state = up;
656  }
657 
658  return 0;
659 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define MC_CMD_GET_LINK_OUT_LEN
#define MC_CMD_GET_LINK
#define DBGC(...)
Definition: compiler.h:505
#define MCDI_DWORD(_buf, _field)
Definition: mcdi.h:53
void netdev_link_down(struct net_device *netdev)
Mark network device as having link down.
Definition: netdevice.c:230
#define EMSGSIZE
Message too long.
Definition: errno.h:463
struct efx_nic efx
Definition: sfc_hunt.c:54
static void netdev_link_up(struct net_device *netdev)
Mark network device as having link up.
Definition: netdevice.h:774
#define MCDI_DECLARE_BUF(_name, _len)
Definition: mcdi.h:35
#define MC_CMD_GET_LINK_OUT_LINK_UP_LBN
static int hunt_mcdi(struct hunt_nic *hunt, struct efx_mcdi_req_s *req)
Definition: sfc_hunt.c:290
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
struct net_device * netdev
Definition: efx_common.h:148
MCDI request structure.
Definition: efx_hunt.h:44
uint8_t flags
Flags.
Definition: ena.h:18

References DBGC, hunt_nic::efx, efx_mcdi_req_s::emr_cmd, efx_mcdi_req_s::emr_in_buf, efx_mcdi_req_s::emr_in_length, efx_mcdi_req_s::emr_out_buf, efx_mcdi_req_s::emr_out_length, efx_mcdi_req_s::emr_out_length_used, EMSGSIZE, flags, hunt_mcdi(), MC_CMD_GET_LINK, MC_CMD_GET_LINK_OUT_LEN, MC_CMD_GET_LINK_OUT_LINK_UP_LBN, MCDI_DECLARE_BUF, MCDI_DWORD, efx_nic::netdev, netdev_link_down(), netdev_link_up(), NULL, and rc.

Referenced by hunt_open(), and hunt_poll().

◆ hunt_tx_init()

static int hunt_tx_init ( struct net_device netdev,
struct hunt_nic hunt 
)
static

Definition at line 678 of file sfc_hunt.c.

679 {
680  struct efx_mcdi_req_s req;
681  dma_addr_t dma_addr;
682  efx_qword_t *addr;
683  MCDI_DECLARE_BUF(inbuf,
685  int rc, npages;
686 
687  rc = efx_hunt_tx_init(netdev, &dma_addr);
688  if (rc != 0)
689  return rc;
690 
691  npages = EFX_TXQ_NBUFS(EFX_TXD_SIZE);
692 
693  req.emr_cmd = MC_CMD_INIT_TXQ;
694  req.emr_in_buf = inbuf;
695  req.emr_in_length = MC_CMD_INIT_TXQ_IN_LEN(npages);
696  req.emr_out_buf = NULL;
697  req.emr_out_length = 0;
698 
699  MCDI_SET_DWORD(req.emr_in_buf, INIT_TXQ_IN_SIZE, EFX_TXD_SIZE);
700  MCDI_SET_DWORD(req.emr_in_buf, INIT_TXQ_IN_TARGET_EVQ, 0);
701  MCDI_SET_DWORD(req.emr_in_buf, INIT_TXQ_IN_LABEL, 0);
702  MCDI_SET_DWORD(req.emr_in_buf, INIT_TXQ_IN_INSTANCE, 0);
703 
704  MCDI_POPULATE_DWORD_6(req.emr_in_buf, INIT_TXQ_IN_FLAGS,
705  INIT_TXQ_IN_FLAG_BUFF_MODE, 0,
706  INIT_TXQ_IN_FLAG_IP_CSUM_DIS, 1,
707  INIT_TXQ_IN_FLAG_TCP_CSUM_DIS, 1,
708  INIT_TXQ_IN_FLAG_TCP_UDP_ONLY, 0,
709  INIT_TXQ_IN_CRC_MODE, 0,
710  INIT_TXQ_IN_FLAG_TIMESTAMP, 0);
711 
712  MCDI_SET_DWORD(req.emr_in_buf, INIT_TXQ_IN_OWNER_ID, 0);
713  MCDI_SET_DWORD(req.emr_in_buf, INIT_TXQ_IN_PORT_ID,
715 
716  addr = (efx_qword_t *) MCDI_PTR(req.emr_in_buf, INIT_TXQ_IN_DMA_ADDR);
717 
719  EFX_DWORD_1, (uint32_t)(dma_addr >> 32),
720  EFX_DWORD_0, (uint32_t)(dma_addr & 0xffffffff));
721 
722  return hunt_mcdi(hunt, &req);
723 }
#define MC_CMD_INIT_TXQ_IN_LEN(num)
#define MCDI_SET_DWORD(_buf, _field, _value)
Definition: mcdi.h:51
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define MC_CMD_INIT_TXQ
#define EFX_TXQ_NBUFS(_ndescs)
Definition: efx_hunt.h:41
unsigned long dma_addr_t
Definition: bnx2.h:20
int efx_hunt_tx_init(struct net_device *netdev, dma_addr_t *dma_addr)
Definition: efx_hunt.c:156
#define MCDI_PTR(_buf, _field)
Definition: mcdi.h:41
static struct net_device * netdev
Definition: gdbudp.c:52
#define EFX_POPULATE_QWORD_2(qword,...)
Definition: efx_bitfield.h:394
#define MCDI_DECLARE_BUF(_name, _len)
Definition: mcdi.h:35
u32 addr
Definition: sky2.h:8
unsigned int uint32_t
Definition: stdint.h:12
#define MCDI_POPULATE_DWORD_6(_buf, _field, _name1, _value1, _name2, _value2, _name3, _value3, _name4, _value4, _name5, _value5, _name6, _value6)
Definition: mcdi.h:86
static int hunt_mcdi(struct hunt_nic *hunt, struct efx_mcdi_req_s *req)
Definition: sfc_hunt.c:290
#define EFX_TXD_SIZE
Definition: efx_common.h:58
#define EVB_PORT_ID_ASSIGNED
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
A quadword (8 byte) datatype - little-endian in HW.
Definition: efx_bitfield.h:92
MCDI request structure.
Definition: efx_hunt.h:44

References addr, efx_hunt_tx_init(), EFX_POPULATE_QWORD_2, EFX_TXD_SIZE, EFX_TXQ_NBUFS, efx_mcdi_req_s::emr_cmd, efx_mcdi_req_s::emr_in_buf, efx_mcdi_req_s::emr_in_length, efx_mcdi_req_s::emr_out_buf, efx_mcdi_req_s::emr_out_length, EVB_PORT_ID_ASSIGNED, hunt_mcdi(), MC_CMD_INIT_TXQ, MC_CMD_INIT_TXQ_IN_LEN, MCDI_DECLARE_BUF, MCDI_POPULATE_DWORD_6, MCDI_PTR, MCDI_SET_DWORD, netdev, NULL, and rc.

Referenced by hunt_open().

◆ hunt_tx_fini()

static void hunt_tx_fini ( struct hunt_nic hunt)
static

Definition at line 725 of file sfc_hunt.c.

726 {
727  struct efx_mcdi_req_s req;
729  struct efx_nic *efx = &hunt->efx;
730  struct efx_tx_queue *txq = &efx->txq;
731  int rc;
732 
733  req.emr_cmd = MC_CMD_FINI_TXQ;
734  req.emr_in_buf = inbuf;
735  req.emr_in_length = sizeof(inbuf);
736  req.emr_out_buf = NULL;
737  req.emr_out_length = 0;
738 
739  MCDI_SET_DWORD(req.emr_in_buf, FINI_TXQ_IN_INSTANCE, 0);
740 
741  rc = hunt_mcdi(hunt, &req);
742  if (rc != 0)
743  DBGC(hunt, "MC_CMD_FINI_TXQ Failed\n");
744 
746  sizeof(efx_tx_desc_t) * EFX_TXD_SIZE);
747  txq->ring = NULL;
748 }
#define MCDI_SET_DWORD(_buf, _field, _value)
Definition: mcdi.h:51
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
Hardware access.
Definition: efx_common.h:147
A transmit queue.
Definition: efx_common.h:89
#define MC_CMD_FINI_TXQ
#define DBGC(...)
Definition: compiler.h:505
efx_tx_desc_t * ring
Definition: efx_common.h:91
struct efx_nic efx
Definition: sfc_hunt.c:54
#define MCDI_DECLARE_BUF(_name, _len)
Definition: mcdi.h:35
static int hunt_mcdi(struct hunt_nic *hunt, struct efx_mcdi_req_s *req)
Definition: sfc_hunt.c:290
struct efx_tx_queue txq
Definition: efx_common.h:165
#define EFX_TXD_SIZE
Definition: efx_common.h:58
void efx_hunt_free_special_buffer(void *buf, int bytes)
Definition: efx_hunt.c:39
#define MC_CMD_FINI_TXQ_IN_LEN
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
A quadword (8 byte) datatype - little-endian in HW.
Definition: efx_bitfield.h:92
MCDI request structure.
Definition: efx_hunt.h:44

References DBGC, hunt_nic::efx, efx_hunt_free_special_buffer(), EFX_TXD_SIZE, efx_mcdi_req_s::emr_cmd, efx_mcdi_req_s::emr_in_buf, efx_mcdi_req_s::emr_in_length, efx_mcdi_req_s::emr_out_buf, efx_mcdi_req_s::emr_out_length, hunt_mcdi(), MC_CMD_FINI_TXQ, MC_CMD_FINI_TXQ_IN_LEN, MCDI_DECLARE_BUF, MCDI_SET_DWORD, NULL, rc, efx_tx_queue::ring, and efx_nic::txq.

Referenced by hunt_close(), and hunt_open().

◆ hunt_rx_filter_insert()

static int hunt_rx_filter_insert ( struct net_device netdev,
struct hunt_nic hunt,
int  multicast 
)
static

Definition at line 757 of file sfc_hunt.c.

760 {
761  struct efx_mcdi_req_s req;
764  int rc;
765  uint64_t filter_id;
766  (void) netdev;
767 
768  req.emr_cmd = MC_CMD_FILTER_OP;
769  req.emr_in_buf = inbuf;
770  req.emr_in_length = sizeof(inbuf);
771  req.emr_out_buf = outbuf;
772  req.emr_out_length = sizeof(outbuf);
773 
774  MCDI_SET_DWORD(req.emr_in_buf, FILTER_OP_IN_OP,
777  MCDI_POPULATE_DWORD_1(req.emr_in_buf, FILTER_OP_IN_MATCH_FIELDS,
778  FILTER_OP_IN_MATCH_DST_MAC, 1);
779  if (multicast)
780  memset(MCDI_PTR(req.emr_in_buf, FILTER_OP_IN_DST_MAC),
781  0xff, ETH_ALEN);
782  else
783  memcpy(MCDI_PTR(req.emr_in_buf, FILTER_OP_IN_DST_MAC),
784  hunt->mac, ETH_ALEN);
785 
786  MCDI_SET_DWORD(req.emr_in_buf, FILTER_OP_IN_PORT_ID,
788  MCDI_SET_DWORD(req.emr_in_buf, FILTER_OP_IN_RX_DEST,
790  MCDI_SET_DWORD(req.emr_in_buf, FILTER_OP_IN_RX_QUEUE, 0);
791  MCDI_SET_DWORD(req.emr_in_buf, FILTER_OP_IN_RX_MODE, 0);
792  MCDI_SET_DWORD(req.emr_in_buf, FILTER_OP_IN_TX_DEST,
794 
795  rc = hunt_mcdi(hunt, &req);
796  if (rc != 0)
797  return rc;
798 
799  if (req.emr_out_length_used < MC_CMD_FILTER_OP_OUT_LEN)
800  return -EIO;
801 
802  filter_id = MCDI_QWORD(req.emr_out_buf, FILTER_OP_OUT_HANDLE);
803  if (multicast)
804  hunt->mc_filter_id = filter_id;
805  else
806  hunt->uc_filter_id = filter_id;
807 
808  return 0;
809 }
#define MCDI_SET_DWORD(_buf, _field, _value)
Definition: mcdi.h:51
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define MC_CMD_FILTER_OP_IN_RX_DEST_HOST
#define MC_CMD_FILTER_OP_IN_OP_INSERT
#define MCDI_QWORD(_buf, _field)
Definition: mcdi.h:116
#define MC_CMD_FILTER_OP_IN_LEN
#define MCDI_POPULATE_DWORD_1(_buf, _field, _name1, _value1)
Definition: mcdi.h:55
#define MC_CMD_FILTER_OP_IN_TX_DEST_DEFAULT
unsigned long long uint64_t
Definition: stdint.h:13
uint64_t mc_filter_id
Definition: sfc_hunt.c:63
u8 mac[ETH_ALEN]
Definition: sfc_hunt.c:64
#define MC_CMD_FILTER_OP
#define MCDI_PTR(_buf, _field)
Definition: mcdi.h:41
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static struct net_device * netdev
Definition: gdbudp.c:52
#define MCDI_DECLARE_BUF(_name, _len)
Definition: mcdi.h:35
#define MC_CMD_FILTER_OP_OUT_LEN
#define ETH_ALEN
Definition: if_ether.h:8
#define MC_CMD_FILTER_OP_IN_OP_SUBSCRIBE
static int hunt_mcdi(struct hunt_nic *hunt, struct efx_mcdi_req_s *req)
Definition: sfc_hunt.c:290
#define EIO
Input/output error.
Definition: errno.h:433
#define EVB_PORT_ID_ASSIGNED
uint64_t uc_filter_id
Definition: sfc_hunt.c:62
MCDI request structure.
Definition: efx_hunt.h:44
void * memset(void *dest, int character, size_t len) __nonnull

References EIO, efx_mcdi_req_s::emr_cmd, efx_mcdi_req_s::emr_in_buf, efx_mcdi_req_s::emr_in_length, efx_mcdi_req_s::emr_out_buf, efx_mcdi_req_s::emr_out_length, efx_mcdi_req_s::emr_out_length_used, ETH_ALEN, EVB_PORT_ID_ASSIGNED, hunt_mcdi(), hunt_nic::mac, MC_CMD_FILTER_OP, MC_CMD_FILTER_OP_IN_LEN, MC_CMD_FILTER_OP_IN_OP_INSERT, MC_CMD_FILTER_OP_IN_OP_SUBSCRIBE, MC_CMD_FILTER_OP_IN_RX_DEST_HOST, MC_CMD_FILTER_OP_IN_TX_DEST_DEFAULT, MC_CMD_FILTER_OP_OUT_LEN, hunt_nic::mc_filter_id, MCDI_DECLARE_BUF, MCDI_POPULATE_DWORD_1, MCDI_PTR, MCDI_QWORD, MCDI_SET_DWORD, memcpy(), memset(), netdev, rc, and hunt_nic::uc_filter_id.

Referenced by hunt_rx_filter_init().

◆ hunt_rx_filter_remove()

static int hunt_rx_filter_remove ( struct hunt_nic hunt,
int  multicast 
)
static

Definition at line 811 of file sfc_hunt.c.

813 {
814  struct efx_mcdi_req_s req;
816 
817  req.emr_cmd = MC_CMD_FILTER_OP;
818  req.emr_in_buf = inbuf;
819  req.emr_in_length = sizeof(inbuf);
820  req.emr_out_buf = NULL;
821  req.emr_out_length = 0;
822 
823  MCDI_SET_DWORD(req.emr_in_buf, FILTER_OP_IN_OP,
826  MCDI_SET_QWORD(req.emr_in_buf, FILTER_OP_IN_HANDLE,
827  multicast ? hunt->mc_filter_id :
828  hunt->uc_filter_id);
829  return hunt_mcdi(hunt, &req);
830 }
#define MCDI_SET_DWORD(_buf, _field, _value)
Definition: mcdi.h:51
#define MC_CMD_FILTER_OP_IN_OP_REMOVE
#define MC_CMD_FILTER_OP_IN_LEN
#define MC_CMD_FILTER_OP_IN_OP_UNSUBSCRIBE
uint64_t mc_filter_id
Definition: sfc_hunt.c:63
#define MC_CMD_FILTER_OP
#define MCDI_DECLARE_BUF(_name, _len)
Definition: mcdi.h:35
static int hunt_mcdi(struct hunt_nic *hunt, struct efx_mcdi_req_s *req)
Definition: sfc_hunt.c:290
#define MCDI_SET_QWORD(_buf, _field, _value)
Definition: mcdi.h:109
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
uint64_t uc_filter_id
Definition: sfc_hunt.c:62
MCDI request structure.
Definition: efx_hunt.h:44

References efx_mcdi_req_s::emr_cmd, efx_mcdi_req_s::emr_in_buf, efx_mcdi_req_s::emr_in_length, efx_mcdi_req_s::emr_out_buf, efx_mcdi_req_s::emr_out_length, hunt_mcdi(), MC_CMD_FILTER_OP, MC_CMD_FILTER_OP_IN_LEN, MC_CMD_FILTER_OP_IN_OP_REMOVE, MC_CMD_FILTER_OP_IN_OP_UNSUBSCRIBE, hunt_nic::mc_filter_id, MCDI_DECLARE_BUF, MCDI_SET_DWORD, MCDI_SET_QWORD, NULL, and hunt_nic::uc_filter_id.

Referenced by hunt_rx_filter_fini(), and hunt_rx_filter_init().

◆ hunt_get_mac()

static int hunt_get_mac ( struct hunt_nic hunt)
static

Definition at line 832 of file sfc_hunt.c.

833 {
834  struct efx_mcdi_req_s req;
836  int rc;
837 
838  req.emr_cmd = MC_CMD_GET_MAC_ADDRESSES;
839  req.emr_in_buf = NULL;
840  req.emr_in_length = 0;
841  req.emr_out_buf = outbuf;
842  req.emr_out_length = sizeof(outbuf);
843 
844  rc = hunt_mcdi(hunt, &req);
845  if (rc != 0)
846  return rc;
847 
848  if (req.emr_out_length_used < MC_CMD_INIT_EVQ_OUT_LEN)
849  return -EMSGSIZE;
850 
851  memcpy(hunt->mac, MCDI_PTR(outbuf, GET_MAC_ADDRESSES_OUT_MAC_ADDR_BASE),
852  ETH_ALEN);
853  return 0;
854 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define MC_CMD_GET_MAC_ADDRESSES_OUT_LEN
u8 mac[ETH_ALEN]
Definition: sfc_hunt.c:64
#define MCDI_PTR(_buf, _field)
Definition: mcdi.h:41
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define EMSGSIZE
Message too long.
Definition: errno.h:463
#define MCDI_DECLARE_BUF(_name, _len)
Definition: mcdi.h:35
#define MC_CMD_GET_MAC_ADDRESSES
#define ETH_ALEN
Definition: if_ether.h:8
static int hunt_mcdi(struct hunt_nic *hunt, struct efx_mcdi_req_s *req)
Definition: sfc_hunt.c:290
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
#define MC_CMD_INIT_EVQ_OUT_LEN
MCDI request structure.
Definition: efx_hunt.h:44

References efx_mcdi_req_s::emr_cmd, efx_mcdi_req_s::emr_in_buf, efx_mcdi_req_s::emr_in_length, efx_mcdi_req_s::emr_out_buf, efx_mcdi_req_s::emr_out_length, efx_mcdi_req_s::emr_out_length_used, EMSGSIZE, ETH_ALEN, hunt_mcdi(), hunt_nic::mac, MC_CMD_GET_MAC_ADDRESSES, MC_CMD_GET_MAC_ADDRESSES_OUT_LEN, MC_CMD_INIT_EVQ_OUT_LEN, MCDI_DECLARE_BUF, MCDI_PTR, memcpy(), NULL, and rc.

Referenced by hunt_rx_filter_init().

◆ hunt_rx_filter_init()

static int hunt_rx_filter_init ( struct net_device netdev,
struct hunt_nic hunt 
)
static

Definition at line 856 of file sfc_hunt.c.

858 {
859  int rc = hunt_get_mac(hunt);
860 
861  if (rc != 0)
862  return rc;
863 
864  rc = hunt_rx_filter_insert(netdev, hunt, 0);
865  if (rc != 0)
866  return rc;
867 
868  rc = hunt_rx_filter_insert(netdev, hunt, 1);
869  if (rc != 0)
870  hunt_rx_filter_remove(hunt, 0);
871 
872  return rc;
873 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static int hunt_rx_filter_insert(struct net_device *netdev, struct hunt_nic *hunt, int multicast)
Definition: sfc_hunt.c:757
static int hunt_rx_filter_remove(struct hunt_nic *hunt, int multicast)
Definition: sfc_hunt.c:811
static struct net_device * netdev
Definition: gdbudp.c:52
static int hunt_get_mac(struct hunt_nic *hunt)
Definition: sfc_hunt.c:832

References hunt_get_mac(), hunt_rx_filter_insert(), hunt_rx_filter_remove(), netdev, and rc.

Referenced by hunt_open().

◆ hunt_rx_init()

static int hunt_rx_init ( struct net_device netdev,
struct hunt_nic hunt 
)
static

Definition at line 876 of file sfc_hunt.c.

878 {
879  struct efx_mcdi_req_s req;
880  dma_addr_t dma_addr;
881  efx_qword_t *addr;
882  MCDI_DECLARE_BUF(inbuf,
884  int rc, npages;
885 
886  rc = efx_hunt_rx_init(netdev, &dma_addr);
887  if (rc != 0)
888  return rc;
889 
890  npages = EFX_RXQ_NBUFS(EFX_RXD_SIZE);
891 
892  req.emr_cmd = MC_CMD_INIT_RXQ;
893  req.emr_in_buf = inbuf;
894  req.emr_in_length = MC_CMD_INIT_RXQ_IN_LEN(npages);
895  req.emr_out_buf = NULL;
896  req.emr_out_length = 0;
897 
898  MCDI_SET_DWORD(req.emr_in_buf, INIT_RXQ_IN_SIZE, EFX_RXD_SIZE);
899  MCDI_SET_DWORD(req.emr_in_buf, INIT_RXQ_IN_TARGET_EVQ, 0);
900  MCDI_SET_DWORD(req.emr_in_buf, INIT_RXQ_IN_LABEL, 0);
901  MCDI_SET_DWORD(req.emr_in_buf, INIT_RXQ_IN_INSTANCE, 0);
902  MCDI_POPULATE_DWORD_5(req.emr_in_buf, INIT_RXQ_IN_FLAGS,
903  INIT_RXQ_IN_FLAG_BUFF_MODE, 0,
904  INIT_RXQ_IN_FLAG_HDR_SPLIT, 0,
905  INIT_RXQ_IN_FLAG_TIMESTAMP, 0,
906  INIT_RXQ_IN_CRC_MODE, 0,
907  INIT_RXQ_IN_FLAG_PREFIX, 1);
908  MCDI_SET_DWORD(req.emr_in_buf, INIT_RXQ_IN_OWNER_ID, 0);
909  MCDI_SET_DWORD(req.emr_in_buf, INIT_RXQ_IN_PORT_ID,
911 
912  addr = (efx_qword_t *) MCDI_PTR(req.emr_in_buf, INIT_RXQ_IN_DMA_ADDR);
913 
915  EFX_DWORD_1, (uint32_t)(dma_addr >> 32),
916  EFX_DWORD_0, (uint32_t)(dma_addr & 0xffffffff));
917  return hunt_mcdi(hunt, &req);
918 }
#define MCDI_SET_DWORD(_buf, _field, _value)
Definition: mcdi.h:51
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
int efx_hunt_rx_init(struct net_device *netdev, dma_addr_t *dma_addr)
Definition: efx_hunt.c:271
unsigned long dma_addr_t
Definition: bnx2.h:20
#define MC_CMD_INIT_RXQ
#define MCDI_PTR(_buf, _field)
Definition: mcdi.h:41
static struct net_device * netdev
Definition: gdbudp.c:52
#define EFX_RXD_SIZE
Definition: efx_common.h:56
#define EFX_POPULATE_QWORD_2(qword,...)
Definition: efx_bitfield.h:394
#define MCDI_DECLARE_BUF(_name, _len)
Definition: mcdi.h:35
#define EFX_RXQ_NBUFS(_ndescs)
Definition: efx_hunt.h:38
u32 addr
Definition: sky2.h:8
unsigned int uint32_t
Definition: stdint.h:12
static int hunt_mcdi(struct hunt_nic *hunt, struct efx_mcdi_req_s *req)
Definition: sfc_hunt.c:290
#define EVB_PORT_ID_ASSIGNED
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
#define MCDI_POPULATE_DWORD_5(_buf, _field, _name1, _value1, _name2, _value2, _name3, _value3, _name4, _value4, _name5, _value5)
Definition: mcdi.h:77
A quadword (8 byte) datatype - little-endian in HW.
Definition: efx_bitfield.h:92
MCDI request structure.
Definition: efx_hunt.h:44
#define MC_CMD_INIT_RXQ_IN_LEN(num)

References addr, efx_hunt_rx_init(), EFX_POPULATE_QWORD_2, EFX_RXD_SIZE, EFX_RXQ_NBUFS, efx_mcdi_req_s::emr_cmd, efx_mcdi_req_s::emr_in_buf, efx_mcdi_req_s::emr_in_length, efx_mcdi_req_s::emr_out_buf, efx_mcdi_req_s::emr_out_length, EVB_PORT_ID_ASSIGNED, hunt_mcdi(), MC_CMD_INIT_RXQ, MC_CMD_INIT_RXQ_IN_LEN, MCDI_DECLARE_BUF, MCDI_POPULATE_DWORD_5, MCDI_PTR, MCDI_SET_DWORD, netdev, NULL, and rc.

Referenced by hunt_open().

◆ hunt_rx_filter_fini()

static void hunt_rx_filter_fini ( struct hunt_nic hunt)
static

Definition at line 920 of file sfc_hunt.c.

921 {
922  hunt_rx_filter_remove(hunt, 0);
923  hunt_rx_filter_remove(hunt, 1);
924 }
static int hunt_rx_filter_remove(struct hunt_nic *hunt, int multicast)
Definition: sfc_hunt.c:811

References hunt_rx_filter_remove().

Referenced by hunt_close(), and hunt_open().

◆ hunt_rx_fini()

static void hunt_rx_fini ( struct hunt_nic hunt)
static

Definition at line 926 of file sfc_hunt.c.

927 {
929  struct efx_mcdi_req_s req;
930  struct efx_nic *efx = &hunt->efx;
931  struct efx_rx_queue *rxq = &efx->rxq;
932  int rc;
933 
934  req.emr_cmd = MC_CMD_FINI_RXQ;
935  req.emr_in_buf = inbuf;
936  req.emr_in_length = MC_CMD_FINI_RXQ_IN_LEN;
937  req.emr_out_buf = NULL;
938  req.emr_out_length = 0;
939 
940  MCDI_SET_DWORD(req.emr_in_buf, FINI_RXQ_IN_INSTANCE, 0);
941 
942  rc = hunt_mcdi(hunt, &req);
943  if (rc != 0)
944  DBGC(hunt, "MC_CMD_FINI_RXQ Failed\n");
945 
947  sizeof(efx_rx_desc_t) * EFX_RXD_SIZE);
948  rxq->ring = NULL;
949 }
#define MCDI_SET_DWORD(_buf, _field, _value)
Definition: mcdi.h:51
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
Hardware access.
Definition: efx_common.h:147
A receive queue.
Definition: efx_common.h:107
#define DBGC(...)
Definition: compiler.h:505
efx_rx_desc_t * ring
Definition: efx_common.h:109
#define MC_CMD_FINI_RXQ_IN_LEN
struct efx_nic efx
Definition: sfc_hunt.c:54
#define EFX_RXD_SIZE
Definition: efx_common.h:56
#define MCDI_DECLARE_BUF(_name, _len)
Definition: mcdi.h:35
struct efx_rx_queue rxq
Definition: efx_common.h:164
static int hunt_mcdi(struct hunt_nic *hunt, struct efx_mcdi_req_s *req)
Definition: sfc_hunt.c:290
#define MC_CMD_FINI_RXQ
void efx_hunt_free_special_buffer(void *buf, int bytes)
Definition: efx_hunt.c:39
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
A quadword (8 byte) datatype - little-endian in HW.
Definition: efx_bitfield.h:92
MCDI request structure.
Definition: efx_hunt.h:44

References DBGC, hunt_nic::efx, efx_hunt_free_special_buffer(), EFX_RXD_SIZE, efx_mcdi_req_s::emr_cmd, efx_mcdi_req_s::emr_in_buf, efx_mcdi_req_s::emr_in_length, efx_mcdi_req_s::emr_out_buf, efx_mcdi_req_s::emr_out_length, hunt_mcdi(), MC_CMD_FINI_RXQ, MC_CMD_FINI_RXQ_IN_LEN, MCDI_DECLARE_BUF, MCDI_SET_DWORD, NULL, rc, efx_rx_queue::ring, and efx_nic::rxq.

Referenced by hunt_close(), and hunt_open().

◆ hunt_ev_init()

static int hunt_ev_init ( struct net_device netdev,
struct hunt_nic hunt 
)
static

Definition at line 959 of file sfc_hunt.c.

961 {
962  struct efx_mcdi_req_s req;
963  dma_addr_t dma_addr;
964  efx_qword_t *addr;
965  MCDI_DECLARE_BUF(inbuf,
968  int rc, npages;
969 
970  rc = efx_hunt_ev_init(netdev, &dma_addr);
971  if (rc != 0)
972  return rc;
973 
974  npages = EFX_EVQ_NBUFS(EFX_EVQ_SIZE);
975 
976  req.emr_cmd = MC_CMD_INIT_EVQ;
977  req.emr_in_buf = inbuf;
978  req.emr_in_length = MC_CMD_INIT_EVQ_IN_LEN(npages);
979  req.emr_out_buf = outbuf;
980  req.emr_out_length = sizeof(outbuf);
981 
982  MCDI_SET_DWORD(req.emr_in_buf, INIT_EVQ_IN_SIZE, EFX_EVQ_SIZE);
983  MCDI_SET_DWORD(req.emr_in_buf, INIT_EVQ_IN_INSTANCE, 0);
984  MCDI_SET_DWORD(req.emr_in_buf, INIT_EVQ_IN_IRQ_NUM, 0);
985 
986  MCDI_POPULATE_DWORD_6(req.emr_in_buf, INIT_EVQ_IN_FLAGS,
987  INIT_EVQ_IN_FLAG_INTERRUPTING, 1,
988  INIT_EVQ_IN_FLAG_RPTR_DOS, 0,
989  INIT_EVQ_IN_FLAG_INT_ARMD, 0,
990  INIT_EVQ_IN_FLAG_CUT_THRU, 0,
991  INIT_EVQ_IN_FLAG_RX_MERGE, 0,
992  INIT_EVQ_IN_FLAG_TX_MERGE, 0);
993 
994  MCDI_SET_DWORD(req.emr_in_buf, INIT_EVQ_IN_TMR_MODE,
996  MCDI_SET_DWORD(req.emr_in_buf, INIT_EVQ_IN_TMR_LOAD, 0);
997  MCDI_SET_DWORD(req.emr_in_buf, INIT_EVQ_IN_TMR_RELOAD, 0);
998 
999  MCDI_SET_DWORD(req.emr_in_buf, INIT_EVQ_IN_COUNT_MODE,
1001  MCDI_SET_DWORD(req.emr_in_buf, INIT_EVQ_IN_COUNT_THRSHLD, 0);
1002 
1003  addr = (efx_qword_t *) MCDI_PTR(req.emr_in_buf, INIT_EVQ_IN_DMA_ADDR);
1004 
1006  EFX_DWORD_1, (uint32_t)(dma_addr >> 32),
1007  EFX_DWORD_0, (uint32_t)(dma_addr & 0xffffffff));
1008  rc = hunt_mcdi(hunt, &req);
1009  if (rc != 0)
1010  return rc;
1011 
1012  if (req.emr_out_length_used < MC_CMD_INIT_EVQ_OUT_LEN)
1013  return -EMSGSIZE;
1014 
1015  return 0;
1016 }
#define MCDI_SET_DWORD(_buf, _field, _value)
Definition: mcdi.h:51
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define MC_CMD_INIT_EVQ_IN_LEN(num)
#define EFX_EVQ_SIZE
Definition: efx_common.h:60
#define MC_CMD_INIT_EVQ_IN_TMR_MODE_DIS
int efx_hunt_ev_init(struct net_device *netdev, dma_addr_t *dma_addr)
Definition: efx_hunt.c:295
unsigned long dma_addr_t
Definition: bnx2.h:20
#define EFX_EVQ_NBUFS(_nevs)
Definition: efx_hunt.h:35
#define MCDI_PTR(_buf, _field)
Definition: mcdi.h:41
#define EMSGSIZE
Message too long.
Definition: errno.h:463
static struct net_device * netdev
Definition: gdbudp.c:52
#define MC_CMD_INIT_EVQ_IN_COUNT_MODE_DIS
#define EFX_POPULATE_QWORD_2(qword,...)
Definition: efx_bitfield.h:394
#define MCDI_DECLARE_BUF(_name, _len)
Definition: mcdi.h:35
u32 addr
Definition: sky2.h:8
unsigned int uint32_t
Definition: stdint.h:12
#define MCDI_POPULATE_DWORD_6(_buf, _field, _name1, _value1, _name2, _value2, _name3, _value3, _name4, _value4, _name5, _value5, _name6, _value6)
Definition: mcdi.h:86
static int hunt_mcdi(struct hunt_nic *hunt, struct efx_mcdi_req_s *req)
Definition: sfc_hunt.c:290
#define MC_CMD_INIT_EVQ
#define MC_CMD_INIT_EVQ_OUT_LEN
A quadword (8 byte) datatype - little-endian in HW.
Definition: efx_bitfield.h:92
MCDI request structure.
Definition: efx_hunt.h:44

References addr, EFX_EVQ_NBUFS, EFX_EVQ_SIZE, efx_hunt_ev_init(), EFX_POPULATE_QWORD_2, efx_mcdi_req_s::emr_cmd, efx_mcdi_req_s::emr_in_buf, efx_mcdi_req_s::emr_in_length, efx_mcdi_req_s::emr_out_buf, efx_mcdi_req_s::emr_out_length, efx_mcdi_req_s::emr_out_length_used, EMSGSIZE, hunt_mcdi(), MC_CMD_INIT_EVQ, MC_CMD_INIT_EVQ_IN_COUNT_MODE_DIS, MC_CMD_INIT_EVQ_IN_LEN, MC_CMD_INIT_EVQ_IN_TMR_MODE_DIS, MC_CMD_INIT_EVQ_OUT_LEN, MCDI_DECLARE_BUF, MCDI_POPULATE_DWORD_6, MCDI_PTR, MCDI_SET_DWORD, netdev, and rc.

Referenced by hunt_open().

◆ hunt_ev_fini()

static void hunt_ev_fini ( struct hunt_nic hunt)
static

Definition at line 1018 of file sfc_hunt.c.

1019 {
1021  struct efx_mcdi_req_s req;
1022  struct efx_nic *efx = &hunt->efx;
1023  struct efx_ev_queue *evq = &efx->evq;
1024  int rc;
1025 
1026  req.emr_cmd = MC_CMD_FINI_EVQ;
1027  req.emr_in_buf = inbuf;
1028  req.emr_in_length = sizeof(inbuf);
1029  req.emr_out_buf = NULL;
1030  req.emr_out_length = 0;
1031 
1032  MCDI_SET_DWORD(req.emr_in_buf, FINI_EVQ_IN_INSTANCE, 0);
1033 
1034  rc = hunt_mcdi(hunt, &req);
1035  if (rc != 0)
1036  DBGC(hunt, "MC_CMD_FINI_EVQ Failed\n");
1037 
1039  sizeof(efx_event_t) * EFX_EVQ_SIZE);
1040  evq->ring = NULL;
1041 }
#define MCDI_SET_DWORD(_buf, _field, _value)
Definition: mcdi.h:51
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
Hardware access.
Definition: efx_common.h:147
#define EFX_EVQ_SIZE
Definition: efx_common.h:60
#define DBGC(...)
Definition: compiler.h:505
#define MC_CMD_FINI_EVQ
struct efx_nic efx
Definition: sfc_hunt.c:54
#define MCDI_DECLARE_BUF(_name, _len)
Definition: mcdi.h:35
efx_event_t * ring
Definition: efx_common.h:132
static int hunt_mcdi(struct hunt_nic *hunt, struct efx_mcdi_req_s *req)
Definition: sfc_hunt.c:290
struct efx_ev_queue evq
Definition: efx_common.h:166
#define MC_CMD_FINI_EVQ_IN_LEN
An event queue.
Definition: efx_common.h:128
void efx_hunt_free_special_buffer(void *buf, int bytes)
Definition: efx_hunt.c:39
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
A quadword (8 byte) datatype - little-endian in HW.
Definition: efx_bitfield.h:92
MCDI request structure.
Definition: efx_hunt.h:44

References DBGC, hunt_nic::efx, EFX_EVQ_SIZE, efx_hunt_free_special_buffer(), efx_mcdi_req_s::emr_cmd, efx_mcdi_req_s::emr_in_buf, efx_mcdi_req_s::emr_in_length, efx_mcdi_req_s::emr_out_buf, efx_mcdi_req_s::emr_out_length, efx_nic::evq, hunt_mcdi(), MC_CMD_FINI_EVQ, MC_CMD_FINI_EVQ_IN_LEN, MCDI_DECLARE_BUF, MCDI_SET_DWORD, NULL, rc, and efx_ev_queue::ring.

Referenced by hunt_close(), and hunt_open().

◆ hunt_poll()

static void hunt_poll ( struct net_device netdev)
static

Definition at line 1044 of file sfc_hunt.c.

1045 {
1046  struct hunt_nic *hunt = netdev->priv;
1047 
1048  /* If called while already polling, return immediately */
1049  if (hunt->efx.state & EFX_STATE_POLLING)
1050  return;
1051  hunt->efx.state |= EFX_STATE_POLLING;
1052 
1053  /* Poll link state */
1054  if (hunt->link_poll_timer + TICKS_PER_SEC < currticks()) {
1055  hunt->link_poll_timer = currticks();
1056  hunt_check_link(hunt);
1057  }
1058 
1059  /* Poll data path */
1061 
1062  hunt->efx.state &= ~EFX_STATE_POLLING;
1063 }
void efx_hunt_poll(struct net_device *netdev)
Definition: efx_hunt.c:405
#define TICKS_PER_SEC
Number of ticks per second.
Definition: timer.h:15
u32 state
Definition: efx_common.h:153
void * priv
Driver private data.
Definition: netdevice.h:431
struct efx_nic efx
Definition: sfc_hunt.c:54
static struct net_device * netdev
Definition: gdbudp.c:52
#define EFX_STATE_POLLING
Definition: efx_common.h:78
static int hunt_check_link(struct hunt_nic *hunt)
Definition: sfc_hunt.c:615
unsigned long currticks(void)
Get current system time in ticks.
Definition: timer.c:42
unsigned long link_poll_timer
Definition: sfc_hunt.c:59

References currticks(), hunt_nic::efx, efx_hunt_poll(), EFX_STATE_POLLING, hunt_check_link(), hunt_nic::link_poll_timer, netdev, net_device::priv, efx_nic::state, and TICKS_PER_SEC.

◆ hunt_open()

static int hunt_open ( struct net_device netdev)
static

Definition at line 1072 of file sfc_hunt.c.

1073 {
1074  struct hunt_nic *hunt = netdev->priv;
1075  int rc;
1076 
1077  /* Allocate VIs */
1078  rc = hunt_alloc_vis(hunt);
1079  if (rc != 0)
1080  goto fail2;
1081 
1082  /* Initialize data path */
1083  rc = hunt_ev_init(netdev, hunt);
1084  if (rc != 0)
1085  goto fail3;
1086 
1087  rc = hunt_rx_init(netdev, hunt);
1088  if (rc != 0)
1089  goto fail4;
1090 
1091  rc = hunt_rx_filter_init(netdev, hunt);
1092  if (rc != 0)
1093  goto fail5;
1094 
1095  rc = hunt_tx_init(netdev, hunt);
1096  if (rc != 0)
1097  goto fail6;
1098 
1099  rc = efx_hunt_open(netdev);
1100  if (rc)
1101  goto fail7;
1102 
1103  rc = hunt_set_mac(hunt);
1104  if (rc)
1105  goto fail8;
1106 
1107  /* Mark the link as down before checking the link state because the
1108  * latter might fail.
1109  */
1111  hunt_check_link(hunt);
1112 
1113  DBGC2(hunt, "%s: open ok\n", netdev->name);
1114  return 0;
1115 
1116 fail8:
1118 fail7:
1119  hunt_tx_fini(hunt);
1120 fail6:
1121  hunt_rx_filter_fini(hunt);
1122 fail5:
1123  hunt_rx_fini(hunt);
1124 fail4:
1125  hunt_ev_fini(hunt);
1126 fail3:
1127  hunt_free_vis(hunt);
1128 fail2:
1129  DBGC2(hunt, "%s: %s\n", netdev->name, strerror(rc));
1130  return rc;
1131 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static int hunt_set_mac(struct hunt_nic *hunt)
Definition: sfc_hunt.c:537
static int hunt_alloc_vis(struct hunt_nic *hunt)
Definition: sfc_hunt.c:575
void netdev_link_down(struct net_device *netdev)
Mark network device as having link down.
Definition: netdevice.c:230
static int hunt_tx_init(struct net_device *netdev, struct hunt_nic *hunt)
Definition: sfc_hunt.c:678
static int hunt_rx_init(struct net_device *netdev, struct hunt_nic *hunt)
Definition: sfc_hunt.c:876
static void hunt_ev_fini(struct hunt_nic *hunt)
Definition: sfc_hunt.c:1018
static int hunt_rx_filter_init(struct net_device *netdev, struct hunt_nic *hunt)
Definition: sfc_hunt.c:856
void efx_hunt_close(struct net_device *netdev)
Definition: efx_hunt.c:487
void * priv
Driver private data.
Definition: netdevice.h:431
static struct net_device * netdev
Definition: gdbudp.c:52
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
static void hunt_rx_filter_fini(struct hunt_nic *hunt)
Definition: sfc_hunt.c:920
int efx_hunt_open(struct net_device *netdev)
Definition: efx_hunt.c:466
char name[NETDEV_NAME_LEN]
Name of this network device.
Definition: netdevice.h:362
static int hunt_check_link(struct hunt_nic *hunt)
Definition: sfc_hunt.c:615
#define DBGC2(...)
Definition: compiler.h:522
static int hunt_ev_init(struct net_device *netdev, struct hunt_nic *hunt)
Definition: sfc_hunt.c:959
static void hunt_tx_fini(struct hunt_nic *hunt)
Definition: sfc_hunt.c:725
static void hunt_free_vis(struct hunt_nic *hunt)
Definition: sfc_hunt.c:592
static void hunt_rx_fini(struct hunt_nic *hunt)
Definition: sfc_hunt.c:926

References DBGC2, efx_hunt_close(), efx_hunt_open(), hunt_alloc_vis(), hunt_check_link(), hunt_ev_fini(), hunt_ev_init(), hunt_free_vis(), hunt_rx_filter_fini(), hunt_rx_filter_init(), hunt_rx_fini(), hunt_rx_init(), hunt_set_mac(), hunt_tx_fini(), hunt_tx_init(), net_device::name, netdev, netdev_link_down(), net_device::priv, rc, and strerror().

◆ hunt_close()

static void hunt_close ( struct net_device netdev)
static

Definition at line 1134 of file sfc_hunt.c.

1135 {
1136  struct hunt_nic *hunt = netdev->priv;
1137 
1138  /* Stop datapath */
1140 
1141  hunt_tx_fini(hunt);
1142  hunt_rx_fini(hunt);
1143  hunt_rx_filter_fini(hunt);
1144  hunt_ev_fini(hunt);
1145 
1146  hunt_free_vis(hunt);
1147 
1148  /* Reset hardware and detach */
1149  hunt_reset(hunt);
1150 }
static void hunt_ev_fini(struct hunt_nic *hunt)
Definition: sfc_hunt.c:1018
void efx_hunt_close(struct net_device *netdev)
Definition: efx_hunt.c:487
void * priv
Driver private data.
Definition: netdevice.h:431
static struct net_device * netdev
Definition: gdbudp.c:52
static void hunt_rx_filter_fini(struct hunt_nic *hunt)
Definition: sfc_hunt.c:920
static int hunt_reset(struct hunt_nic *hunt)
Definition: sfc_hunt.c:491
static void hunt_tx_fini(struct hunt_nic *hunt)
Definition: sfc_hunt.c:725
static void hunt_free_vis(struct hunt_nic *hunt)
Definition: sfc_hunt.c:592
static void hunt_rx_fini(struct hunt_nic *hunt)
Definition: sfc_hunt.c:926

References efx_hunt_close(), hunt_ev_fini(), hunt_free_vis(), hunt_reset(), hunt_rx_filter_fini(), hunt_rx_fini(), hunt_tx_fini(), netdev, and net_device::priv.

◆ hunt_probe()

static int hunt_probe ( struct pci_device pci)
static

Definition at line 1170 of file sfc_hunt.c.

1171 {
1172  struct net_device *netdev;
1173  struct hunt_nic *hunt;
1174  struct efx_nic *efx;
1175  int rc = 0;
1176 
1177  /* Create the network adapter */
1178  netdev = alloc_etherdev(sizeof(struct hunt_nic));
1179  if (!netdev) {
1180  rc = -ENOMEM;
1181  goto fail1;
1182  }
1183 
1184  /* Initialise the network adapter, and initialise private storage */
1186  pci_set_drvdata(pci, netdev);
1187  netdev->dev = &pci->dev;
1189 
1190  hunt = netdev->priv;
1191  memset(hunt, 0, sizeof(*hunt));
1192  efx = &hunt->efx;
1193 
1194  efx->type = &hunt_nic_type;
1195 
1196  /* Initialise efx datapath */
1198 
1199  /* Initialise MCDI. In case we are recovering from a crash, first
1200  * cancel any outstanding request by sending a special message using the
1201  * least significant bits of the 'high' (doorbell) register.
1202  */
1204  rc = hunt_mcdi_init(hunt);
1205  if (rc != 0)
1206  goto fail2;
1207 
1208  /* Reset (most) configuration for this function */
1209  rc = hunt_reset(hunt);
1210  if (rc != 0)
1211  goto fail3;
1212 
1213  /* Medford has a list of UDP tunnel ports that is populated by the
1214  * driver. Avoid dropping any unencapsulated packets. This may cause
1215  * an MC reboot.
1216  */
1218 
1219  /* Enable the workaround for bug35388, if supported */
1221 
1222  /* Set the RX packet prefix size */
1224 
1225  rc = hunt_get_port_assignment(hunt);
1226  if (rc != 0)
1227  goto fail3;
1228 
1229  rc = hunt_mac_addr(hunt, netdev->ll_addr);
1230  if (rc != 0)
1231  goto fail4;
1232 
1233  rc = hunt_get_phy_cfg(hunt);
1234  if (rc != 0)
1235  goto fail5;
1236 
1237  rc = hunt_driver_attach(hunt, 1);
1238  if (rc != 0)
1239  goto fail5;
1240 
1241  /* If not exposing this network device, return successfully here */
1243  return 0;
1244 
1245  if (hunt_nic_is_primary(hunt)) {
1246  hunt->next_primary = primary_nics;
1247  primary_nics = hunt;
1248  hunt->primary = hunt;
1249  } else {
1250  struct hunt_nic *other_hunt = primary_nics;
1251 
1252  while (other_hunt && !hunt->primary) {
1253  struct pci_device *other_pci = (struct pci_device *)
1254  other_hunt->efx.netdev->dev;
1255  /* Check if the seg:bus:dev parts match. */
1256  if (PCI_FIRST_FUNC(other_pci->busdevfn) ==
1257  PCI_FIRST_FUNC(pci->busdevfn))
1258  hunt->primary = other_hunt;
1259 
1260  other_hunt = other_hunt->next_primary;
1261  }
1262  if (!hunt->primary) {
1263  rc = -EIO;
1264  goto fail6;
1265  }
1266  }
1267 
1269  if (rc != 0)
1270  goto fail8;
1271 
1272  DBG2("%s " PCI_FMT " ok\n", __func__, PCI_ARGS(pci));
1273  return 0;
1274 
1275 fail8:
1276 fail6:
1277  (void) hunt_driver_attach(hunt, 0);
1278 fail5:
1279 fail4:
1280 fail3:
1281  hunt_mcdi_fini(hunt);
1282 fail2:
1283  efx_remove(netdev);
1284  netdev_put(netdev);
1285 fail1:
1286  DBG2("%s " PCI_FMT " rc=%d\n", __func__, PCI_ARGS(pci), rc);
1287  return rc;
1288 }
static int hunt_workaround_35388(struct hunt_nic *hunt)
Definition: sfc_hunt.c:364
static int hunt_get_port_assignment(struct hunt_nic *hunt)
Definition: sfc_hunt.c:383
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static struct net_device_operations hunt_operations
Definition: sfc_hunt.c:1161
static int hunt_mcdi_init(struct hunt_nic *hunt)
Definition: sfc_hunt.c:97
Hardware access.
Definition: efx_common.h:147
static void hunt_clear_udp_tunnel_ports(struct hunt_nic *hunt)
Definition: sfc_hunt.c:507
bool workaround_35388
Definition: efx_common.h:175
unsigned int state
Current device state.
Definition: netdevice.h:395
static void _efx_writel(struct efx_nic *efx, uint32_t value, unsigned int reg)
Definition: efx_common.h:205
void efx_probe(struct net_device *netdev, enum efx_revision revision)
Definition: efx_common.c:71
struct device dev
Generic device.
Definition: pci.h:208
#define MC_CMD_DRV_ATTACH_EXT_OUT_FLAG_NO_ACTIVE_PORT
static void netdev_init(struct net_device *netdev, struct net_device_operations *op)
Initialise a network device.
Definition: netdevice.h:515
static void pci_set_drvdata(struct pci_device *pci, void *priv)
Set PCI driver-private data.
Definition: pci.h:359
#define ENOMEM
Not enough space.
Definition: errno.h:534
#define ER_DZ_MC_DB_HWRD
Definition: ef10_regs.h:75
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
Definition: netdevice.h:572
struct hunt_nic * next_primary
Definition: sfc_hunt.c:78
#define PCI_FIRST_FUNC(busdevfn)
Definition: pci.h:282
void * priv
Driver private data.
Definition: netdevice.h:431
struct efx_nic efx
Definition: sfc_hunt.c:54
static struct net_device * netdev
Definition: gdbudp.c:52
struct hunt_nic * primary_nics
Definition: sfc_hunt.c:51
#define cpu_to_le32(value)
Definition: byteswap.h:107
#define PCI_FMT
PCI device debug message format.
Definition: pci.h:307
A PCI device.
Definition: pci.h:206
int register_netdev(struct net_device *netdev)
Register network device.
Definition: netdevice.c:759
A network device.
Definition: netdevice.h:352
const struct efx_nic_type * type
Definition: efx_common.h:150
const struct efx_nic_type hunt_nic_type
Definition: sfc_hunt.c:1313
u32 flags
Definition: sfc_hunt.c:79
static void hunt_mcdi_fini(struct hunt_nic *hunt)
Definition: sfc_hunt.c:255
unsigned int rx_prefix_size
Definition: efx_common.h:168
struct device * dev
Underlying hardware device.
Definition: netdevice.h:364
static int hunt_get_phy_cfg(struct hunt_nic *hunt)
Definition: sfc_hunt.c:430
uint32_t busdevfn
Segment, bus, device, and function (bus:dev.fn) number.
Definition: pci.h:233
void efx_remove(struct net_device *netdev)
Definition: efx_common.c:98
static int hunt_reset(struct hunt_nic *hunt)
Definition: sfc_hunt.c:491
#define ES_DZ_RX_PREFIX_SIZE
Definition: ef10_regs.h:362
static int hunt_driver_attach(struct hunt_nic *hunt, int attach)
Definition: sfc_hunt.c:455
#define EIO
Input/output error.
Definition: errno.h:433
struct net_device * alloc_etherdev(size_t priv_size)
Allocate Ethernet device.
Definition: ethernet.c:264
#define PCI_ARGS(pci)
PCI device debug message arguments.
Definition: pci.h:310
struct hunt_nic * primary
Definition: sfc_hunt.c:77
static int hunt_nic_is_primary(struct hunt_nic *hunt)
Definition: sfc_hunt.c:82
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
Definition: netdevice.h:387
static int hunt_mac_addr(struct hunt_nic *hunt, uint8_t *ll_addr)
Definition: sfc_hunt.c:404
#define NETDEV_IRQ_UNSUPPORTED
Network device interrupts are unsupported.
Definition: netdevice.h:452
struct net_device * netdev
Definition: efx_common.h:148
#define DBG2(...)
Definition: compiler.h:515
if(natsemi->flags &NATSEMI_64BIT) return 1
void * memset(void *dest, int character, size_t len) __nonnull

References _efx_writel(), alloc_etherdev(), pci_device::busdevfn, cpu_to_le32, DBG2, pci_device::dev, net_device::dev, hunt_nic::efx, EFX_HUNTINGTON, efx_probe(), efx_remove(), EIO, ENOMEM, ER_DZ_MC_DB_HWRD, ES_DZ_RX_PREFIX_SIZE, hunt_nic::flags, hunt_clear_udp_tunnel_ports(), hunt_driver_attach(), hunt_get_phy_cfg(), hunt_get_port_assignment(), hunt_mac_addr(), hunt_mcdi_fini(), hunt_mcdi_init(), hunt_nic_is_primary(), hunt_nic_type, hunt_operations, hunt_reset(), hunt_workaround_35388(), if(), net_device::ll_addr, MC_CMD_DRV_ATTACH_EXT_OUT_FLAG_NO_ACTIVE_PORT, memset(), netdev, efx_nic::netdev, netdev_init(), NETDEV_IRQ_UNSUPPORTED, netdev_put(), hunt_nic::next_primary, PCI_ARGS, PCI_FIRST_FUNC, PCI_FMT, pci_set_drvdata(), hunt_nic::primary, primary_nics, net_device::priv, rc, register_netdev(), efx_nic::rx_prefix_size, net_device::state, efx_nic::type, and efx_nic::workaround_35388.

◆ hunt_remove()

static void hunt_remove ( struct pci_device pci)
static

Definition at line 1290 of file sfc_hunt.c.

1291 {
1292  struct net_device *netdev = pci_get_drvdata(pci);
1293  struct hunt_nic *hunt = netdev->priv;
1294 
1295  if (!(hunt->flags &
1297  /* The netdevice might still be open, so unregister it now
1298  * before ripping stuff out from underneath.
1299  */
1301  }
1302 
1303  (void)hunt_driver_attach(hunt, 0);
1304  hunt_mcdi_fini(hunt);
1305 
1306  /* Destroy data path */
1307  efx_remove(netdev);
1308 
1310  netdev_put(netdev);
1311 }
#define MC_CMD_DRV_ATTACH_EXT_OUT_FLAG_NO_ACTIVE_PORT
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
Definition: netdevice.h:572
void * priv
Driver private data.
Definition: netdevice.h:431
static struct net_device * netdev
Definition: gdbudp.c:52
void unregister_netdev(struct net_device *netdev)
Unregister network device.
Definition: netdevice.c:941
A network device.
Definition: netdevice.h:352
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
Definition: netdevice.h:528
u32 flags
Definition: sfc_hunt.c:79
static void hunt_mcdi_fini(struct hunt_nic *hunt)
Definition: sfc_hunt.c:255
static void * pci_get_drvdata(struct pci_device *pci)
Get PCI driver-private data.
Definition: pci.h:369
void efx_remove(struct net_device *netdev)
Definition: efx_common.c:98
static int hunt_driver_attach(struct hunt_nic *hunt, int attach)
Definition: sfc_hunt.c:455

References efx_remove(), hunt_nic::flags, hunt_driver_attach(), hunt_mcdi_fini(), MC_CMD_DRV_ATTACH_EXT_OUT_FLAG_NO_ACTIVE_PORT, netdev, netdev_nullify(), netdev_put(), pci_get_drvdata(), net_device::priv, and unregister_netdev().

Variable Documentation

◆ primary_nics

struct hunt_nic* primary_nics = NULL

Definition at line 51 of file sfc_hunt.c.

Referenced by hunt_probe().

◆ hunt_operations

struct net_device_operations hunt_operations
static
Initial value:
= {
.open = hunt_open,
.close = hunt_close,
.transmit = efx_hunt_transmit,
.poll = hunt_poll,
.irq = efx_hunt_irq,
}
void efx_hunt_irq(struct net_device *netdev, int enable)
Definition: efx_hunt.c:444
static int hunt_open(struct net_device *netdev)
Definition: sfc_hunt.c:1072
static void hunt_close(struct net_device *netdev)
Definition: sfc_hunt.c:1134
static void hunt_poll(struct net_device *netdev)
Definition: sfc_hunt.c:1044
int efx_hunt_transmit(struct net_device *netdev, struct io_buffer *iob)
Definition: efx_hunt.c:101

Definition at line 1161 of file sfc_hunt.c.

Referenced by hunt_probe().

◆ hunt_nic_type

const struct efx_nic_type hunt_nic_type
Initial value:
= {
.mcdi_rpc = _hunt_mcdi,
}
int _hunt_mcdi(struct efx_nic *efx, unsigned int cmd, const efx_dword_t *inbuf, size_t inlen, efx_dword_t *outbuf, size_t outlen, size_t *outlen_actual, bool quiet)
Definition: sfc_hunt.c:260

Definition at line 1313 of file sfc_hunt.c.

Referenced by hunt_probe().

◆ hunt_nics

struct pci_device_id hunt_nics[]
static
Initial value:
= {
PCI_ROM(0x1924, 0x0903, "SFC9120", "Solarflare SFC9120 Adapter", 0),
PCI_ROM(0x1924, 0x0923, "SFC9140", "Solarflare SFC9140 Adapter", 0),
PCI_ROM(0x1924, 0x0a03, "SFC9220", "Solarflare SFN8xxx Adapter", 0),
PCI_ROM(0x1924, 0x0b03, "SFC9250", "Solarflare X25xx Adapter", 0),
}
#define PCI_ROM(_vendor, _device, _name, _description, _data)
Definition: pci.h:303

Definition at line 1317 of file sfc_hunt.c.

◆ __pci_driver

struct pci_driver hunt_driver __pci_driver
Initial value:
= {
.ids = hunt_nics,
.id_count = ARRAY_SIZE(hunt_nics),
.probe = hunt_probe,
.remove = hunt_remove,
}
static int hunt_probe(struct pci_device *pci)
Definition: sfc_hunt.c:1170
#define ARRAY_SIZE(x)
Definition: efx_common.h:43
static void hunt_remove(struct pci_device *pci)
Definition: sfc_hunt.c:1290
static struct pci_device_id hunt_nics[]
Definition: sfc_hunt.c:1317

Definition at line 1324 of file sfc_hunt.c.