115#define MYRI10GE_TRANSMIT_WRAP 1U
116#define MYRI10GE_RECEIVE_WRAP 7U
117#define MYRI10GE_RECEIVE_COMPLETION_WRAP 31U
201#define DBG2_RINGS( priv ) \
202 DBG2 ( "tx %x/%x rx %x/%x in %s() \n", \
203 ( priv ) ->transmits_done, ( priv ) -> transmits_posted, \
204 ( priv ) ->receives_done, ( priv ) -> receives_posted, \
254 unsigned int receives_posted;
260 receives_posted =
priv->receives_posted;
266 &
priv->receive_post_ring_wrap];
270 priv->receives_posted = ++receives_posted;
288 unsigned int slept_ms;
291 DBGP (
"myri10ge_command ( ,%d, ) \n",
cmd );
293 response = &
priv->dma->command_response;
297 response->
result = 0xFFFFFFFF;
305 command->response_addr.high = 0;
308 for ( i=0; i<9; i++ )
315 for ( slept_ms=0; slept_ms<2000; slept_ms++ ) {
320 }
else if (
result != 0xFFFFFFFF ) {
321 DBG (
"cmd%d:0x%x\n",
329 DBG (
"cmd%d:timed out\n",
cmd );
347 irq_data = &
priv->dma->irq_data;
352 valid = irq_data->
valid;
360 *
priv->irq_deassert = 0;
378 unsigned int nic_done_count;
381 nic_done_count =
ntohl (
priv->dma->irq_data.send_done_count );
382 while (
priv->transmits_done != nic_done_count ) {
385 iob =
priv->transmit_iob [
priv->transmits_done
389 ++
priv->transmits_done;
414 }
while ( irq_data->
valid );
426#define VS_EEPROM_READ_ADDR ( vs + 0x04 )
427#define VS_EEPROM_READ_DATA ( vs + 0x08 )
428#define VS_EEPROM_WRITE ( vs + 0x0C )
429#define VS_ADDR ( vs + 0x18 )
430#define VS_DATA ( vs + 0x14 )
431#define VS_MODE ( vs + 0x10 )
432#define VS_MODE_READ32 0x3
433#define VS_MODE_LOCATE 0x8
434#define VS_LOCATE_STRING_SPECS 0x3
435#define VS_MODE_EEPROM_STREAM_WRITE 0xB
451 char string_specs[256];
453 char *to = string_specs;
468 if (
len >
sizeof ( string_specs ) || (
len & 3 ) ) {
470 DBG (
"SS too big\n" );
490 DBG2 (
"STRING_SPECS:\n" );
492 limit = string_specs +
sizeof ( string_specs );
493 while ( *ptr !=
'\0' && ptr <
limit ) {
494 DBG2 (
"%s\n", ptr );
495 if (
memcmp ( ptr,
"MAC=", 4 ) == 0 ) {
499 for ( i=0; i<6; i++ ) {
500 if ( ( ptr + 2 ) >
limit ) {
501 DBG (
"bad MAC addr\n" );
510 while ( ptr <
limit && *ptr++ );
516 DBG (
"no MAC addr\n" );
520 DBG2 (
"MAC %02x:%02x:%02x:%02x:%02x:%02x\n",
547 unsigned int vs =
priv->pci_cap_vs;
548 unsigned char *buf = (
unsigned char *) _buf;
552 DBGP (
"myri10ge_nvs_read\n" );
563 for ( i=0; i<
len; ++i,
addr++ ) {
569 if ( (
addr & 0xff ) == 0 ) {
570 if ( (
addr & 0xffff ) == 0 ) {
583 if ( ( i & 3 ) == 3 ) {
587 for ( j=0; j<4; j++ ) {
596 if ( ( i & 3 ) != 0 ) {
598 for ( j=1; j<=(i&3); j++ ) {
625 unsigned int vs =
priv->pci_cap_vs;
626 const unsigned char *buf = (
const unsigned char *)_buf;
630 DBGP (
"nvs_write " );
642 while ( verify != 0xff ) {
671 struct myri10ge_eeprom_header
675 uint32 eeprom_segment_len;
681 unsigned int nvo_fragment_pos;
683 DBGP (
"myri10ge_nv_init\n" );
690 DBG (
"EEPROM header unreadable\n" );
694 hdr.eeprom_segment_len =
ntohl (
hdr.eeprom_segment_len );
697 DBG2 (
"eelen:%xh seglen:%xh mcp2@%xh ver%d\n",
hdr.eeprom_len,
698 hdr.eeprom_segment_len,
hdr.mcp2_offset,
hdr.version );
702 if (
hdr.version < 1 ) {
703 DBG (
"No EEPROM write support\n" );
710 mcp2_len =
ntohl ( mcp2_len );
711 DBG2 (
"mcp2len:%xh\n", mcp2_len );
716 nvo_fragment_pos =
hdr.eeprom_len -
hdr.eeprom_segment_len;
717 if (
hdr.mcp2_offset + mcp2_len > nvo_fragment_pos ) {
718 DBG (
"EEPROM full\n" );
724 priv->nvs.word_len_log2 = 0;
725 priv->nvs.size =
hdr.eeprom_len;
726 priv->nvs.block_size =
hdr.eeprom_segment_len;
734 nvo_fragment_pos, 0x200,
740 DBG (
"register_nvo failed");
744 priv->nvo_registered = 1;
745 DBG2 (
"NVO supported\n" );
754 if ( 0 ==
priv->nvo_registered )
789 DBGP (
"myri10ge_pci_probe: " );
794 dbg =
"alloc_etherdev";
795 goto abort_with_nothing;
811 if ( 0 ==
priv->pci_cap_vs ) {
814 goto abort_with_netdev_init;
824 goto abort_with_netdev_init;
837 dbg =
"register_netdev";
838 goto abort_with_netdev_init;
845 dbg =
"myri10ge_nv_init";
846 goto abort_with_registered_netdev;
853abort_with_registered_netdev:
855abort_with_netdev_init:
874 DBGP (
"myri10ge_pci_remove\n" );
899 DBGP (
"myri10ge_net_close\n" );
913 while (
priv->receives_done !=
priv->receives_posted ) {
916 ++
priv->receives_done;
943 DBGP (
"myri10ge_net_irq\n" );
976 DBGP (
"myri10ge_net_open\n" );
995 goto abort_with_nothing;
1001#define TRY( prefix, base, suffix ) do { \
1002 rc = myri10ge_command ( priv, \
1010 goto abort_with_dma; \
1023 TRY ( CMD_SET_ , INTRQ_SIZE , );
1029 TRY ( CMD_SET_, INTRQ_DMA, );
1033 TRY ( CMD_GET_, IRQ_ACK, _OFFSET );
1038 TRY ( CMD_GET_, IRQ_DEASSERT, _OFFSET );
1044 TRY ( CMD_GET_, INTR_COAL, _DELAY_OFFSET );
1050 |
netdev->ll_addr[1] << 16
1051 |
netdev->ll_addr[2] << 8
1060 TRY ( ENABLE_ , ALLMULTI , );
1065 TRY ( DISABLE_ , FLOW , _CONTROL );
1070 TRY ( CMD_GET_, SEND_RING, _SIZE );
1071 priv->transmit_ring_wrap
1073 if (
priv->transmit_ring_wrap
1074 & (
priv->transmit_ring_wrap + 1 ) ) {
1077 goto abort_with_dma;
1083 TRY ( CMD_GET_ , RX_RING , _SIZE );
1085 if (
priv->receive_post_ring_wrap
1086 & (
priv->receive_post_ring_wrap + 1 ) ) {
1089 goto abort_with_dma;
1095 TRY ( CMD_GET_, SEND, _OFFSET );
1101 TRY ( CMD_GET_, SMALL_RX, _OFFSET );
1107 TRY ( CMD_SET_, MTU, );
1114 TRY ( CMD_SET_, SMALL_BUFFER, _SIZE );
1116 TRY ( CMD_SET_, BIG_BUFFER, _SIZE );
1122 data[2] =
sizeof (
priv->dma->irq_data );
1123 TRY ( CMD_SET_, STATS_DMA_V2, );
1137 goto abort_with_receives_posted;
1145 TRY ( CMD_, ETHERNET_UP, );
1150abort_with_receives_posted:
1151 while (
priv->receives_posted-- )
1179 unsigned int orig_receives_posted;
1181 DBGP (
"myri10ge_net_poll\n" );
1193 orig_receives_posted =
priv->receives_posted;
1194 while (
priv->receives_done != orig_receives_posted ) {
1199 [
priv->receives_done
1214 DBG (
"NO RX BUF\n" );
1221 iob =
priv->receive_iob[
priv->receives_done
1229 dma->receive_completion [
priv->receives_done
1237 ++
priv->receives_done;
1259 DBGP (
"myri10ge_net_transmit\n" );
1267 DBG (
"TX ring full\n" );
1293 &
priv->transmit_ring_wrap];
1320 PCI_ROM ( 0x14c1, 0x0008,
"myri10ge",
"Myricom 10Gb Ethernet Adapter", 0 ) ,
#define NULL
NULL pointer (VOID *)
struct golan_inbox_hdr hdr
Message header.
struct arbelprm_rc_send_wqe rc
u32 version
Driver version.
uint32_t addr
Buffer address.
uint8_t data[48]
Additional event data.
uint8_t mac[ETH_ALEN]
MAC address.
struct net_device * alloc_etherdev(size_t priv_size)
Allocate Ethernet device.
static struct net_device * netdev
#define DBG(...)
Print a debugging message.
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
#define ETIMEDOUT
Connection timed out.
#define EPROTO
Protocol error.
#define ENOMEM
Not enough space.
#define EIO
Input/output error.
#define ENOTSUP
Operation not supported.
#define ENOBUFS
No buffer space available.
u8 request[0]
List of IEs requested.
void mb(void)
Memory barrier.
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
int pci_read_config_dword(struct pci_device *pci, unsigned int where, uint32_t *value)
Read 32-bit dword from PCI configuration space.
int pci_read_config_word(struct pci_device *pci, unsigned int where, uint16_t *value)
Read 16-bit word from PCI configuration space.
int pci_write_config_byte(struct pci_device *pci, unsigned int where, uint8_t value)
Write byte to PCI configuration space.
int pci_write_config_word(struct pci_device *pci, unsigned int where, uint16_t value)
Write 16-bit word to PCI configuration space.
int pci_read_config_byte(struct pci_device *pci, unsigned int where, uint8_t *value)
Read byte from PCI configuration space.
int pci_write_config_dword(struct pci_device *pci, unsigned int where, uint32_t value)
Write 32-bit dword to PCI configuration space.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
void * memset(void *dest, int character, size_t len) __nonnull
void iob_pad(struct io_buffer *iobuf, size_t min_len)
Pad I/O buffer.
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
#define iob_put(iobuf, len)
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
#define iob_reserve(iobuf, len)
physaddr_t dma(struct dma_mapping *map, void *addr)
Get DMA address from virtual address.
void * malloc_phys(size_t size, size_t phys_align)
Allocate memory with specified physical alignment.
void free_phys(void *ptr, size_t size)
Free memory allocated with malloc_phys()
Dynamic memory allocation.
static void myri10ge_net_poll(struct net_device *)
static int myri10ge_nvs_write(struct nvs_device *nvs, unsigned int addr, const void *_buf, size_t len)
#define VS_EEPROM_READ_DATA
static struct pci_device * myri10ge_pcidev(struct net_device *netdev)
static void myri10ge_net_irq(struct net_device *, int enable)
static int myri10ge_nv_init(struct myri10ge_private *priv)
void myri10ge_nv_fini(struct myri10ge_private *priv)
static int myri10ge_net_transmit(struct net_device *, struct io_buffer *)
static int mac_address_from_string_specs(struct pci_device *pci, unsigned int vs, uint8 mac[ETH_ALEN])
#define MYRI10GE_RECEIVE_COMPLETION_WRAP
static struct myri10ge_private * myri10ge_priv(struct net_device *nd)
static void myri10ge_pci_remove(struct pci_device *)
static void myri10ge_net_close(struct net_device *)
static void myri10ge_interrupt_handler(struct net_device *netdev)
#define MYRI10GE_RECEIVE_WRAP
#define MYRI10GE_TRANSMIT_WRAP
#define TRY(prefix, base, suffix)
static int myri10ge_pci_probe(struct pci_device *)
static int myri10ge_command(struct myri10ge_private *priv, uint32 cmd, uint32 data[3])
static int myri10ge_nvs_read(struct nvs_device *nvs, unsigned int addr, void *_buf, size_t len)
static struct net_device * myri10ge_netdev(struct myri10ge_private *p)
#define VS_EEPROM_READ_ADDR
#define VS_LOCATE_STRING_SPECS
static struct pci_device_id myri10ge_nics[]
#define VS_MODE_EEPROM_STREAM_WRITE
static void myri10ge_post_receive(struct myri10ge_private *priv, struct io_buffer *iob)
static int myri10ge_net_open(struct net_device *)
#define MXGEFW_CMD_SET_INTRQ_SIZE_FLAG_NO_STRICT_SIZE_CHECK
#define MXGEFW_FLAGS_FIRST
struct mcp_slot mcp_slot_t
#define MXGEFW_FLAGS_NO_TSO
struct mcp_dma_addr mcp_dma_addr_t
struct mcp_irq_data mcp_irq_data_t
struct mcp_kreq_ether_recv mcp_kreq_ether_recv_t
struct mcp_kreq_ether_send mcp_kreq_ether_send_t
struct mcp_cmd_response mcp_cmd_response_t
#define MXGEFW_FLAGS_SMALL
void netdev_link_down(struct net_device *netdev)
Mark network device as having link down.
void netdev_rx(struct net_device *netdev, struct io_buffer *iobuf)
Add packet to receive queue.
void unregister_netdev(struct net_device *netdev)
Unregister network device.
int register_netdev(struct net_device *netdev)
Register network device.
Network device management.
static void netdev_link_up(struct net_device *netdev)
Mark network device as having link up.
static void netdev_init(struct net_device *netdev, struct net_device_operations *op)
Initialise a network device.
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
static void netdev_tx_complete(struct net_device *netdev, struct io_buffer *iobuf)
Complete network transmission.
static struct settings * netdev_settings(struct net_device *netdev)
Get per-netdevice configuration settings block.
void nvo_init(struct nvo_block *nvo, struct nvs_device *nvs, size_t address, size_t len, int(*resize)(struct nvo_block *nvo, size_t len), struct refcnt *refcnt)
Initialise non-volatile stored options.
void unregister_nvo(struct nvo_block *nvo)
Unregister non-volatile stored options.
int register_nvo(struct nvo_block *nvo, struct settings *parent)
Register non-volatile stored options.
Non-volatile stored options.
void adjust_pci_device(struct pci_device *pci)
Enable PCI device.
#define PCI_CAP_ID_VNDR
Vendor-specific.
#define __pci_driver
Declare a PCI driver.
static void pci_set_drvdata(struct pci_device *pci, void *priv)
Set PCI driver-private data.
#define PCI_ROM(_vendor, _device, _name, _description, _data)
#define PCI_COMMAND_INTX_DISABLE
Interrupt disable.
static void * pci_get_drvdata(struct pci_device *pci)
Get PCI driver-private data.
#define PCI_COMMAND
PCI command.
#define container_of(ptr, type, field)
Get containing structure.
char * strerror(int errno)
Retrieve string representation of error number.
unsigned long strtoul(const char *string, char **endp, int base)
Convert string to numeric value.
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
void * data
Start of data.
mcp_slot_t receive_completion[1+MYRI10GE_RECEIVE_COMPLETION_WRAP]
mcp_cmd_response_t command_response
unsigned int receives_done
struct io_buffer * receive_iob[1+MYRI10GE_RECEIVE_WRAP]
unsigned int receives_posted
struct myri10ge_dma_buffers * dma
struct io_buffer * transmit_iob[1+MYRI10GE_TRANSMIT_WRAP]
mcp_kreq_ether_send_t * transmit_ring
unsigned int nvo_registered
uint32 transmit_ring_wrap
unsigned int receive_post_ring_wrap
mcp_kreq_ether_recv_t * receive_post_ring
Network device operations.
A block of non-volatile stored options.
A non-volatile storage device.
A PCI device ID list entry.
unsigned long membase
Memory base.
struct device dev
Generic device.
int(* probe)(struct pci_device *pci)
Probe device.
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
static struct tlan_private * priv
static struct xen_remove_from_physmap * remove