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