iPXE
intelxl.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 Michael Brown <mbrown@fensystems.co.uk>.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of the
7  * License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  * 02110-1301, USA.
18  *
19  * You can also choose to distribute this program under the terms of
20  * the Unmodified Binary Distribution Licence (as given in the file
21  * COPYING.UBDL), provided that you have satisfied its requirements.
22  */
23 
24 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
25 
26 #include <stdint.h>
27 #include <string.h>
28 #include <stdio.h>
29 #include <unistd.h>
30 #include <errno.h>
31 #include <byteswap.h>
32 #include <ipxe/netdevice.h>
33 #include <ipxe/ethernet.h>
34 #include <ipxe/if_ether.h>
35 #include <ipxe/vlan.h>
36 #include <ipxe/iobuf.h>
37 #include <ipxe/pci.h>
38 #include <ipxe/version.h>
39 #include "intelxl.h"
40 
41 /** @file
42  *
43  * Intel 40 Gigabit Ethernet network card driver
44  *
45  */
46 
47 /******************************************************************************
48  *
49  * MSI-X interrupts
50  *
51  ******************************************************************************
52  */
53 
54 /**
55  * Enable MSI-X dummy interrupt
56  *
57  * @v intelxl Intel device
58  * @v pci PCI device
59  * @v vector MSI-X vector
60  * @ret rc Return status code
61  */
62 int intelxl_msix_enable ( struct intelxl_nic *intelxl,
63  struct pci_device *pci, unsigned int vector ) {
64  int rc;
65 
66  /* Enable MSI-X capability */
67  if ( ( rc = pci_msix_enable ( pci, &intelxl->msix ) ) != 0 ) {
68  DBGC ( intelxl, "INTELXL %p could not enable MSI-X: %s\n",
69  intelxl, strerror ( rc ) );
70  goto err_enable;
71  }
72 
73  /* Enable dummy interrupt */
74  pci_msix_unmask ( &intelxl->msix, vector );
75 
76  return 0;
77 
78  pci_msix_disable ( pci, &intelxl->msix );
79  err_enable:
80  return rc;
81 }
82 
83 /**
84  * Disable MSI-X dummy interrupt
85  *
86  * @v intelxl Intel device
87  * @v pci PCI device
88  * @v vector MSI-X vector
89  */
90 void intelxl_msix_disable ( struct intelxl_nic *intelxl,
91  struct pci_device *pci, unsigned int vector ) {
92 
93  /* Disable dummy interrupts */
94  pci_msix_mask ( &intelxl->msix, vector );
95 
96  /* Disable MSI-X capability */
97  pci_msix_disable ( pci, &intelxl->msix );
98 }
99 
100 /******************************************************************************
101  *
102  * Admin queue
103  *
104  ******************************************************************************
105  */
106 
107 /** Admin queue register offsets */
110  .bah = INTELXL_ADMIN_BAH,
111  .len = INTELXL_ADMIN_LEN,
112  .head = INTELXL_ADMIN_HEAD,
113  .tail = INTELXL_ADMIN_TAIL,
114 };
115 
116 /**
117  * Allocate admin queue
118  *
119  * @v intelxl Intel device
120  * @v admin Admin queue
121  * @ret rc Return status code
122  */
123 static int intelxl_alloc_admin ( struct intelxl_nic *intelxl,
124  struct intelxl_admin *admin ) {
125  size_t buf_len = ( sizeof ( admin->buf[0] ) * INTELXL_ADMIN_NUM_DESC );
126  size_t len = ( sizeof ( admin->desc[0] ) * INTELXL_ADMIN_NUM_DESC );
127 
128  /* Allocate admin queue */
129  admin->buf = dma_alloc ( intelxl->dma, &admin->map, ( buf_len + len ),
130  INTELXL_ALIGN );
131  if ( ! admin->buf )
132  return -ENOMEM;
133  admin->desc = ( ( ( void * ) admin->buf ) + buf_len );
134 
135  DBGC ( intelxl, "INTELXL %p A%cQ is at [%08lx,%08lx) buf "
136  "[%08lx,%08lx)\n", intelxl,
137  ( ( admin == &intelxl->command ) ? 'T' : 'R' ),
138  virt_to_phys ( admin->desc ),
139  ( virt_to_phys ( admin->desc ) + len ),
140  virt_to_phys ( admin->buf ),
141  ( virt_to_phys ( admin->buf ) + buf_len ) );
142  return 0;
143 }
144 
145 /**
146  * Enable admin queue
147  *
148  * @v intelxl Intel device
149  * @v admin Admin queue
150  */
151 static void intelxl_enable_admin ( struct intelxl_nic *intelxl,
152  struct intelxl_admin *admin ) {
153  size_t len = ( sizeof ( admin->desc[0] ) * INTELXL_ADMIN_NUM_DESC );
154  const struct intelxl_admin_offsets *regs = admin->regs;
155  void *admin_regs = ( intelxl->regs + admin->base );
157 
158  /* Initialise admin queue */
159  memset ( admin->desc, 0, len );
160 
161  /* Reset head and tail registers */
162  writel ( 0, admin_regs + regs->head );
163  writel ( 0, admin_regs + regs->tail );
164 
165  /* Reset queue index */
166  admin->index = 0;
167 
168  /* Program queue address */
169  address = dma ( &admin->map, admin->desc );
170  writel ( ( address & 0xffffffffUL ), admin_regs + regs->bal );
171  if ( sizeof ( physaddr_t ) > sizeof ( uint32_t ) ) {
172  writel ( ( ( ( uint64_t ) address ) >> 32 ),
173  admin_regs + regs->bah );
174  } else {
175  writel ( 0, admin_regs + regs->bah );
176  }
177 
178  /* Program queue length and enable queue */
181  admin_regs + regs->len );
182 }
183 
184 /**
185  * Disable admin queue
186  *
187  * @v intelxl Intel device
188  * @v admin Admin queue
189  */
190 static void intelxl_disable_admin ( struct intelxl_nic *intelxl,
191  struct intelxl_admin *admin ) {
192  const struct intelxl_admin_offsets *regs = admin->regs;
193  void *admin_regs = ( intelxl->regs + admin->base );
194 
195  /* Disable queue */
196  writel ( 0, admin_regs + regs->len );
197 }
198 
199 /**
200  * Free admin queue
201  *
202  * @v intelxl Intel device
203  * @v admin Admin queue
204  */
205 static void intelxl_free_admin ( struct intelxl_nic *intelxl __unused,
206  struct intelxl_admin *admin ) {
207  size_t buf_len = ( sizeof ( admin->buf[0] ) * INTELXL_ADMIN_NUM_DESC );
208  size_t len = ( sizeof ( admin->desc[0] ) * INTELXL_ADMIN_NUM_DESC );
209 
210  /* Free queue */
211  dma_free ( &admin->map, admin->buf, ( buf_len + len ) );
212 }
213 
214 /**
215  * Get next admin command queue descriptor
216  *
217  * @v intelxl Intel device
218  * @ret cmd Command descriptor
219  */
222  struct intelxl_admin *admin = &intelxl->command;
224 
225  /* Get and initialise next descriptor */
226  cmd = &admin->desc[ admin->index % INTELXL_ADMIN_NUM_DESC ];
227  memset ( cmd, 0, sizeof ( *cmd ) );
228  return cmd;
229 }
230 
231 /**
232  * Get next admin command queue data buffer
233  *
234  * @v intelxl Intel device
235  * @ret buf Data buffer
236  */
237 union intelxl_admin_buffer *
239  struct intelxl_admin *admin = &intelxl->command;
240  union intelxl_admin_buffer *buf;
241 
242  /* Get next data buffer */
243  buf = &admin->buf[ admin->index % INTELXL_ADMIN_NUM_DESC ];
244  memset ( buf, 0, sizeof ( *buf ) );
245  return buf;
246 }
247 
248 /**
249  * Initialise admin event queue descriptor
250  *
251  * @v intelxl Intel device
252  * @v index Event queue index
253  */
254 static void intelxl_admin_event_init ( struct intelxl_nic *intelxl,
255  unsigned int index ) {
256  struct intelxl_admin *admin = &intelxl->event;
257  struct intelxl_admin_descriptor *evt;
258  union intelxl_admin_buffer *buf;
260 
261  /* Initialise descriptor */
262  evt = &admin->desc[ index % INTELXL_ADMIN_NUM_DESC ];
263  buf = &admin->buf[ index % INTELXL_ADMIN_NUM_DESC ];
264  address = dma ( &admin->map, buf );
266  evt->len = cpu_to_le16 ( sizeof ( *buf ) );
267  evt->params.buffer.high = cpu_to_le32 ( address >> 32 );
268  evt->params.buffer.low = cpu_to_le32 ( address & 0xffffffffUL );
269 }
270 
271 /**
272  * Issue admin queue command
273  *
274  * @v intelxl Intel device
275  * @ret rc Return status code
276  */
277 int intelxl_admin_command ( struct intelxl_nic *intelxl ) {
278  struct intelxl_admin *admin = &intelxl->command;
279  const struct intelxl_admin_offsets *regs = admin->regs;
280  void *admin_regs = ( intelxl->regs + admin->base );
282  union intelxl_admin_buffer *buf;
284  uint32_t cookie;
285  uint16_t silence;
286  unsigned int index;
287  unsigned int tail;
288  unsigned int i;
289  int rc;
290 
291  /* Get next queue entry */
292  index = admin->index++;
293  tail = ( admin->index % INTELXL_ADMIN_NUM_DESC );
294  cmd = &admin->desc[ index % INTELXL_ADMIN_NUM_DESC ];
295  buf = &admin->buf[ index % INTELXL_ADMIN_NUM_DESC ];
296  DBGC2 ( intelxl, "INTELXL %p admin command %#x opcode %#04x",
297  intelxl, index, le16_to_cpu ( cmd->opcode ) );
298  if ( cmd->cookie )
299  DBGC2 ( intelxl, "/%#08x", le32_to_cpu ( cmd->cookie ) );
300  DBGC2 ( intelxl, ":\n" );
301 
302  /* Allow expected errors to be silenced */
303  silence = cmd->ret;
304  cmd->ret = 0;
305 
306  /* Sanity checks */
307  assert ( ! ( cmd->flags & cpu_to_le16 ( INTELXL_ADMIN_FL_DD ) ) );
308  assert ( ! ( cmd->flags & cpu_to_le16 ( INTELXL_ADMIN_FL_CMP ) ) );
309  assert ( ! ( cmd->flags & cpu_to_le16 ( INTELXL_ADMIN_FL_ERR ) ) );
310 
311  /* Populate data buffer address if applicable */
312  if ( cmd->flags & cpu_to_le16 ( INTELXL_ADMIN_FL_BUF ) ) {
313  address = dma ( &admin->map, buf );
314  cmd->params.buffer.high = cpu_to_le32 ( address >> 32 );
315  cmd->params.buffer.low = cpu_to_le32 ( address & 0xffffffffUL );
316  }
317 
318  /* Populate cookie, if not being (ab)used for VF opcode */
319  if ( ! cmd->cookie )
320  cmd->cookie = cpu_to_le32 ( index );
321 
322  /* Record cookie */
323  cookie = cmd->cookie;
324 
325  /* Post command descriptor */
326  DBGC2_HDA ( intelxl, virt_to_phys ( cmd ), cmd, sizeof ( *cmd ) );
327  if ( cmd->flags & cpu_to_le16 ( INTELXL_ADMIN_FL_RD ) ) {
328  DBGC2_HDA ( intelxl, virt_to_phys ( buf ), buf,
329  le16_to_cpu ( cmd->len ) );
330  }
331  wmb();
332  writel ( tail, admin_regs + regs->tail );
333 
334  /* Wait for completion */
335  for ( i = 0 ; i < INTELXL_ADMIN_MAX_WAIT_MS ; i++ ) {
336 
337  /* If response is not complete, delay 1ms and retry */
338  if ( ! ( cmd->flags & INTELXL_ADMIN_FL_DD ) ) {
339  mdelay ( 1 );
340  continue;
341  }
342  DBGC2 ( intelxl, "INTELXL %p admin command %#x response:\n",
343  intelxl, index );
344  DBGC2_HDA ( intelxl, virt_to_phys ( cmd ), cmd,
345  sizeof ( *cmd ) );
346  if ( cmd->flags & cpu_to_le16 ( INTELXL_ADMIN_FL_BUF ) ) {
347  DBGC2_HDA ( intelxl, virt_to_phys ( buf ), buf,
348  le16_to_cpu ( cmd->len ) );
349  }
350 
351  /* Check for cookie mismatch */
352  if ( cmd->cookie != cookie ) {
353  DBGC ( intelxl, "INTELXL %p admin command %#x bad "
354  "cookie %#x\n", intelxl, index,
355  le32_to_cpu ( cmd->cookie ) );
356  rc = -EPROTO;
357  goto err;
358  }
359 
360  /* Check for unexpected errors */
361  if ( ( cmd->ret != 0 ) && ( cmd->ret != silence ) ) {
362  DBGC ( intelxl, "INTELXL %p admin command %#x error "
363  "%d\n", intelxl, index,
364  le16_to_cpu ( cmd->ret ) );
365  rc = -EIO;
366  goto err;
367  }
368 
369  /* Success */
370  return 0;
371  }
372 
373  rc = -ETIMEDOUT;
374  DBGC ( intelxl, "INTELXL %p timed out waiting for admin command %#x:\n",
375  intelxl, index );
376  err:
377  DBGC_HDA ( intelxl, virt_to_phys ( cmd ), cmd, sizeof ( *cmd ) );
378  return rc;
379 }
380 
381 /**
382  * Get firmware version
383  *
384  * @v intelxl Intel device
385  * @ret rc Return status code
386  */
387 static int intelxl_admin_version ( struct intelxl_nic *intelxl ) {
390  unsigned int api;
391  int rc;
392 
393  /* Populate descriptor */
395  cmd->opcode = cpu_to_le16 ( INTELXL_ADMIN_VERSION );
396  version = &cmd->params.version;
397 
398  /* Issue command */
399  if ( ( rc = intelxl_admin_command ( intelxl ) ) != 0 )
400  return rc;
401  api = le16_to_cpu ( version->api.major );
402  DBGC ( intelxl, "INTELXL %p firmware v%d.%d API v%d.%d\n",
403  intelxl, le16_to_cpu ( version->firmware.major ),
404  le16_to_cpu ( version->firmware.minor ),
405  api, le16_to_cpu ( version->api.minor ) );
406 
407  /* Check for API compatibility */
408  if ( api > INTELXL_ADMIN_API_MAJOR ) {
409  DBGC ( intelxl, "INTELXL %p unsupported API v%d\n",
410  intelxl, api );
411  return -ENOTSUP;
412  }
413 
414  return 0;
415 }
416 
417 /**
418  * Report driver version
419  *
420  * @v intelxl Intel device
421  * @ret rc Return status code
422  */
423 static int intelxl_admin_driver ( struct intelxl_nic *intelxl ) {
425  struct intelxl_admin_driver_params *driver;
426  union intelxl_admin_buffer *buf;
427  int rc;
428 
429  /* Populate descriptor */
431  cmd->opcode = cpu_to_le16 ( INTELXL_ADMIN_DRIVER );
433  cmd->len = cpu_to_le16 ( sizeof ( buf->driver ) );
434  driver = &cmd->params.driver;
435  driver->major = product_major_version;
436  driver->minor = product_minor_version;
437  buf = intelxl_admin_command_buffer ( intelxl );
438  snprintf ( buf->driver.name, sizeof ( buf->driver.name ), "%s",
440 
441  /* Issue command */
442  if ( ( rc = intelxl_admin_command ( intelxl ) ) != 0 )
443  return rc;
444 
445  return 0;
446 }
447 
448 /**
449  * Shutdown admin queues
450  *
451  * @v intelxl Intel device
452  * @ret rc Return status code
453  */
454 static int intelxl_admin_shutdown ( struct intelxl_nic *intelxl ) {
457  int rc;
458 
459  /* Populate descriptor */
461  cmd->opcode = cpu_to_le16 ( INTELXL_ADMIN_SHUTDOWN );
462  shutdown = &cmd->params.shutdown;
464 
465  /* Issue command */
466  if ( ( rc = intelxl_admin_command ( intelxl ) ) != 0 )
467  return rc;
468 
469  return 0;
470 }
471 
472 /**
473  * Get MAC address
474  *
475  * @v netdev Network device
476  * @ret rc Return status code
477  */
478 static int intelxl_admin_mac_read ( struct net_device *netdev ) {
479  struct intelxl_nic *intelxl = netdev->priv;
482  union intelxl_admin_buffer *buf;
483  uint8_t *mac;
484  int rc;
485 
486  /* Populate descriptor */
488  cmd->opcode = cpu_to_le16 ( INTELXL_ADMIN_MAC_READ );
489  cmd->flags = cpu_to_le16 ( INTELXL_ADMIN_FL_BUF );
490  cmd->len = cpu_to_le16 ( sizeof ( buf->mac_read ) );
491  read = &cmd->params.mac_read;
492  buf = intelxl_admin_command_buffer ( intelxl );
493  mac = buf->mac_read.pf;
494 
495  /* Issue command */
496  if ( ( rc = intelxl_admin_command ( intelxl ) ) != 0 )
497  return rc;
498 
499  /* Check that MAC address is present in response */
500  if ( ! ( read->valid & INTELXL_ADMIN_MAC_READ_VALID_LAN ) ) {
501  DBGC ( intelxl, "INTELXL %p has no MAC address\n", intelxl );
502  return -ENOENT;
503  }
504 
505  /* Check that address is valid */
506  if ( ! is_valid_ether_addr ( mac ) ) {
507  DBGC ( intelxl, "INTELXL %p has invalid MAC address (%s)\n",
508  intelxl, eth_ntoa ( mac ) );
509  return -ENOENT;
510  }
511 
512  /* Copy MAC address */
513  DBGC ( intelxl, "INTELXL %p has MAC address %s\n",
514  intelxl, eth_ntoa ( mac ) );
516 
517  return 0;
518 }
519 
520 /**
521  * Set MAC address
522  *
523  * @v netdev Network device
524  * @ret rc Return status code
525  */
526 static int intelxl_admin_mac_write ( struct net_device *netdev ) {
527  struct intelxl_nic *intelxl = netdev->priv;
530  union {
532  struct {
533  uint16_t high;
534  uint32_t low;
535  } __attribute__ (( packed ));
536  } mac;
537  int rc;
538 
539  /* Populate descriptor */
542  write = &cmd->params.mac_write;
543  memcpy ( mac.raw, netdev->ll_addr, ETH_ALEN );
544  write->high = bswap_16 ( mac.high );
545  write->low = bswap_32 ( mac.low );
546 
547  /* Issue command */
548  if ( ( rc = intelxl_admin_command ( intelxl ) ) != 0 )
549  return rc;
550 
551  return 0;
552 }
553 
554 /**
555  * Clear PXE mode
556  *
557  * @v intelxl Intel device
558  * @ret rc Return status code
559  */
560 int intelxl_admin_clear_pxe ( struct intelxl_nic *intelxl ) {
562  struct intelxl_admin_clear_pxe_params *pxe;
563  int rc;
564 
565  /* Populate descriptor */
569  pxe = &cmd->params.pxe;
571 
572  /* Issue command */
573  if ( ( rc = intelxl_admin_command ( intelxl ) ) != 0 )
574  return rc;
575 
576  /* Check for expected errors */
577  if ( cmd->ret == cpu_to_le16 ( INTELXL_ADMIN_EEXIST ) ) {
578  DBGC ( intelxl, "INTELXL %p already in non-PXE mode\n",
579  intelxl );
580  return 0;
581  }
582 
583  return 0;
584 }
585 
586 /**
587  * Get switch configuration
588  *
589  * @v intelxl Intel device
590  * @ret rc Return status code
591  */
592 static int intelxl_admin_switch ( struct intelxl_nic *intelxl ) {
594  struct intelxl_admin_switch_params *sw;
595  union intelxl_admin_buffer *buf;
596  uint16_t next = 0;
597  int rc;
598 
599  /* Get each configuration in turn */
600  do {
601  /* Populate descriptor */
603  cmd->opcode = cpu_to_le16 ( INTELXL_ADMIN_SWITCH );
604  cmd->flags = cpu_to_le16 ( INTELXL_ADMIN_FL_BUF );
605  cmd->len = cpu_to_le16 ( sizeof ( buf->sw ) );
606  sw = &cmd->params.sw;
607  sw->next = next;
608  buf = intelxl_admin_command_buffer ( intelxl );
609 
610  /* Issue command */
611  if ( ( rc = intelxl_admin_command ( intelxl ) ) != 0 )
612  return rc;
613 
614  /* Dump raw configuration */
615  DBGC2 ( intelxl, "INTELXL %p SEID %#04x:\n",
616  intelxl, le16_to_cpu ( buf->sw.cfg.seid ) );
617  DBGC2_HDA ( intelxl, 0, &buf->sw.cfg, sizeof ( buf->sw.cfg ) );
618 
619  /* Parse response */
620  if ( buf->sw.cfg.type == INTELXL_ADMIN_SWITCH_TYPE_VSI ) {
621  intelxl->vsi = le16_to_cpu ( buf->sw.cfg.seid );
622  DBGC ( intelxl, "INTELXL %p VSI %#04x uplink %#04x "
623  "downlink %#04x conn %#02x\n", intelxl,
624  intelxl->vsi, le16_to_cpu ( buf->sw.cfg.uplink ),
625  le16_to_cpu ( buf->sw.cfg.downlink ),
626  buf->sw.cfg.connection );
627  }
628 
629  } while ( ( next = sw->next ) );
630 
631  /* Check that we found a VSI */
632  if ( ! intelxl->vsi ) {
633  DBGC ( intelxl, "INTELXL %p has no VSI\n", intelxl );
634  return -ENOENT;
635  }
636 
637  return 0;
638 }
639 
640 /**
641  * Get VSI parameters
642  *
643  * @v intelxl Intel device
644  * @ret rc Return status code
645  */
646 static int intelxl_admin_vsi ( struct intelxl_nic *intelxl ) {
649  union intelxl_admin_buffer *buf;
650  int rc;
651 
652  /* Populate descriptor */
654  cmd->opcode = cpu_to_le16 ( INTELXL_ADMIN_VSI );
655  cmd->flags = cpu_to_le16 ( INTELXL_ADMIN_FL_BUF );
656  cmd->len = cpu_to_le16 ( sizeof ( buf->vsi ) );
657  vsi = &cmd->params.vsi;
658  vsi->vsi = cpu_to_le16 ( intelxl->vsi );
659  buf = intelxl_admin_command_buffer ( intelxl );
660 
661  /* Issue command */
662  if ( ( rc = intelxl_admin_command ( intelxl ) ) != 0 )
663  return rc;
664 
665  /* Parse response */
666  intelxl->queue = le16_to_cpu ( buf->vsi.queue[0] );
667  intelxl->qset = le16_to_cpu ( buf->vsi.qset[0] );
668  DBGC ( intelxl, "INTELXL %p VSI %#04x queue %#04x qset %#04x\n",
669  intelxl, intelxl->vsi, intelxl->queue, intelxl->qset );
670 
671  return 0;
672 }
673 
674 /**
675  * Set VSI promiscuous modes
676  *
677  * @v intelxl Intel device
678  * @ret rc Return status code
679  */
680 static int intelxl_admin_promisc ( struct intelxl_nic *intelxl ) {
682  struct intelxl_admin_promisc_params *promisc;
683  uint16_t flags;
684  int rc;
685 
686  /* Populate descriptor */
688  cmd->opcode = cpu_to_le16 ( INTELXL_ADMIN_PROMISC );
693  promisc = &cmd->params.promisc;
694  promisc->flags = cpu_to_le16 ( flags );
695  promisc->valid = cpu_to_le16 ( flags );
696  promisc->vsi = cpu_to_le16 ( intelxl->vsi );
697 
698  /* Issue command */
699  if ( ( rc = intelxl_admin_command ( intelxl ) ) != 0 )
700  return rc;
701 
702  return 0;
703 }
704 
705 /**
706  * Set MAC configuration
707  *
708  * @v intelxl Intel device
709  * @ret rc Return status code
710  */
711 int intelxl_admin_mac_config ( struct intelxl_nic *intelxl ) {
713  struct intelxl_admin_mac_config_params *config;
714  int rc;
715 
716  /* Populate descriptor */
719  config = &cmd->params.mac_config;
720  config->mfs = cpu_to_le16 ( intelxl->mfs );
722 
723  /* Issue command */
724  if ( ( rc = intelxl_admin_command ( intelxl ) ) != 0 )
725  return rc;
726 
727  return 0;
728 }
729 
730 /**
731  * Restart autonegotiation
732  *
733  * @v intelxl Intel device
734  * @ret rc Return status code
735  */
736 static int intelxl_admin_autoneg ( struct intelxl_nic *intelxl ) {
738  struct intelxl_admin_autoneg_params *autoneg;
739  int rc;
740 
741  /* Populate descriptor */
743  cmd->opcode = cpu_to_le16 ( INTELXL_ADMIN_AUTONEG );
744  autoneg = &cmd->params.autoneg;
747 
748  /* Issue command */
749  if ( ( rc = intelxl_admin_command ( intelxl ) ) != 0 )
750  return rc;
751 
752  return 0;
753 }
754 
755 /**
756  * Get link status
757  *
758  * @v netdev Network device
759  * @ret rc Return status code
760  */
761 static int intelxl_admin_link ( struct net_device *netdev ) {
762  struct intelxl_nic *intelxl = netdev->priv;
765  int rc;
766 
767  /* Populate descriptor */
769  cmd->opcode = cpu_to_le16 ( INTELXL_ADMIN_LINK );
770  link = &cmd->params.link;
772 
773  /* Issue command */
774  if ( ( rc = intelxl_admin_command ( intelxl ) ) != 0 )
775  return rc;
776  DBGC ( intelxl, "INTELXL %p PHY %#02x speed %#02x status %#02x\n",
777  intelxl, link->phy, link->speed, link->status );
778 
779  /* Update network device */
780  if ( link->status & INTELXL_ADMIN_LINK_UP ) {
782  } else {
784  }
785 
786  return 0;
787 }
788 
789 /**
790  * Handle admin event
791  *
792  * @v netdev Network device
793  * @v evt Event descriptor
794  * @v buf Data buffer
795  */
796 static void intelxl_admin_event ( struct net_device *netdev,
797  struct intelxl_admin_descriptor *evt,
798  union intelxl_admin_buffer *buf __unused ) {
799  struct intelxl_nic *intelxl = netdev->priv;
800 
801  /* Ignore unrecognised events */
802  if ( evt->opcode != cpu_to_le16 ( INTELXL_ADMIN_LINK ) ) {
803  DBGC ( intelxl, "INTELXL %p unrecognised event opcode "
804  "%#04x\n", intelxl, le16_to_cpu ( evt->opcode ) );
805  return;
806  }
807 
808  /* Update link status */
810 }
811 
812 /**
813  * Refill admin event queue
814  *
815  * @v intelxl Intel device
816  */
817 static void intelxl_refill_admin ( struct intelxl_nic *intelxl ) {
818  struct intelxl_admin *admin = &intelxl->event;
819  const struct intelxl_admin_offsets *regs = admin->regs;
820  void *admin_regs = ( intelxl->regs + admin->base );
821  unsigned int tail;
822 
823  /* Update tail pointer */
824  tail = ( ( admin->index + INTELXL_ADMIN_NUM_DESC - 1 ) %
826  wmb();
827  writel ( tail, admin_regs + regs->tail );
828 }
829 
830 /**
831  * Poll admin event queue
832  *
833  * @v netdev Network device
834  */
836  struct intelxl_nic *intelxl = netdev->priv;
837  struct intelxl_admin *admin = &intelxl->event;
838  struct intelxl_admin_descriptor *evt;
839  union intelxl_admin_buffer *buf;
840 
841  /* Check for events */
842  while ( 1 ) {
843 
844  /* Get next event descriptor and data buffer */
845  evt = &admin->desc[ admin->index % INTELXL_ADMIN_NUM_DESC ];
846  buf = &admin->buf[ admin->index % INTELXL_ADMIN_NUM_DESC ];
847 
848  /* Stop if descriptor is not yet completed */
849  if ( ! ( evt->flags & INTELXL_ADMIN_FL_DD ) )
850  return;
851  DBGC2 ( intelxl, "INTELXL %p admin event %#x:\n",
852  intelxl, admin->index );
853  DBGC2_HDA ( intelxl, virt_to_phys ( evt ), evt,
854  sizeof ( *evt ) );
855  if ( evt->flags & cpu_to_le16 ( INTELXL_ADMIN_FL_BUF ) ) {
856  DBGC2_HDA ( intelxl, virt_to_phys ( buf ), buf,
857  le16_to_cpu ( evt->len ) );
858  }
859 
860  /* Handle event */
861  intelxl->handle ( netdev, evt, buf );
862 
863  /* Reset descriptor and refill queue */
864  intelxl_admin_event_init ( intelxl, admin->index );
865  admin->index++;
866  intelxl_refill_admin ( intelxl );
867  }
868 }
869 
870 /**
871  * Open admin queues
872  *
873  * @v intelxl Intel device
874  * @ret rc Return status code
875  */
876 int intelxl_open_admin ( struct intelxl_nic *intelxl ) {
877  int rc;
878 
879  /* Allocate admin event queue */
880  if ( ( rc = intelxl_alloc_admin ( intelxl, &intelxl->event ) ) != 0 )
881  goto err_alloc_event;
882 
883  /* Allocate admin command queue */
884  if ( ( rc = intelxl_alloc_admin ( intelxl, &intelxl->command ) ) != 0 )
885  goto err_alloc_command;
886 
887  /* (Re)open admin queues */
888  intelxl_reopen_admin ( intelxl );
889 
890  return 0;
891 
892  intelxl_disable_admin ( intelxl, &intelxl->command );
893  intelxl_disable_admin ( intelxl, &intelxl->event );
894  intelxl_free_admin ( intelxl, &intelxl->command );
895  err_alloc_command:
896  intelxl_free_admin ( intelxl, &intelxl->event );
897  err_alloc_event:
898  return rc;
899 }
900 
901 /**
902  * Reopen admin queues (after virtual function reset)
903  *
904  * @v intelxl Intel device
905  */
906 void intelxl_reopen_admin ( struct intelxl_nic *intelxl ) {
907  unsigned int i;
908 
909  /* Enable admin event queue */
910  intelxl_enable_admin ( intelxl, &intelxl->event );
911 
912  /* Enable admin command queue */
913  intelxl_enable_admin ( intelxl, &intelxl->command );
914 
915  /* Initialise all admin event queue descriptors */
916  for ( i = 0 ; i < INTELXL_ADMIN_NUM_DESC ; i++ )
917  intelxl_admin_event_init ( intelxl, i );
918 
919  /* Post all descriptors to event queue */
920  intelxl_refill_admin ( intelxl );
921 }
922 
923 /**
924  * Close admin queues
925  *
926  * @v intelxl Intel device
927  */
928 void intelxl_close_admin ( struct intelxl_nic *intelxl ) {
929 
930  /* Shut down admin queues */
931  intelxl_admin_shutdown ( intelxl );
932 
933  /* Disable admin queues */
934  intelxl_disable_admin ( intelxl, &intelxl->command );
935  intelxl_disable_admin ( intelxl, &intelxl->event );
936 
937  /* Free admin queues */
938  intelxl_free_admin ( intelxl, &intelxl->command );
939  intelxl_free_admin ( intelxl, &intelxl->event );
940 }
941 
942 /******************************************************************************
943  *
944  * Descriptor rings
945  *
946  ******************************************************************************
947  */
948 
949 /**
950  * Allocate descriptor ring
951  *
952  * @v intelxl Intel device
953  * @v ring Descriptor ring
954  * @ret rc Return status code
955  */
956 int intelxl_alloc_ring ( struct intelxl_nic *intelxl,
957  struct intelxl_ring *ring ) {
958  int rc;
959 
960  /* Allocate descriptor ring */
961  ring->desc.raw = dma_alloc ( intelxl->dma, &ring->map, ring->len,
962  INTELXL_ALIGN );
963  if ( ! ring->desc.raw ) {
964  rc = -ENOMEM;
965  goto err_alloc;
966  }
967 
968  /* Initialise descriptor ring */
969  memset ( ring->desc.raw, 0, ring->len );
970 
971  /* Reset tail pointer */
972  writel ( 0, ( intelxl->regs + ring->tail ) );
973 
974  /* Reset counters */
975  ring->prod = 0;
976  ring->cons = 0;
977 
978  DBGC ( intelxl, "INTELXL %p ring %06x is at [%08lx,%08lx)\n",
979  intelxl, ring->tail, virt_to_phys ( ring->desc.raw ),
980  ( virt_to_phys ( ring->desc.raw ) + ring->len ) );
981 
982  return 0;
983 
984  dma_free ( &ring->map, ring->desc.raw, ring->len );
985  err_alloc:
986  return rc;
987 }
988 
989 /**
990  * Free descriptor ring
991  *
992  * @v intelxl Intel device
993  * @v ring Descriptor ring
994  */
995 void intelxl_free_ring ( struct intelxl_nic *intelxl __unused,
996  struct intelxl_ring *ring ) {
997 
998  /* Free descriptor ring */
999  dma_free ( &ring->map, ring->desc.raw, ring->len );
1000  ring->desc.raw = NULL;
1001 }
1002 
1003 /**
1004  * Dump queue context (for debugging)
1005  *
1006  * @v intelxl Intel device
1007  * @v op Context operation
1008  * @v len Size of context
1009  */
1010 static __attribute__ (( unused )) void
1011 intelxl_context_dump ( struct intelxl_nic *intelxl, uint32_t op, size_t len ) {
1012  struct intelxl_context_line line;
1013  uint32_t pfcm_lanctxctl;
1014  uint32_t pfcm_lanctxstat;
1015  unsigned int queue;
1016  unsigned int index;
1017  unsigned int i;
1018 
1019  /* Do nothing unless debug output is enabled */
1020  if ( ! DBG_EXTRA )
1021  return;
1022 
1023  /* Dump context */
1024  DBGC2 ( intelxl, "INTELXL %p context %#08x:\n", intelxl, op );
1025  for ( index = 0 ; ( sizeof ( line ) * index ) < len ; index++ ) {
1026 
1027  /* Start context operation */
1028  queue = ( intelxl->base + intelxl->queue );
1029  pfcm_lanctxctl =
1033  writel ( pfcm_lanctxctl,
1034  intelxl->regs + INTELXL_PFCM_LANCTXCTL );
1035 
1036  /* Wait for operation to complete */
1037  for ( i = 0 ; i < INTELXL_CTX_MAX_WAIT_MS ; i++ ) {
1038 
1039  /* Check if operation is complete */
1040  pfcm_lanctxstat = readl ( intelxl->regs +
1042  if ( pfcm_lanctxstat & INTELXL_PFCM_LANCTXSTAT_DONE )
1043  break;
1044 
1045  /* Delay */
1046  mdelay ( 1 );
1047  }
1048 
1049  /* Read context data */
1050  for ( i = 0 ; i < ( sizeof ( line ) /
1051  sizeof ( line.raw[0] ) ) ; i++ ) {
1052  line.raw[i] = readl ( intelxl->regs +
1053  INTELXL_PFCM_LANCTXDATA ( i ) );
1054  }
1055  DBGC2_HDA ( intelxl, ( sizeof ( line ) * index ),
1056  &line, sizeof ( line ) );
1057  }
1058 }
1059 
1060 /**
1061  * Program queue context line
1062  *
1063  * @v intelxl Intel device
1064  * @v line Queue context line
1065  * @v index Line number
1066  * @v op Context operation
1067  * @ret rc Return status code
1068  */
1069 static int intelxl_context_line ( struct intelxl_nic *intelxl,
1070  struct intelxl_context_line *line,
1071  unsigned int index, uint32_t op ) {
1072  uint32_t pfcm_lanctxctl;
1073  uint32_t pfcm_lanctxstat;
1074  unsigned int queue;
1075  unsigned int i;
1076 
1077  /* Write context data */
1078  for ( i = 0; i < ( sizeof ( *line ) / sizeof ( line->raw[0] ) ); i++ ) {
1079  writel ( le32_to_cpu ( line->raw[i] ),
1080  intelxl->regs + INTELXL_PFCM_LANCTXDATA ( i ) );
1081  }
1082 
1083  /* Start context operation */
1084  queue = ( intelxl->base + intelxl->queue );
1085  pfcm_lanctxctl = ( INTELXL_PFCM_LANCTXCTL_QUEUE_NUM ( queue ) |
1088  writel ( pfcm_lanctxctl, intelxl->regs + INTELXL_PFCM_LANCTXCTL );
1089 
1090  /* Wait for operation to complete */
1091  for ( i = 0 ; i < INTELXL_CTX_MAX_WAIT_MS ; i++ ) {
1092 
1093  /* Check if operation is complete */
1094  pfcm_lanctxstat = readl ( intelxl->regs +
1096  if ( pfcm_lanctxstat & INTELXL_PFCM_LANCTXSTAT_DONE )
1097  return 0;
1098 
1099  /* Delay */
1100  mdelay ( 1 );
1101  }
1102 
1103  DBGC ( intelxl, "INTELXL %p timed out waiting for context: %#08x\n",
1104  intelxl, pfcm_lanctxctl );
1105  return -ETIMEDOUT;
1106 }
1107 
1108 /**
1109  * Program queue context
1110  *
1111  * @v intelxl Intel device
1112  * @v line Queue context lines
1113  * @v len Size of context
1114  * @v op Context operation
1115  * @ret rc Return status code
1116  */
1117 static int intelxl_context ( struct intelxl_nic *intelxl,
1118  struct intelxl_context_line *line,
1119  size_t len, uint32_t op ) {
1120  unsigned int index;
1121  int rc;
1122 
1123  DBGC2 ( intelxl, "INTELXL %p context %#08x len %#zx:\n",
1124  intelxl, op, len );
1125  DBGC2_HDA ( intelxl, 0, line, len );
1126 
1127  /* Program one line at a time */
1128  for ( index = 0 ; ( sizeof ( *line ) * index ) < len ; index++ ) {
1129  if ( ( rc = intelxl_context_line ( intelxl, line++, index,
1130  op ) ) != 0 )
1131  return rc;
1132  }
1133 
1134  return 0;
1135 }
1136 
1137 /**
1138  * Program transmit queue context
1139  *
1140  * @v intelxl Intel device
1141  * @v address Descriptor ring base address
1142  * @ret rc Return status code
1143  */
1144 static int intelxl_context_tx ( struct intelxl_nic *intelxl,
1145  physaddr_t address ) {
1146  union {
1147  struct intelxl_context_tx tx;
1148  struct intelxl_context_line line;
1149  } ctx;
1150  int rc;
1151 
1152  /* Initialise context */
1153  memset ( &ctx, 0, sizeof ( ctx ) );
1154  ctx.tx.flags = cpu_to_le16 ( INTELXL_CTX_TX_FL_NEW );
1155  ctx.tx.base = cpu_to_le64 ( INTELXL_CTX_TX_BASE ( address ) );
1156  ctx.tx.count =
1158  ctx.tx.qset = INTELXL_CTX_TX_QSET ( intelxl->qset );
1159 
1160  /* Program context */
1161  if ( ( rc = intelxl_context ( intelxl, &ctx.line, sizeof ( ctx ),
1163  return rc;
1164 
1165  return 0;
1166 }
1167 
1168 /**
1169  * Program receive queue context
1170  *
1171  * @v intelxl Intel device
1172  * @v address Descriptor ring base address
1173  * @ret rc Return status code
1174  */
1175 static int intelxl_context_rx ( struct intelxl_nic *intelxl,
1176  physaddr_t address ) {
1177  union {
1178  struct intelxl_context_rx rx;
1179  struct intelxl_context_line line;
1180  } ctx;
1181  uint64_t base_count;
1182  int rc;
1183 
1184  /* Initialise context */
1185  memset ( &ctx, 0, sizeof ( ctx ) );
1187  ctx.rx.base_count = cpu_to_le64 ( base_count );
1188  ctx.rx.len = cpu_to_le16 ( INTELXL_CTX_RX_LEN ( intelxl->mfs ) );
1190  ctx.rx.mfs = cpu_to_le16 ( INTELXL_CTX_RX_MFS ( intelxl->mfs ) );
1191 
1192  /* Program context */
1193  if ( ( rc = intelxl_context ( intelxl, &ctx.line, sizeof ( ctx ),
1195  return rc;
1196 
1197  return 0;
1198 }
1199 
1200 /**
1201  * Enable descriptor ring
1202  *
1203  * @v intelxl Intel device
1204  * @v ring Descriptor ring
1205  * @ret rc Return status code
1206  */
1207 static int intelxl_enable_ring ( struct intelxl_nic *intelxl,
1208  struct intelxl_ring *ring ) {
1209  void *ring_regs = ( intelxl->regs + ring->reg );
1210  uint32_t qxx_ena;
1211 
1212  /* Enable ring */
1213  writel ( INTELXL_QXX_ENA_REQ, ( ring_regs + INTELXL_QXX_ENA ) );
1215  qxx_ena = readl ( ring_regs + INTELXL_QXX_ENA );
1216  if ( ! ( qxx_ena & INTELXL_QXX_ENA_STAT ) ) {
1217  DBGC ( intelxl, "INTELXL %p ring %06x failed to enable: "
1218  "%#08x\n", intelxl, ring->tail, qxx_ena );
1219  return -EIO;
1220  }
1221 
1222  return 0;
1223 }
1224 
1225 /**
1226  * Disable descriptor ring
1227  *
1228  * @v intelxl Intel device
1229  * @v ring Descriptor ring
1230  * @ret rc Return status code
1231  */
1232 static int intelxl_disable_ring ( struct intelxl_nic *intelxl,
1233  struct intelxl_ring *ring ) {
1234  void *ring_regs = ( intelxl->regs + ring->reg );
1235  uint32_t qxx_ena;
1236  unsigned int i;
1237 
1238  /* Disable ring */
1239  writel ( 0, ( ring_regs + INTELXL_QXX_ENA ) );
1240 
1241  /* Wait for ring to be disabled */
1242  for ( i = 0 ; i < INTELXL_QUEUE_DISABLE_MAX_WAIT_MS ; i++ ) {
1243 
1244  /* Check if ring is disabled */
1245  qxx_ena = readl ( ring_regs + INTELXL_QXX_ENA );
1246  if ( ! ( qxx_ena & INTELXL_QXX_ENA_STAT ) )
1247  return 0;
1248 
1249  /* Delay */
1250  mdelay ( 1 );
1251  }
1252 
1253  DBGC ( intelxl, "INTELXL %p ring %06x timed out waiting for disable: "
1254  "%#08x\n", intelxl, ring->tail, qxx_ena );
1255  return -ETIMEDOUT;
1256 }
1257 
1258 /**
1259  * Create descriptor ring
1260  *
1261  * @v intelxl Intel device
1262  * @v ring Descriptor ring
1263  * @ret rc Return status code
1264  */
1265 int intelxl_create_ring ( struct intelxl_nic *intelxl,
1266  struct intelxl_ring *ring ) {
1268  int rc;
1269 
1270  /* Allocate descriptor ring */
1271  if ( ( rc = intelxl_alloc_ring ( intelxl, ring ) ) != 0 )
1272  goto err_alloc;
1273 
1274  /* Program queue context */
1275  address = dma ( &ring->map, ring->desc.raw );
1276  if ( ( rc = ring->context ( intelxl, address ) ) != 0 )
1277  goto err_context;
1278 
1279  /* Enable ring */
1280  if ( ( rc = intelxl_enable_ring ( intelxl, ring ) ) != 0 )
1281  goto err_enable;
1282 
1283  return 0;
1284 
1285  intelxl_disable_ring ( intelxl, ring );
1286  err_enable:
1287  err_context:
1288  intelxl_free_ring ( intelxl, ring );
1289  err_alloc:
1290  return rc;
1291 }
1292 
1293 /**
1294  * Destroy descriptor ring
1295  *
1296  * @v intelxl Intel device
1297  * @v ring Descriptor ring
1298  */
1299 void intelxl_destroy_ring ( struct intelxl_nic *intelxl,
1300  struct intelxl_ring *ring ) {
1301  int rc;
1302 
1303  /* Disable ring */
1304  if ( ( rc = intelxl_disable_ring ( intelxl, ring ) ) != 0 ) {
1305  /* Leak memory; there's nothing else we can do */
1306  return;
1307  }
1308 
1309  /* Free descriptor ring */
1310  intelxl_free_ring ( intelxl, ring );
1311 }
1312 
1313 /**
1314  * Refill receive descriptor ring
1315  *
1316  * @v intelxl Intel device
1317  */
1318 static void intelxl_refill_rx ( struct intelxl_nic *intelxl ) {
1320  struct io_buffer *iobuf;
1321  unsigned int rx_idx;
1322  unsigned int rx_tail;
1323  unsigned int refilled = 0;
1324 
1325  /* Refill ring */
1326  while ( ( intelxl->rx.prod - intelxl->rx.cons ) < INTELXL_RX_FILL ) {
1327 
1328  /* Allocate I/O buffer */
1329  iobuf = alloc_rx_iob ( intelxl->mfs, intelxl->dma );
1330  if ( ! iobuf ) {
1331  /* Wait for next refill */
1332  break;
1333  }
1334 
1335  /* Get next receive descriptor */
1336  rx_idx = ( intelxl->rx.prod++ % INTELXL_RX_NUM_DESC );
1337  rx = &intelxl->rx.desc.rx[rx_idx].data;
1338 
1339  /* Populate receive descriptor */
1340  rx->address = cpu_to_le64 ( iob_dma ( iobuf ) );
1341  rx->flags = 0;
1342 
1343  /* Record I/O buffer */
1344  assert ( intelxl->rx_iobuf[rx_idx] == NULL );
1345  intelxl->rx_iobuf[rx_idx] = iobuf;
1346 
1347  DBGC2 ( intelxl, "INTELXL %p RX %d is [%08lx,%08lx)\n",
1348  intelxl, rx_idx, virt_to_phys ( iobuf->data ),
1349  ( virt_to_phys ( iobuf->data ) + intelxl->mfs ) );
1350  refilled++;
1351  }
1352 
1353  /* Push descriptors to card, if applicable */
1354  if ( refilled ) {
1355  wmb();
1356  rx_tail = ( intelxl->rx.prod % INTELXL_RX_NUM_DESC );
1357  writel ( rx_tail, ( intelxl->regs + intelxl->rx.tail ) );
1358  }
1359 }
1360 
1361 /**
1362  * Discard unused receive I/O buffers
1363  *
1364  * @v intelxl Intel device
1365  */
1366 void intelxl_empty_rx ( struct intelxl_nic *intelxl ) {
1367  unsigned int i;
1368 
1369  /* Discard any unused receive buffers */
1370  for ( i = 0 ; i < INTELXL_RX_NUM_DESC ; i++ ) {
1371  if ( intelxl->rx_iobuf[i] )
1372  free_rx_iob ( intelxl->rx_iobuf[i] );
1373  intelxl->rx_iobuf[i] = NULL;
1374  }
1375 }
1376 
1377 /******************************************************************************
1378  *
1379  * Network device interface
1380  *
1381  ******************************************************************************
1382  */
1383 
1384 /**
1385  * Open network device
1386  *
1387  * @v netdev Network device
1388  * @ret rc Return status code
1389  */
1390 static int intelxl_open ( struct net_device *netdev ) {
1391  struct intelxl_nic *intelxl = netdev->priv;
1392  unsigned int queue;
1393  int rc;
1394 
1395  /* Calculate maximum frame size */
1396  intelxl->mfs = ( ( ETH_HLEN + netdev->mtu + 4 /* CRC */ +
1397  INTELXL_ALIGN - 1 ) & ~( INTELXL_ALIGN - 1 ) );
1398 
1399  /* Set MAC address */
1400  if ( ( rc = intelxl_admin_mac_write ( netdev ) ) != 0 )
1401  goto err_mac_write;
1402 
1403  /* Set maximum frame size */
1404  if ( ( rc = intelxl_admin_mac_config ( intelxl ) ) != 0 )
1405  goto err_mac_config;
1406 
1407  /* Associate transmit queue to PF */
1409  INTELXL_QXX_CTL_PFVF_PF_INDX ( intelxl->pf ) ),
1410  ( intelxl->regs + intelxl->tx.reg + INTELXL_QXX_CTL ) );
1411 
1412  /* Clear transmit pre queue disable */
1413  queue = ( intelxl->base + intelxl->queue );
1416  ( intelxl->regs + INTELXL_GLLAN_TXPRE_QDIS ( queue ) ) );
1417 
1418  /* Reset transmit queue head */
1419  writel ( 0, ( intelxl->regs + INTELXL_QTX_HEAD ( intelxl->queue ) ) );
1420 
1421  /* Create receive descriptor ring */
1422  if ( ( rc = intelxl_create_ring ( intelxl, &intelxl->rx ) ) != 0 )
1423  goto err_create_rx;
1424 
1425  /* Create transmit descriptor ring */
1426  if ( ( rc = intelxl_create_ring ( intelxl, &intelxl->tx ) ) != 0 )
1427  goto err_create_tx;
1428 
1429  /* Fill receive ring */
1430  intelxl_refill_rx ( intelxl );
1431 
1432  /* Restart autonegotiation */
1433  intelxl_admin_autoneg ( intelxl );
1434 
1435  /* Update link state */
1437 
1438  return 0;
1439 
1442  ( intelxl->regs + INTELXL_GLLAN_TXPRE_QDIS ( queue ) ) );
1444  intelxl_destroy_ring ( intelxl, &intelxl->tx );
1445  err_create_tx:
1446  intelxl_destroy_ring ( intelxl, &intelxl->rx );
1447  err_create_rx:
1448  err_mac_config:
1449  err_mac_write:
1450  return rc;
1451 }
1452 
1453 /**
1454  * Close network device
1455  *
1456  * @v netdev Network device
1457  */
1458 static void intelxl_close ( struct net_device *netdev ) {
1459  struct intelxl_nic *intelxl = netdev->priv;
1460  unsigned int queue;
1461 
1462  /* Dump contexts (for debugging) */
1464  sizeof ( struct intelxl_context_tx ) );
1466  sizeof ( struct intelxl_context_rx ) );
1467 
1468  /* Pre-disable transmit queue */
1469  queue = ( intelxl->base + intelxl->queue );
1472  ( intelxl->regs + INTELXL_GLLAN_TXPRE_QDIS ( queue ) ) );
1474 
1475  /* Destroy transmit descriptor ring */
1476  intelxl_destroy_ring ( intelxl, &intelxl->tx );
1477 
1478  /* Destroy receive descriptor ring */
1479  intelxl_destroy_ring ( intelxl, &intelxl->rx );
1480 
1481  /* Discard any unused receive buffers */
1482  intelxl_empty_rx ( intelxl );
1483 }
1484 
1485 /**
1486  * Transmit packet
1487  *
1488  * @v netdev Network device
1489  * @v iobuf I/O buffer
1490  * @ret rc Return status code
1491  */
1492 int intelxl_transmit ( struct net_device *netdev, struct io_buffer *iobuf ) {
1493  struct intelxl_nic *intelxl = netdev->priv;
1495  unsigned int tx_idx;
1496  unsigned int tx_tail;
1497  size_t len;
1498 
1499  /* Get next transmit descriptor */
1500  if ( ( intelxl->tx.prod - intelxl->tx.cons ) >= INTELXL_TX_FILL ) {
1501  DBGC ( intelxl, "INTELXL %p out of transmit descriptors\n",
1502  intelxl );
1503  return -ENOBUFS;
1504  }
1505  tx_idx = ( intelxl->tx.prod++ % INTELXL_TX_NUM_DESC );
1506  tx_tail = ( intelxl->tx.prod % INTELXL_TX_NUM_DESC );
1507  tx = &intelxl->tx.desc.tx[tx_idx].data;
1508 
1509  /* Populate transmit descriptor */
1510  len = iob_len ( iobuf );
1511  tx->address = cpu_to_le64 ( iob_dma ( iobuf ) );
1512  tx->len = cpu_to_le32 ( INTELXL_TX_DATA_LEN ( len ) );
1515  wmb();
1516 
1517  /* Notify card that there are packets ready to transmit */
1518  writel ( tx_tail, ( intelxl->regs + intelxl->tx.tail ) );
1519 
1520  DBGC2 ( intelxl, "INTELXL %p TX %d is [%08lx,%08lx)\n",
1521  intelxl, tx_idx, virt_to_phys ( iobuf->data ),
1522  ( virt_to_phys ( iobuf->data ) + len ) );
1523  return 0;
1524 }
1525 
1526 /**
1527  * Poll for completed packets
1528  *
1529  * @v netdev Network device
1530  */
1531 static void intelxl_poll_tx ( struct net_device *netdev ) {
1532  struct intelxl_nic *intelxl = netdev->priv;
1533  struct intelxl_tx_writeback_descriptor *tx_wb;
1534  unsigned int tx_idx;
1535 
1536  /* Check for completed packets */
1537  while ( intelxl->tx.cons != intelxl->tx.prod ) {
1538 
1539  /* Get next transmit descriptor */
1540  tx_idx = ( intelxl->tx.cons % INTELXL_TX_NUM_DESC );
1541  tx_wb = &intelxl->tx.desc.tx[tx_idx].wb;
1542 
1543  /* Stop if descriptor is still in use */
1544  if ( ! ( tx_wb->flags & INTELXL_TX_WB_FL_DD ) )
1545  return;
1546  DBGC2 ( intelxl, "INTELXL %p TX %d complete\n",
1547  intelxl, tx_idx );
1548 
1549  /* Complete TX descriptor */
1551  intelxl->tx.cons++;
1552  }
1553 }
1554 
1555 /**
1556  * Poll for received packets
1557  *
1558  * @v netdev Network device
1559  */
1560 static void intelxl_poll_rx ( struct net_device *netdev ) {
1561  struct intelxl_nic *intelxl = netdev->priv;
1562  struct intelxl_rx_writeback_descriptor *rx_wb;
1563  struct io_buffer *iobuf;
1564  unsigned int rx_idx;
1565  unsigned int tag;
1566  size_t len;
1567 
1568  /* Check for received packets */
1569  while ( intelxl->rx.cons != intelxl->rx.prod ) {
1570 
1571  /* Get next receive descriptor */
1572  rx_idx = ( intelxl->rx.cons % INTELXL_RX_NUM_DESC );
1573  rx_wb = &intelxl->rx.desc.rx[rx_idx].wb;
1574 
1575  /* Stop if descriptor is still in use */
1576  if ( ! ( rx_wb->flags & cpu_to_le32 ( INTELXL_RX_WB_FL_DD ) ) )
1577  return;
1578 
1579  /* Populate I/O buffer */
1580  iobuf = intelxl->rx_iobuf[rx_idx];
1581  intelxl->rx_iobuf[rx_idx] = NULL;
1582  len = INTELXL_RX_WB_LEN ( le32_to_cpu ( rx_wb->len ) );
1583  iob_put ( iobuf, len );
1584 
1585  /* Find VLAN device, if applicable */
1586  if ( rx_wb->flags & cpu_to_le32 ( INTELXL_RX_WB_FL_VLAN ) ) {
1587  tag = VLAN_TAG ( le16_to_cpu ( rx_wb->vlan ) );
1588  } else {
1589  tag = 0;
1590  }
1591 
1592  /* Hand off to network stack */
1593  if ( rx_wb->flags & cpu_to_le32 ( INTELXL_RX_WB_FL_RXE ) ) {
1594  DBGC ( intelxl, "INTELXL %p RX %d error (length %zd, "
1595  "flags %08x)\n", intelxl, rx_idx, len,
1596  le32_to_cpu ( rx_wb->flags ) );
1597  vlan_netdev_rx_err ( netdev, tag, iobuf, -EIO );
1598  } else {
1599  DBGC2 ( intelxl, "INTELXL %p RX %d complete (length "
1600  "%zd)\n", intelxl, rx_idx, len );
1601  vlan_netdev_rx ( netdev, tag, iobuf );
1602  }
1603  intelxl->rx.cons++;
1604  }
1605 }
1606 
1607 /**
1608  * Poll for completed and received packets
1609  *
1610  * @v netdev Network device
1611  */
1612 void intelxl_poll ( struct net_device *netdev ) {
1613  struct intelxl_nic *intelxl = netdev->priv;
1614 
1615  /* Poll for completed packets */
1616  intelxl_poll_tx ( netdev );
1617 
1618  /* Poll for received packets */
1619  intelxl_poll_rx ( netdev );
1620 
1621  /* Poll for admin events */
1623 
1624  /* Refill RX ring */
1625  intelxl_refill_rx ( intelxl );
1626 
1627  /* Rearm interrupt, since otherwise receive descriptors will
1628  * be written back only after a complete cacheline (four
1629  * packets) have been received.
1630  *
1631  * There is unfortunately no efficient way to determine
1632  * whether or not rearming the interrupt is necessary. If we
1633  * are running inside a hypervisor (e.g. using a VF or PF as a
1634  * passed-through PCI device), then the MSI-X write is
1635  * redirected by the hypervisor to the real host APIC and the
1636  * host ISR then raises an interrupt within the guest. We
1637  * therefore cannot poll the nominal MSI-X target location to
1638  * watch for the value being written. We could read from the
1639  * INT_DYN_CTL register, but this is even less efficient than
1640  * just unconditionally rearming the interrupt.
1641  */
1642  writel ( INTELXL_INT_DYN_CTL_INTENA, intelxl->regs + intelxl->intr );
1643 }
1644 
1645 /** Network device operations */
1647  .open = intelxl_open,
1648  .close = intelxl_close,
1649  .transmit = intelxl_transmit,
1650  .poll = intelxl_poll,
1651 };
1652 
1653 /******************************************************************************
1654  *
1655  * PCI interface
1656  *
1657  ******************************************************************************
1658  */
1659 
1660 /**
1661  * Probe PCI device
1662  *
1663  * @v pci PCI device
1664  * @ret rc Return status code
1665  */
1666 static int intelxl_probe ( struct pci_device *pci ) {
1667  struct net_device *netdev;
1668  struct intelxl_nic *intelxl;
1669  uint32_t pffunc_rid;
1670  uint32_t pfgen_portnum;
1671  uint32_t pflan_qalloc;
1672  int rc;
1673 
1674  /* Allocate and initialise net device */
1675  netdev = alloc_etherdev ( sizeof ( *intelxl ) );
1676  if ( ! netdev ) {
1677  rc = -ENOMEM;
1678  goto err_alloc;
1679  }
1682  intelxl = netdev->priv;
1683  pci_set_drvdata ( pci, netdev );
1684  netdev->dev = &pci->dev;
1685  memset ( intelxl, 0, sizeof ( *intelxl ) );
1686  intelxl->intr = INTELXL_PFINT_DYN_CTL0;
1687  intelxl->handle = intelxl_admin_event;
1693  sizeof ( intelxl->tx.desc.tx[0] ),
1696  sizeof ( intelxl->rx.desc.rx[0] ),
1698 
1699  /* Fix up PCI device */
1700  adjust_pci_device ( pci );
1701 
1702  /* Map registers */
1703  intelxl->regs = pci_ioremap ( pci, pci->membase, INTELXL_BAR_SIZE );
1704  if ( ! intelxl->regs ) {
1705  rc = -ENODEV;
1706  goto err_ioremap;
1707  }
1708 
1709  /* Configure DMA */
1710  intelxl->dma = &pci->dma;
1711  dma_set_mask_64bit ( intelxl->dma );
1712  netdev->dma = intelxl->dma;
1713 
1714  /* Locate PCI Express capability */
1715  intelxl->exp = pci_find_capability ( pci, PCI_CAP_ID_EXP );
1716  if ( ! intelxl->exp ) {
1717  DBGC ( intelxl, "INTELXL %p missing PCIe capability\n",
1718  intelxl );
1719  rc = -ENXIO;
1720  goto err_exp;
1721  }
1722 
1723  /* Reset the function via PCIe FLR */
1724  pci_reset ( pci, intelxl->exp );
1725 
1726  /* Get function number, port number and base queue number */
1727  pffunc_rid = readl ( intelxl->regs + INTELXL_PFFUNC_RID );
1728  intelxl->pf = INTELXL_PFFUNC_RID_FUNC_NUM ( pffunc_rid );
1729  pfgen_portnum = readl ( intelxl->regs + INTELXL_PFGEN_PORTNUM );
1730  intelxl->port = INTELXL_PFGEN_PORTNUM_PORT_NUM ( pfgen_portnum );
1731  pflan_qalloc = readl ( intelxl->regs + INTELXL_PFLAN_QALLOC );
1732  intelxl->base = INTELXL_PFLAN_QALLOC_FIRSTQ ( pflan_qalloc );
1733  DBGC ( intelxl, "INTELXL %p PF %d using port %d queues [%#04x-%#04x]\n",
1734  intelxl, intelxl->pf, intelxl->port, intelxl->base,
1735  INTELXL_PFLAN_QALLOC_LASTQ ( pflan_qalloc ) );
1736 
1737  /* Enable MSI-X dummy interrupt */
1738  if ( ( rc = intelxl_msix_enable ( intelxl, pci,
1739  INTELXL_MSIX_VECTOR ) ) != 0 )
1740  goto err_msix;
1741 
1742  /* Open admin queues */
1743  if ( ( rc = intelxl_open_admin ( intelxl ) ) != 0 )
1744  goto err_open_admin;
1745 
1746  /* Get firmware version */
1747  if ( ( rc = intelxl_admin_version ( intelxl ) ) != 0 )
1748  goto err_admin_version;
1749 
1750  /* Report driver version */
1751  if ( ( rc = intelxl_admin_driver ( intelxl ) ) != 0 )
1752  goto err_admin_driver;
1753 
1754  /* Clear PXE mode */
1755  if ( ( rc = intelxl_admin_clear_pxe ( intelxl ) ) != 0 )
1756  goto err_admin_clear_pxe;
1757 
1758  /* Get switch configuration */
1759  if ( ( rc = intelxl_admin_switch ( intelxl ) ) != 0 )
1760  goto err_admin_switch;
1761 
1762  /* Get VSI configuration */
1763  if ( ( rc = intelxl_admin_vsi ( intelxl ) ) != 0 )
1764  goto err_admin_vsi;
1765 
1766  /* Configure switch for promiscuous mode */
1767  if ( ( rc = intelxl_admin_promisc ( intelxl ) ) != 0 )
1768  goto err_admin_promisc;
1769 
1770  /* Get MAC address */
1771  if ( ( rc = intelxl_admin_mac_read ( netdev ) ) != 0 )
1772  goto err_admin_mac_read;
1773 
1774  /* Configure queue register addresses */
1775  intelxl->tx.reg = INTELXL_QTX ( intelxl->queue );
1776  intelxl->tx.tail = ( intelxl->tx.reg + INTELXL_QXX_TAIL );
1777  intelxl->rx.reg = INTELXL_QRX ( intelxl->queue );
1778  intelxl->rx.tail = ( intelxl->rx.reg + INTELXL_QXX_TAIL );
1779 
1780  /* Configure interrupt causes */
1783  intelxl->regs + INTELXL_QINT_TQCTL ( intelxl->queue ) );
1784  writel ( ( INTELXL_QINT_RQCTL_NEXTQ_INDX ( intelxl->queue ) |
1787  intelxl->regs + INTELXL_QINT_RQCTL ( intelxl->queue ) );
1790  intelxl->regs + INTELXL_PFINT_LNKLST0 );
1792  intelxl->regs + INTELXL_PFINT_ICR0_ENA );
1793 
1794  /* Register network device */
1795  if ( ( rc = register_netdev ( netdev ) ) != 0 )
1796  goto err_register_netdev;
1797 
1798  /* Set initial link state */
1800 
1801  return 0;
1802 
1804  err_register_netdev:
1805  err_admin_mac_read:
1806  err_admin_promisc:
1807  err_admin_vsi:
1808  err_admin_switch:
1809  err_admin_clear_pxe:
1810  err_admin_driver:
1811  err_admin_version:
1812  intelxl_close_admin ( intelxl );
1813  err_open_admin:
1814  intelxl_msix_disable ( intelxl, pci, INTELXL_MSIX_VECTOR );
1815  err_msix:
1816  pci_reset ( pci, intelxl->exp );
1817  err_exp:
1818  iounmap ( intelxl->regs );
1819  err_ioremap:
1820  netdev_nullify ( netdev );
1821  netdev_put ( netdev );
1822  err_alloc:
1823  return rc;
1824 }
1825 
1826 /**
1827  * Remove PCI device
1828  *
1829  * @v pci PCI device
1830  */
1831 static void intelxl_remove ( struct pci_device *pci ) {
1832  struct net_device *netdev = pci_get_drvdata ( pci );
1833  struct intelxl_nic *intelxl = netdev->priv;
1834 
1835  /* Unregister network device */
1837 
1838  /* Close admin queues */
1839  intelxl_close_admin ( intelxl );
1840 
1841  /* Disable MSI-X dummy interrupt */
1842  intelxl_msix_disable ( intelxl, pci, INTELXL_MSIX_VECTOR );
1843 
1844  /* Reset the NIC */
1845  pci_reset ( pci, intelxl->exp );
1846 
1847  /* Free network device */
1848  iounmap ( intelxl->regs );
1849  netdev_nullify ( netdev );
1850  netdev_put ( netdev );
1851 }
1852 
1853 /** PCI device IDs */
1854 static struct pci_device_id intelxl_nics[] = {
1855  PCI_ROM ( 0x8086, 0x0cf8, "x710-n3000", "X710 FPGA N3000", 0 ),
1856  PCI_ROM ( 0x8086, 0x0d58, "xxv710-n3000", "XXV710 FPGA N3000", 0 ),
1857  PCI_ROM ( 0x8086, 0x104e, "x710-sfp-b", "X710 10GbE SFP+", 0 ),
1858  PCI_ROM ( 0x8086, 0x104f, "x710-kx-b", "X710 10GbE backplane", 0 ),
1859  PCI_ROM ( 0x8086, 0x1572, "x710-sfp", "X710 10GbE SFP+", 0 ),
1860  PCI_ROM ( 0x8086, 0x1574, "xl710-qemu", "Virtual XL710", 0 ),
1861  PCI_ROM ( 0x8086, 0x1580, "xl710-kx-b", "XL710 40GbE backplane", 0 ),
1862  PCI_ROM ( 0x8086, 0x1581, "xl710-kx-c", "XL710 10GbE backplane", 0 ),
1863  PCI_ROM ( 0x8086, 0x1583, "xl710-qda2", "XL710 40GbE QSFP+", 0 ),
1864  PCI_ROM ( 0x8086, 0x1584, "xl710-qda1", "XL710 40GbE QSFP+", 0 ),
1865  PCI_ROM ( 0x8086, 0x1585, "x710-qsfp", "X710 10GbE QSFP+", 0 ),
1866  PCI_ROM ( 0x8086, 0x1586, "x710-10gt", "X710 10GBASE-T", 0 ),
1867  PCI_ROM ( 0x8086, 0x1587, "x710-kr2", "XL710 20GbE backplane", 0 ),
1868  PCI_ROM ( 0x8086, 0x1588, "x710-kr2-a", "XL710 20GbE backplane", 0 ),
1869  PCI_ROM ( 0x8086, 0x1589, "x710-10gt4", "X710 10GBASE-T4", 0 ),
1870  PCI_ROM ( 0x8086, 0x158a, "xxv710", "XXV710 25GbE backplane", 0 ),
1871  PCI_ROM ( 0x8086, 0x158b, "xxv710-sfp28", "XXV710 25GbE SFP28", 0 ),
1872  PCI_ROM ( 0x8086, 0x15ff, "x710-10gt-b", "X710 10GBASE-T", 0 ),
1873  PCI_ROM ( 0x8086, 0x37ce, "x722-kx", "X722 10GbE backplane", 0 ),
1874  PCI_ROM ( 0x8086, 0x37cf, "x722-qsfp", "X722 10GbE QSFP+", 0 ),
1875  PCI_ROM ( 0x8086, 0x37d0, "x722-sfp", "X722 10GbE SFP+", 0 ),
1876  PCI_ROM ( 0x8086, 0x37d1, "x722-1gt", "X722 1GBASE-T", 0 ),
1877  PCI_ROM ( 0x8086, 0x37d2, "x722-10gt", "X722 10GBASE-T", 0 ),
1878  PCI_ROM ( 0x8086, 0x37d3, "x722-sfp-i", "X722 10GbE SFP+", 0 ),
1879 };
1880 
1881 /** PCI driver */
1882 struct pci_driver intelxl_driver __pci_driver = {
1883  .ids = intelxl_nics,
1884  .id_count = ( sizeof ( intelxl_nics ) / sizeof ( intelxl_nics[0] ) ),
1885  .probe = intelxl_probe,
1887 };
const char product_short_name[]
Product short name string.
Definition: version.c:76
struct intelxl_admin_descriptor * intelxl_admin_command_descriptor(struct intelxl_nic *intelxl)
Get next admin command queue descriptor.
Definition: intelxl.c:221
static int intelxl_admin_promisc(struct intelxl_nic *intelxl)
Set VSI promiscuous modes.
Definition: intelxl.c:680
Receive queue context.
Definition: intelxl.h:567
#define INTELXL_PFLAN_QALLOC_FIRSTQ(x)
First queue.
Definition: intelxl.h:892
#define INTELXL_GLLAN_TXPRE_QDIS(x)
Global Transmit Pre Queue Disable register.
Definition: intelxl.h:625
int intelxl_transmit(struct net_device *netdev, struct io_buffer *iobuf)
Transmit packet.
Definition: intelxl.c:1492
#define __attribute__(x)
Definition: compiler.h:10
void * regs
Registers.
Definition: intelxl.h:911
#define VLAN_TAG(tci)
Extract VLAN tag from tag control information.
Definition: vlan.h:29
#define INTELXL_ADMIN_PROMISC_FL_VLAN
Promiscuous VLAN mode.
Definition: intelxl.h:307
#define INTELXL_QRX(x)
Global Receive Queue register block.
Definition: intelxl.h:638
struct option_descriptor read[1]
Definition: nvo_cmd.c:115
#define INTELXL_ADMIN_AUTONEG_FL_RESTART
Restart autonegotiation.
Definition: intelxl.h:337
unsigned long membase
Memory base.
Definition: pci.h:219
#define INTELXL_ADMIN_SHUTDOWN
Admin queue Shutdown command.
Definition: intelxl.h:135
size_t len
Length (in bytes)
Definition: intelxl.h:777
#define INTELXL_ADMIN_FL_ERR
Admin descriptor completed in error.
Definition: intelxl.h:439
struct dma_device * dma
DMA device.
Definition: intelxl.h:913
#define INTELXL_PFLAN_QALLOC_LASTQ(x)
Last queue.
Definition: intelxl.h:895
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define INTELXL_CTX_RX_LEN(len)
Receive queue data buffer length.
Definition: intelxl.h:591
void pci_msix_disable(struct pci_device *pci, struct pci_msix *msix)
Disable MSI-X interrupts.
Definition: pcimsix.c:207
unsigned short uint16_t
Definition: stdint.h:11
wmb()
#define INTELXL_ADMIN_BAH
Admin Queue Base Address High Register (offset)
Definition: intelxl.h:45
#define iob_put(iobuf, len)
Definition: iobuf.h:124
struct dma_device dma
DMA device.
Definition: pci.h:214
#define INTELXL_PFFUNC_RID
Function Requester ID Information Register.
Definition: intelxl.h:885
void intelxl_destroy_ring(struct intelxl_nic *intelxl, struct intelxl_ring *ring)
Destroy descriptor ring.
Definition: intelxl.c:1299
uint32_t raw[4]
Raw data.
Definition: intelxl.h:531
A PCI driver.
Definition: pci.h:251
static int intelxl_admin_switch(struct intelxl_nic *intelxl)
Get switch configuration.
Definition: intelxl.c:592
#define INTELXL_ADMIN_EVT
PF Admin Event Queue register block.
Definition: intelxl.h:39
#define INTELXL_PFLAN_QALLOC
PF Queue Allocation Register.
Definition: intelxl.h:891
int(* context)(struct intelxl_nic *intelxl, physaddr_t address)
Program queue context.
Definition: intelxl.h:783
#define INTELXL_QXX_CTL_PFVF_Q_PF
PF queue.
Definition: intelxl.h:648
static void intelxl_context_dump(struct intelxl_nic *intelxl, uint32_t op, size_t len)
Dump queue context (for debugging)
Definition: intelxl.c:1011
#define INTELXL_GLLAN_TXPRE_QDIS_QINDX(x)
Queue index.
Definition: intelxl.h:626
#define INTELXL_ADMIN_LINK
Admin queue Get Link Status command.
Definition: intelxl.h:343
#define le32_to_cpu(value)
Definition: byteswap.h:113
int(* open)(struct net_device *netdev)
Open network device.
Definition: netdevice.h:222
int pci_find_capability(struct pci_device *pci, int cap)
Look for a PCI capability.
Definition: pciextra.c:38
static int intelxl_context_tx(struct intelxl_nic *intelxl, physaddr_t address)
Program transmit queue context.
Definition: intelxl.c:1144
static int intelxl_open(struct net_device *netdev)
Open network device.
Definition: intelxl.c:1390
#define INTELXL_ADMIN_SWITCH
Admin queue Get Switch Configuration command.
Definition: intelxl.h:206
#define INTELXL_ADMIN_AUTONEG
Admin queue Restart Autonegotiation command.
Definition: intelxl.h:326
Error codes.
#define INTELXL_QINT_RQCTL_NEXTQ_INDX(x)
Queue index.
Definition: intelxl.h:862
void(* handle)(struct net_device *netdev, struct intelxl_admin_descriptor *evt, union intelxl_admin_buffer *buf)
Handle admin event.
Definition: intelxl.h:962
#define INTELXL_PFCM_LANCTXCTL_OP_CODE_WRITE
Write context.
Definition: intelxl.h:521
uint32_t vector
MSI-X vector.
Definition: ena.h:20
#define INTELXL_ADMIN_LEN_ENABLE
Queue enable.
Definition: intelxl.h:50
uint16_t queue[16]
Queue numbers.
Definition: intelxl.h:273
#define INTELXL_QINT_TQCTL_NEXTQ_INDX_NONE
End of list.
Definition: intelxl.h:875
#define INTELXL_ADMIN_CMD
PF Admin Command Queue register block.
Definition: intelxl.h:36
union intelxl_admin_buffer * buf
Data buffers.
Definition: intelxl.h:455
uint16_t qset[8]
Queue set handles for each traffic class.
Definition: intelxl.h:277
struct intelxl_admin_vsi_buffer vsi
Get VSI Parameters data buffer.
Definition: intelxl.h:409
static void netdev_tx_complete_next(struct net_device *netdev)
Complete network transmission.
Definition: netdevice.h:778
Admin queue register offsets.
Definition: intelxl.h:63
I/O buffers.
Admin queue Restart Autonegotiation command parameters.
Definition: intelxl.h:329
static int intelxl_enable_ring(struct intelxl_nic *intelxl, struct intelxl_ring *ring)
Enable descriptor ring.
Definition: intelxl.c:1207
struct pci_device_id * ids
PCI ID table.
Definition: pci.h:253
uint16_t vlan
VLAN tag.
Definition: intelxl.h:723
uint8_t type
Switching element type.
Definition: intelxl.h:211
uint64_t address
Base address.
Definition: ena.h:24
static int intelxl_admin_shutdown(struct intelxl_nic *intelxl)
Shutdown admin queues.
Definition: intelxl.c:454
uint16_t opcode
Opcode.
Definition: intelxl.h:419
Queue context line.
Definition: intelxl.h:529
size_t mtu
Maximum transmission unit length.
Definition: netdevice.h:415
Admin queue.
Definition: intelxl.h:451
#define INTELXL_TX_DATA_EOP
Transmit data descriptor end of packet.
Definition: intelxl.h:669
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
Admin queue Get VSI Parameters command parameters.
Definition: intelxl.h:259
unsigned int qset
Queue set handle.
Definition: intelxl.h:928
struct pci_api * api
API for this bus:dev.fn address.
Definition: pcicloud.c:42
#define INTELXL_RX_WB_FL_DD
Receive writeback descriptor complete.
Definition: intelxl.h:735
#define INTELXL_TX_DATA_DTYP
Transmit data descriptor type.
Definition: intelxl.h:666
#define DBGC(...)
Definition: compiler.h:505
int intelxl_admin_clear_pxe(struct intelxl_nic *intelxl)
Clear PXE mode.
Definition: intelxl.c:560
#define INTELXL_PFINT_ICR0_ENA
PF Interrupt Zero Cause Enablement Register.
Definition: intelxl.h:857
unsigned int prod
Producer index.
Definition: intelxl.h:768
struct intelxl_admin command
Admin command queue.
Definition: intelxl.h:941
Admin queue Shutdown command parameters.
Definition: intelxl.h:138
long index
Definition: bigint.h:62
#define ENOENT
No such file or directory.
Definition: errno.h:514
char name[32]
Driver name.
Definition: intelxl.h:131
uint16_t flags
Flags.
Definition: intelxl.h:417
static int intelxl_context_rx(struct intelxl_nic *intelxl, physaddr_t address)
Program receive queue context.
Definition: intelxl.c:1175
union intelxl_admin_buffer * intelxl_admin_command_buffer(struct intelxl_nic *intelxl)
Get next admin command queue data buffer.
Definition: intelxl.c:238
unsigned long long uint64_t
Definition: stdint.h:13
#define INTELXL_INT_DYN_CTL_INTENA
Enable.
Definition: intelxl.h:837
static void intelxl_enable_admin(struct intelxl_nic *intelxl, struct intelxl_admin *admin)
Enable admin queue.
Definition: intelxl.c:151
struct intelxl_admin_driver_buffer driver
Driver Version data buffer.
Definition: intelxl.h:403
static __always_inline void dma_set_mask_64bit(struct dma_device *dma)
Set 64-bit addressable space mask.
Definition: dma.h:466
struct dma_device * dma
DMA device.
Definition: netdevice.h:366
static int intelxl_admin_mac_read(struct net_device *netdev)
Get MAC address.
Definition: intelxl.c:478
static void intelxl_poll_tx(struct net_device *netdev)
Poll for completed packets.
Definition: intelxl.c:1531
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
#define cpu_to_le64(value)
Definition: byteswap.h:108
void netdev_link_down(struct net_device *netdev)
Mark network device as having link down.
Definition: netdevice.c:230
#define INTELXL_CTX_RX_MFS(mfs)
Receive queue maximum frame size.
Definition: intelxl.h:600
#define INTELXL_QXX_ENA_STAT
Enabled status.
Definition: intelxl.h:643
struct intelxl_rx_writeback_descriptor wb
Receive writeback descriptor.
Definition: intelxl.h:751
#define INTELXL_ALIGN
Alignment.
Definition: intelxl.h:26
static int intelxl_disable_ring(struct intelxl_nic *intelxl, struct intelxl_ring *ring)
Disable descriptor ring.
Definition: intelxl.c:1232
uint8_t mac[ETH_ALEN]
MAC address.
Definition: ena.h:24
unsigned int bal
Base Address Low Register offset.
Definition: intelxl.h:65
struct golan_eq_context ctx
Definition: CIB_PRM.h:28
#define INTELXL_PFINT_ICR0_ENA_ADMINQ
Admin event.
Definition: intelxl.h:858
size_t mfs
Maximum frame size.
Definition: intelxl.h:915
struct intelxl_admin_switch_buffer sw
Get Switch Configuration data buffer.
Definition: intelxl.h:407
#define INTELXL_PFGEN_PORTNUM_PORT_NUM(x)
Port number.
Definition: intelxl.h:901
Admin queue Set MAC Configuration command parameters.
Definition: intelxl.h:313
int intelxl_open_admin(struct intelxl_nic *intelxl)
Open admin queues.
Definition: intelxl.c:876
unsigned int base
Register block base.
Definition: intelxl.h:462
void pci_reset(struct pci_device *pci, unsigned int exp)
Perform PCI Express function-level reset (FLR)
Definition: pciextra.c:88
union intelxl_tx_descriptor * tx
Transmit descriptors.
Definition: intelxl.h:759
void adjust_pci_device(struct pci_device *pci)
Enable PCI device.
Definition: pci.c:240
#define INTELXL_CTX_RX_FL_DSIZE
Use 32-byte receive descriptors.
Definition: intelxl.h:594
#define INTELXL_ADMIN_VSI
Admin queue Get VSI Parameters command.
Definition: intelxl.h:256
struct device dev
Generic device.
Definition: pci.h:212
unsigned int queue
Queue number.
Definition: intelxl.h:924
Admin queue Clear PXE Mode command parameters.
Definition: intelxl.h:195
unsigned int exp
PCI Express capability offset.
Definition: intelxl.h:936
#define INTELXL_ADMIN_PROMISC
Admin queue Set VSI Promiscuous Modes command.
Definition: intelxl.h:283
#define ENOTSUP
Operation not supported.
Definition: errno.h:589
#define INTELXL_ADMIN_NUM_DESC
Number of admin queue descriptors.
Definition: intelxl.h:483
#define INTELXL_QXX_ENA
Queue Enable Register (offset)
Definition: intelxl.h:641
#define INTELXL_TX_DATA_LEN(len)
Transmit data descriptor length.
Definition: intelxl.h:685
#define INTELXL_ADMIN_MAC_READ_VALID_LAN
LAN MAC address is valid.
Definition: intelxl.h:160
Intel 40 Gigabit Ethernet network card driver.
static void netdev_init(struct net_device *netdev, struct net_device_operations *op)
Initialise a network device.
Definition: netdevice.h:518
#define INTELXL_PFCM_LANCTXCTL_TYPE_RX
RX queue type.
Definition: intelxl.h:512
static void intelxl_refill_rx(struct intelxl_nic *intelxl)
Refill receive descriptor ring.
Definition: intelxl.c:1318
#define INTELXL_PFCM_LANCTXCTL_TYPE_TX
TX queue type.
Definition: intelxl.h:514
static struct pci_device_id intelxl_nics[]
PCI device IDs.
Definition: intelxl.c:1854
void dma_free(struct dma_mapping *map, void *addr, size_t len)
Unmap and free DMA-coherent buffer.
static void pci_set_drvdata(struct pci_device *pci, void *priv)
Set PCI driver-private data.
Definition: pci.h:365
#define ENOMEM
Not enough space.
Definition: errno.h:534
unsigned int cons
Consumer index.
Definition: intelxl.h:770
#define INTELXL_PFGEN_PORTNUM
PF LAN Port Number Register.
Definition: intelxl.h:900
void * memcpy(void *dest, const void *src, size_t len) __nonnull
uint8_t pf[ETH_ALEN]
Physical function MAC address.
Definition: intelxl.h:165
static int intelxl_context(struct intelxl_nic *intelxl, struct intelxl_context_line *line, size_t len, uint32_t op)
Program queue context.
Definition: intelxl.c:1117
uint16_t len
Data length.
Definition: intelxl.h:421
struct intelxl_ring rx
Receive descriptor ring.
Definition: intelxl.h:951
static void intelxl_init_admin(struct intelxl_admin *admin, unsigned int base, const struct intelxl_admin_offsets *regs)
Initialise admin queue.
Definition: intelxl.h:475
#define INTELXL_QINT_TQCTL_CAUSE_ENA
Enable.
Definition: intelxl.h:882
#define INTELXL_ADMIN_FL_CMP
Admin descriptor contains a completion.
Definition: intelxl.h:436
u32 version
Driver version.
Definition: ath9k_hw.c:1983
unsigned int index
Queue index.
Definition: intelxl.h:459
Transmit writeback descriptor.
Definition: intelxl.h:688
#define INTELXL_ADMIN_CLEAR_PXE_MAGIC
Clear PXE Mode magic value.
Definition: intelxl.h:203
#define ETH_HLEN
Definition: if_ether.h:9
struct io_buffer * rx_iobuf[INTELXL_RX_NUM_DESC]
Receive I/O buffers.
Definition: intelxl.h:953
#define INTELXL_PFINT_LNKLST0_FIRSTQ_TYPE_RX
Receive queue.
Definition: intelxl.h:851
static void intelxl_admin_event_init(struct intelxl_nic *intelxl, unsigned int index)
Initialise admin event queue descriptor.
Definition: intelxl.c:254
#define INTELXL_PFINT_DYN_CTL0
PF Interrupt Zero Dynamic Control Register.
Definition: intelxl.h:836
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
#define INTELXL_MAX_PKT_LEN
Maximum packet length (excluding CRC)
Definition: intelxl.h:826
uint8_t magic
Magic value.
Definition: intelxl.h:197
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
Definition: netdevice.h:575
Ethernet protocol.
static void intelxl_admin_event(struct net_device *netdev, struct intelxl_admin_descriptor *evt, union intelxl_admin_buffer *buf __unused)
Handle admin event.
Definition: intelxl.c:796
#define INTELXL_QXX_CTL_PFVF_PF_INDX(x)
PF index.
Definition: intelxl.h:650
#define INTELXL_QINT_RQCTL_CAUSE_ENA
Enable.
Definition: intelxl.h:870
Admin queue version number.
Definition: intelxl.h:90
static void pci_msix_mask(struct pci_msix *msix, unsigned int vector)
Mask MSI-X interrupt vector.
Definition: pcimsix.h:64
unsigned int vsi
Virtual Station Interface switching element ID.
Definition: intelxl.h:926
#define INTELXL_QINT_RQCTL_NEXTQ_TYPE_TX
Transmit queue.
Definition: intelxl.h:868
struct intelxl_tx_data_descriptor data
Transmit data descriptor.
Definition: intelxl.h:703
#define INTELXL_TX_NUM_DESC
Number of transmit descriptors.
Definition: intelxl.h:808
void * priv
Driver private data.
Definition: netdevice.h:431
#define bswap_16(value)
Definition: byteswap.h:58
uint16_t high
MAC address first 16 bits, byte-swapped.
Definition: intelxl.h:184
#define INTELXL_PFCM_LANCTXCTL_QUEUE_NUM(x)
Queue number.
Definition: intelxl.h:503
#define DBGC_HDA(...)
Definition: compiler.h:506
#define __unused
Declare a variable or data structure as unused.
Definition: compiler.h:573
static void netdev_link_up(struct net_device *netdev)
Mark network device as having link up.
Definition: netdevice.h:788
ring len
Length.
Definition: dwmac.h:231
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
void * raw
Raw data.
Definition: intelxl.h:763
uint16_t flags
Flags.
Definition: intelxl.h:288
#define INTELXL_PFCM_LANCTXSTAT
CMLAN Context Status Register.
Definition: intelxl.h:525
static struct net_device * netdev
Definition: gdbudp.c:52
static __always_inline physaddr_t iob_dma(struct io_buffer *iobuf)
Get I/O buffer DMA address.
Definition: iobuf.h:267
u32 link
Link to next descriptor.
Definition: ar9003_mac.h:68
#define INTELXL_RX_NUM_DESC
Number of receive descriptors.
Definition: intelxl.h:817
static void intelxl_refill_admin(struct intelxl_nic *intelxl)
Refill admin event queue.
Definition: intelxl.c:817
#define INTELXL_QXX_ENA_REQ
Enable request.
Definition: intelxl.h:642
static void pci_msix_unmask(struct pci_msix *msix, unsigned int vector)
Unmask MSI-X interrupt vector.
Definition: pcimsix.h:76
#define INTELXL_ADMIN_VERSION
Admin queue Get Version command.
Definition: intelxl.h:87
#define INTELXL_CTX_TX_FL_NEW
New transmit queue context.
Definition: intelxl.h:555
int intelxl_create_ring(struct intelxl_nic *intelxl, struct intelxl_ring *ring)
Create descriptor ring.
Definition: intelxl.c:1265
void intelxl_poll_admin(struct net_device *netdev)
Poll admin event queue.
Definition: intelxl.c:835
uint32_t low
MAC address last 32 bits, byte-swapped.
Definition: intelxl.h:186
union intelxl_ring::@79 desc
Descriptors.
void unregister_netdev(struct net_device *netdev)
Unregister network device.
Definition: netdevice.c:941
uint16_t downlink
Downlink switching element ID.
Definition: intelxl.h:219
#define INTELXL_ADMIN_API_MAJOR
Admin queue API major version.
Definition: intelxl.h:489
#define INTELXL_ADMIN_EEXIST
Error: attempt to create something that already exists.
Definition: intelxl.h:448
struct dma_mapping map
DMA mapping.
Definition: intelxl.h:457
#define bswap_32(value)
Definition: byteswap.h:70
unsigned int reg
Register block.
Definition: intelxl.h:773
#define cpu_to_le32(value)
Definition: byteswap.h:107
void intelxl_free_ring(struct intelxl_nic *intelxl __unused, struct intelxl_ring *ring)
Free descriptor ring.
Definition: intelxl.c:995
static int intelxl_alloc_admin(struct intelxl_nic *intelxl, struct intelxl_admin *admin)
Allocate admin queue.
Definition: intelxl.c:123
#define EPROTO
Protocol error.
Definition: errno.h:624
struct intelxl_admin_mac_read_buffer mac_read
Manage MAC Address Read data buffer.
Definition: intelxl.h:405
#define DBGC2_HDA(...)
Definition: compiler.h:523
#define INTELXL_QUEUE_DISABLE_MAX_WAIT_MS
Maximum time to wait for a queue to become disabled.
Definition: intelxl.h:612
Receive data descriptor.
Definition: intelxl.h:709
#define INTELXL_TX_DATA_RS
Transmit data descriptor report status.
Definition: intelxl.h:672
uint8_t flags
Flags.
Definition: ena.h:18
#define INTELXL_ADMIN_MAC_READ
Admin queue Manage MAC Address Read command.
Definition: intelxl.h:149
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
Admin queue Driver Version command parameters.
Definition: intelxl.h:113
Admin queue Manage MAC Address Read command parameters.
Definition: intelxl.h:152
struct io_buffer * alloc_rx_iob(size_t len, struct dma_device *dma)
Allocate and map I/O buffer for receive DMA.
Definition: iobuf.c:187
union intelxl_rx_descriptor * rx
Receive descriptors.
Definition: intelxl.h:761
PCI bus.
A PCI device.
Definition: pci.h:210
int register_netdev(struct net_device *netdev)
Register network device.
Definition: netdevice.c:759
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:159
const char * eth_ntoa(const void *ll_addr)
Transcribe Ethernet address.
Definition: ethernet.c:175
device nvs write
Definition: threewire.h:61
unsigned int intr
Interrupt control register.
Definition: intelxl.h:934
static int intelxl_admin_autoneg(struct intelxl_nic *intelxl)
Restart autonegotiation.
Definition: intelxl.c:736
#define INTELXL_PFCM_LANCTXCTL_SUB_LINE(x)
Sub-line.
Definition: intelxl.h:506
struct intelxl_admin_descriptor * desc
Descriptors.
Definition: intelxl.h:453
A network device.
Definition: netdevice.h:352
#define INTELXL_QTX(x)
Global Transmit Queue register block.
Definition: intelxl.h:635
#define ENODEV
No such device.
Definition: errno.h:509
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
Definition: netdevice.h:531
static void intelxl_free_admin(struct intelxl_nic *intelxl __unused, struct intelxl_admin *admin)
Free admin queue.
Definition: intelxl.c:205
#define INTELXL_ADMIN_MAC_WRITE
Admin queue Manage MAC Address Write command.
Definition: intelxl.h:175
struct dma_mapping map
Descriptor ring DMA mapping.
Definition: intelxl.h:766
unsigned char uint8_t
Definition: stdint.h:10
static void intelxl_disable_admin(struct intelxl_nic *intelxl, struct intelxl_admin *admin)
Disable admin queue.
Definition: intelxl.c:190
#define INTELXL_ADMIN_FL_BUF
Admin descriptor uses data buffer.
Definition: intelxl.h:445
void intelxl_msix_disable(struct intelxl_nic *intelxl, struct pci_device *pci, unsigned int vector)
Disable MSI-X dummy interrupt.
Definition: intelxl.c:90
unsigned int port
Port number.
Definition: intelxl.h:922
#define INTELXL_ADMIN_BAL
Admin Queue Base Address Low Register (offset)
Definition: intelxl.h:42
Admin queue Get Version command parameters.
Definition: intelxl.h:98
Transmit data descriptor.
Definition: intelxl.h:656
#define INTELXL_CTX_TX_QSET(qset)
Transmit queue set.
Definition: intelxl.h:564
#define INTELXL_QUEUE_PRE_DISABLE_DELAY_US
Time to wait for a transmit queue to become pre-disabled.
Definition: intelxl.h:609
An Intel 40 Gigabit network card.
Definition: intelxl.h:909
#define INTELXL_PFINT_LNKLST0
PF Interrupt Zero Linked List Register.
Definition: intelxl.h:842
#define INTELXL_TX_DATA_JFDI
Transmit data descriptor pretty please.
Definition: intelxl.h:682
#define ETH_ALEN
Definition: if_ether.h:8
uint16_t vsi
VSI switching element ID.
Definition: intelxl.h:261
union intelxl_admin_params params
Parameters.
Definition: intelxl.h:429
uint8_t connection
Connection type.
Definition: intelxl.h:223
A PCI device ID list entry.
Definition: pci.h:174
Version number.
#define le16_to_cpu(value)
Definition: byteswap.h:112
unsigned int uint32_t
Definition: stdint.h:12
static void intelxl_init_ring(struct intelxl_ring *ring, unsigned int count, size_t len, int(*context)(struct intelxl_nic *intelxl, physaddr_t address))
Initialise descriptor ring.
Definition: intelxl.h:795
void * dma_alloc(struct dma_device *dma, struct dma_mapping *map, size_t len, size_t align)
Allocate and map DMA-coherent buffer.
uint32_t next
Next descriptor address.
Definition: dwmac.h:22
#define INTELXL_ADMIN_LEN_LEN(x)
Queue length.
Definition: intelxl.h:49
static int is_valid_ether_addr(const void *addr)
Check if Ethernet address is valid.
Definition: ethernet.h:77
uint32_t high
Buffer address high.
Definition: intelxl.h:81
struct intelxl_ring tx
Transmit descriptor ring.
Definition: intelxl.h:949
static void intelxl_close(struct net_device *netdev)
Close network device.
Definition: intelxl.c:1458
struct i386_regs regs
Definition: registers.h:15
static struct xen_remove_from_physmap * remove
Definition: xenmem.h:39
uint8_t unused
Unused.
Definition: librm.h:140
#define PCI_CAP_ID_EXP
PCI Express.
Definition: pci.h:97
int intelxl_admin_command(struct intelxl_nic *intelxl)
Issue admin queue command.
Definition: intelxl.c:277
struct pci_driver intelxl_driver __pci_driver
PCI driver.
Definition: intelxl.c:1882
Network device operations.
Definition: netdevice.h:213
#define INTELXL_MSIX_VECTOR
MSI-X interrupt vector.
Definition: intelxl.h:906
uint16_t vsi
VSI switching element ID.
Definition: intelxl.h:292
struct device * dev
Underlying hardware device.
Definition: netdevice.h:364
static int intelxl_admin_version(struct intelxl_nic *intelxl)
Get firmware version.
Definition: intelxl.c:387
Admin queue Set VSI Promiscuous Modes command parameters.
Definition: intelxl.h:286
#define INTELXL_CTX_TX_BASE(base)
Transmit queue base address.
Definition: intelxl.h:558
#define INTELXL_CTX_RX_FL_CRCSTRIP
Strip CRC from received packets.
Definition: intelxl.h:597
#define INTELXL_ADMIN_MAC_CONFIG
Admin queue Set MAC Configuration command.
Definition: intelxl.h:310
Network device management.
unsigned long physaddr_t
Definition: stdint.h:20
#define INTELXL_QINT_TQCTL(x)
Transmit Queue Interrupt Cause Control Register.
Definition: intelxl.h:873
static void * pci_get_drvdata(struct pci_device *pci)
Get PCI driver-private data.
Definition: pci.h:375
const int product_major_version
Product major version.
Definition: version.c:64
#define INTELXL_TX_WB_FL_DD
Transmit writeback descriptor complete.
Definition: intelxl.h:698
unsigned int pf
Physical function number.
Definition: intelxl.h:918
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition: timer.c:78
static uint16_t struct vmbus_xfer_pages_operations * op
Definition: netvsc.h:327
Admin queue descriptor.
Definition: intelxl.h:415
#define ENXIO
No such device or address.
Definition: errno.h:599
uint32_t low
Buffer address low.
Definition: intelxl.h:83
uint16_t uplink
Uplink switching element ID.
Definition: intelxl.h:217
static int intelxl_admin_mac_write(struct net_device *netdev)
Set MAC address.
Definition: intelxl.c:526
#define INTELXL_ADMIN_TAIL
Admin Queue Tail Register (offset)
Definition: intelxl.h:56
uint16_t mfs
Maximum frame size.
Definition: intelxl.h:315
#define INTELXL_QXX_TAIL
Queue Tail Pointer Register (offset)
Definition: intelxl.h:653
#define INTELXL_RX_WB_LEN(len)
Receive writeback descriptor length.
Definition: intelxl.h:744
__weak void vlan_netdev_rx(struct net_device *netdev, unsigned int tag, struct io_buffer *iobuf)
Add VLAN tag-stripped packet to queue (when VLAN support is not present)
Definition: netdevice.c:1209
#define INTELXL_GLLAN_TXPRE_QDIS_SET_QDIS
Set disable.
Definition: intelxl.h:629
void free_rx_iob(struct io_buffer *iobuf)
Unmap and free I/O buffer for receive DMA.
Definition: iobuf.c:214
static int intelxl_probe(struct pci_device *pci)
Probe PCI device.
Definition: intelxl.c:1666
#define ENOBUFS
No buffer space available.
Definition: errno.h:498
#define INTELXL_QUEUE_ENABLE_DELAY_US
Time to wait for a queue to become enabled.
Definition: intelxl.h:606
#define DBGC2(...)
Definition: compiler.h:522
int(* probe)(struct pci_device *pci)
Probe device.
Definition: pci.h:264
struct pci_msix msix
MSI-X interrupt.
Definition: intelxl.h:938
#define INTELXL_ADMIN_LINK_UP
Link is up.
Definition: intelxl.h:365
Admin queue Manage MAC Address Write command parameters.
Definition: intelxl.h:178
void * data
Start of data.
Definition: iobuf.h:52
#define INTELXL_ADMIN_LINK_NOTIFY
Notify driver of link status changes.
Definition: intelxl.h:362
#define INTELXL_PFINT_LNKLST0_FIRSTQ_INDX(x)
Queue index.
Definition: intelxl.h:843
static int intelxl_context_line(struct intelxl_nic *intelxl, struct intelxl_context_line *line, unsigned int index, uint32_t op)
Program queue context line.
Definition: intelxl.c:1069
int pci_msix_enable(struct pci_device *pci, struct pci_msix *msix)
Enable MSI-X interrupts.
Definition: pcimsix.c:136
#define EIO
Input/output error.
Definition: errno.h:433
#define INTELXL_PFCM_LANCTXSTAT_DONE
Complete.
Definition: intelxl.h:526
__weak void vlan_netdev_rx_err(struct net_device *netdev, unsigned int tag __unused, struct io_buffer *iobuf, int rc)
Discard received VLAN tag-stripped packet (when VLAN support is not present)
Definition: netdevice.c:1227
struct net_device * alloc_etherdev(size_t priv_size)
Allocate Ethernet device.
Definition: ethernet.c:264
u8 rx[WPA_TKIP_MIC_KEY_LEN]
MIC key for packets from the AP.
Definition: wpa.h:234
#define INTELXL_GLLAN_TXPRE_QDIS_CLEAR_QDIS
Clear disable.
Definition: intelxl.h:631
#define cpu_to_le16(value)
Definition: byteswap.h:106
#define INTELXL_ADMIN_PROMISC_FL_BROADCAST
Promiscuous broadcast mode.
Definition: intelxl.h:304
unsigned int base
Absolute queue number base.
Definition: intelxl.h:920
void iounmap(volatile const void *io_addr)
Unmap I/O address.
Descriptor ring.
Definition: intelxl.h:755
Virtual LANs.
struct intelxl_admin_switch_config cfg
Switch configuration.
Definition: intelxl.h:252
unsigned int tail
Tail register.
Definition: intelxl.h:775
Receive writeback descriptor.
Definition: intelxl.h:719
unsigned int tail
Tail Register offset.
Definition: intelxl.h:73
__be32 raw[7]
Definition: CIB_PRM.h:28
#define INTELXL_ADMIN_AUTONEG_FL_ENABLE
Enable link.
Definition: intelxl.h:340
#define INTELXL_QINT_RQCTL(x)
Receive Queue Interrupt Cause Control Register.
Definition: intelxl.h:861
struct intelxl_admin_buffer_params buffer
Additional data buffer command parameters.
Definition: intelxl.h:370
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.
Definition: vsprintf.c:382
const struct intelxl_admin_offsets * regs
Register offsets.
Definition: intelxl.h:464
void intelxl_reopen_admin(struct intelxl_nic *intelxl)
Reopen admin queues (after virtual function reset)
Definition: intelxl.c:906
#define INTELXL_ADMIN_MAC_CONFIG_FL_CRC
Append CRC on transmit.
Definition: intelxl.h:323
#define INTELXL_BAR_SIZE
BAR size.
Definition: intelxl.h:20
Admin queue Get Switch Configuration command parameters.
Definition: intelxl.h:234
#define INTELXL_ADMIN_SHUTDOWN_UNLOADING
Driver is unloading.
Definition: intelxl.h:146
uint16_t valid
Valid flags.
Definition: intelxl.h:290
static int intelxl_admin_vsi(struct intelxl_nic *intelxl)
Get VSI parameters.
Definition: intelxl.c:646
void shutdown(int flags)
Shut down iPXE.
Definition: init.c:100
struct intelxl_tx_writeback_descriptor wb
Transmit writeback descriptor.
Definition: intelxl.h:705
#define INTELXL_ADMIN_PROMISC_FL_UNICAST
Promiscuous unicast mode.
Definition: intelxl.h:298
const char product_name[]
Product name string.
Definition: version.c:73
#define DBG_EXTRA
Definition: compiler.h:319
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
Definition: netdevice.h:387
size_t max_pkt_len
Maximum packet length.
Definition: netdevice.h:409
static struct net_device_operations intelxl_operations
Network device operations.
Definition: intelxl.c:1646
void intelxl_close_admin(struct intelxl_nic *intelxl)
Close admin queues.
Definition: intelxl.c:928
#define INTELXL_ADMIN_DRIVER
Admin queue Driver Version command.
Definition: intelxl.h:110
#define INTELXL_PFFUNC_RID_FUNC_NUM(x)
Function number.
Definition: intelxl.h:886
#define INTELXL_CTX_TX_COUNT(count)
Transmit queue count.
Definition: intelxl.h:561
#define INTELXL_ADMIN_SWITCH_TYPE_VSI
Virtual Station Inferface element type.
Definition: intelxl.h:231
#define INTELXL_RX_FILL
Receive descriptor ring fill level.
Definition: intelxl.h:823
void * pci_ioremap(struct pci_device *pci, unsigned long bus_addr, size_t len)
Map PCI bus address as an I/O address.
static int intelxl_admin_link(struct net_device *netdev)
Get link status.
Definition: intelxl.c:761
static int intelxl_admin_driver(struct intelxl_nic *intelxl)
Report driver version.
Definition: intelxl.c:423
uint64_t tag
Identity tag.
Definition: edd.h:30
uint16_t queue
Queue ID.
Definition: ena.h:22
Transmit queue context.
Definition: intelxl.h:535
#define INTELXL_ADMIN_CLEAR_PXE
Admin queue Clear PXE Mode command.
Definition: intelxl.h:192
#define INTELXL_CTX_MAX_WAIT_MS
Maximum time to wait for a context operation to complete.
Definition: intelxl.h:603
uint16_t seid
Switching element ID.
Definition: intelxl.h:215
#define INTELXL_RX_WB_FL_RXE
Receive writeback descriptor error.
Definition: intelxl.h:741
#define INTELXL_ADMIN_FL_RD
Admin descriptor uses data buffer for command parameters.
Definition: intelxl.h:442
#define INTELXL_CTX_RX_BASE_COUNT(base, count)
Receive queue base address and queue count.
Definition: intelxl.h:587
static void intelxl_remove(struct pci_device *pci)
Remove PCI device.
Definition: intelxl.c:1831
uint8_t hw_addr[MAX_HW_ADDR_LEN]
Hardware address.
Definition: netdevice.h:381
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29
#define INTELXL_ADMIN_MAX_WAIT_MS
Maximum time to wait for an admin request to complete.
Definition: intelxl.h:486
#define INTELXL_ADMIN_LEN
Admin Queue Length Register (offset)
Definition: intelxl.h:48
#define INTELXL_ADMIN_PROMISC_FL_MULTICAST
Promiscuous multicast mode.
Definition: intelxl.h:301
struct intelxl_admin event
Admin event queue.
Definition: intelxl.h:943
#define INTELXL_QXX_CTL
Queue Control Register (offset)
Definition: intelxl.h:646
#define ETIMEDOUT
Connection timed out.
Definition: errno.h:669
#define INTELXL_QTX_HEAD(x)
Global Transmit Queue Head register.
Definition: intelxl.h:622
String functions.
#define INTELXL_ADMIN_FL_DD
Admin descriptor done.
Definition: intelxl.h:433
#define PCI_ROM(_vendor, _device, _name, _description, _data)
Definition: pci.h:307
#define INTELXL_PFCM_LANCTXCTL
CMLAN Context Control Register.
Definition: intelxl.h:502
const int product_minor_version
Product minor version.
Definition: version.c:67
void intelxl_empty_rx(struct intelxl_nic *intelxl)
Discard unused receive I/O buffers.
Definition: intelxl.c:1366
physaddr_t dma(struct dma_mapping *map, void *addr)
Get DMA address from virtual address.
#define INTELXL_TX_FILL
Transmit descriptor ring maximum fill level.
Definition: intelxl.h:811
#define INTELXL_ADMIN_HEAD
Admin Queue Head Register (offset)
Definition: intelxl.h:53
int intelxl_admin_mac_config(struct intelxl_nic *intelxl)
Set MAC configuration.
Definition: intelxl.c:711
#define INTELXL_PFCM_LANCTXDATA(x)
CMLAN Context Data Register.
Definition: intelxl.h:499
void intelxl_poll(struct net_device *netdev)
Poll for completed and received packets.
Definition: intelxl.c:1612
int intelxl_alloc_ring(struct intelxl_nic *intelxl, struct intelxl_ring *ring)
Allocate descriptor ring.
Definition: intelxl.c:956
Admin queue data buffer.
Definition: intelxl.h:401
#define INTELXL_RX_WB_FL_VLAN
Receive writeback descriptor VLAN tag present.
Definition: intelxl.h:738
struct intelxl_rx_data_descriptor data
Receive data descriptor.
Definition: intelxl.h:749
u8 tx[WPA_TKIP_MIC_KEY_LEN]
MIC key for packets to the AP.
Definition: wpa.h:237
static void intelxl_poll_rx(struct net_device *netdev)
Poll for received packets.
Definition: intelxl.c:1560
void * memset(void *dest, int character, size_t len) __nonnull
int intelxl_msix_enable(struct intelxl_nic *intelxl, struct pci_device *pci, unsigned int vector)
Enable MSI-X dummy interrupt.
Definition: intelxl.c:62
A persistent I/O buffer.
Definition: iobuf.h:37
#define INTELXL_PFCM_LANCTXCTL_OP_CODE_READ
Read context.
Definition: intelxl.h:519