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;
853 abort_with_registered_netdev:
855 abort_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 );
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, );
1150 abort_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 ) ,
static int mac_address_from_string_specs(struct pci_device *pci, unsigned int vs, uint8 mac[ETH_ALEN])
unsigned long membase
Memory base.
#define MYRI10GE_RECEIVE_WRAP
struct arbelprm_rc_send_wqe rc
static void netdev_tx_complete(struct net_device *netdev, struct io_buffer *iobuf)
Complete network transmission.
#define iob_put(iobuf, len)
static void myri10ge_net_irq(struct net_device *, int enable)
unsigned long strtoul(const char *string, char **endp, int base)
Convert string to numeric value.
static int myri10ge_net_transmit(struct net_device *, struct io_buffer *)
int(* open)(struct net_device *netdev)
Open network device.
#define MYRI10GE_RECEIVE_COMPLETION_WRAP
uint32 transmit_ring_wrap
static int myri10ge_command(struct myri10ge_private *priv, uint32 cmd, uint32 data[3])
static void myri10ge_net_poll(struct net_device *)
struct golan_inbox_hdr hdr
Message header.
unsigned int receives_done
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
A non-volatile storage device.
struct pci_device_id * ids
PCI ID table.
int register_nvo(struct nvo_block *nvo, struct settings *parent)
Register non-volatile stored options.
int pci_write_config_word(struct pci_device *pci, unsigned int where, uint16_t value)
Write 16-bit word to PCI configuration space.
#define PCI_COMMAND_INTX_DISABLE
Interrupt disable.
#define PCI_CAP_ID_VNDR
Vendor-specific.
static void *__malloc malloc_phys(size_t size, size_t phys_align)
Allocate memory with specified physical alignment.
int pci_read_config_word(struct pci_device *pci, unsigned int where, uint16_t *value)
Read 16-bit word from PCI configuration space.
unsigned int nvo_registered
void netdev_link_down(struct net_device *netdev)
Mark network device as having link down.
#define PCI_COMMAND
PCI command.
struct io_buffer * transmit_iob[1+MYRI10GE_TRANSMIT_WRAP]
static struct myri10ge_private * myri10ge_priv(struct net_device *nd)
uint8_t mac[ETH_ALEN]
MAC address.
#define VS_EEPROM_READ_DATA
void adjust_pci_device(struct pci_device *pci)
Enable PCI device.
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
unsigned int receives_posted
struct device dev
Generic device.
static struct settings * netdev_settings(struct net_device *netdev)
Get per-netdevice configuration settings block.
#define ENOTSUP
Operation not supported.
Dynamic memory allocation.
static void netdev_init(struct net_device *netdev, struct net_device_operations *op)
Initialise a network device.
static __always_inline void * phys_to_virt(unsigned long phys_addr)
Convert physical address to a virtual address.
static void pci_set_drvdata(struct pci_device *pci, void *priv)
Set PCI driver-private data.
#define ENOMEM
Not enough space.
struct mcp_dma_addr mcp_dma_addr_t
void * memcpy(void *dest, const void *src, size_t len) __nonnull
mcp_kreq_ether_recv_t * receive_post_ring
u32 version
Driver version.
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
#define container_of(ptr, type, field)
Get containing structure.
int pci_read_config_dword(struct pci_device *pci, unsigned int where, uint32_t *value)
Read 32-bit dword from PCI configuration space.
mcp_kreq_ether_send_t * transmit_ring
#define VS_EEPROM_READ_ADDR
static void netdev_link_up(struct net_device *netdev)
Mark network device as having link up.
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
static struct net_device * netdev
void unregister_netdev(struct net_device *netdev)
Unregister network device.
void unregister_nvo(struct nvo_block *nvo)
Unregister non-volatile stored options.
#define EPROTO
Protocol error.
unsigned int receive_post_ring_wrap
#define MXGEFW_FLAGS_FIRST
Non-volatile stored options.
char * strerror(int errno)
Retrieve string representation of error number.
A block of non-volatile stored options.
int pci_write_config_byte(struct pci_device *pci, unsigned int where, uint8_t value)
Write byte to PCI configuration space.
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.
int register_netdev(struct net_device *netdev)
Register network device.
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
static struct net_device * myri10ge_netdev(struct myri10ge_private *p)
#define TRY(prefix, base, suffix)
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
static int myri10ge_nv_init(struct myri10ge_private *priv)
#define MXGEFW_CMD_SET_INTRQ_SIZE_FLAG_NO_STRICT_SIZE_CHECK
static struct pci_device_id myri10ge_nics[]
A PCI device ID list entry.
static void myri10ge_pci_remove(struct pci_device *)
static struct xen_remove_from_physmap * remove
static struct pci_device * myri10ge_pcidev(struct net_device *netdev)
Network device operations.
void netdev_rx(struct net_device *netdev, struct io_buffer *iobuf)
Add packet to receive queue.
struct device * dev
Underlying hardware device.
static void myri10ge_net_close(struct net_device *)
Network device management.
static void * pci_get_drvdata(struct pci_device *pci)
Get PCI driver-private data.
#define iob_reserve(iobuf, len)
void myri10ge_nv_fini(struct myri10ge_private *priv)
struct pci_driver myri10ge_driver __pci_driver
struct io_buffer * receive_iob[1+MYRI10GE_RECEIVE_WRAP]
#define ENOBUFS
No buffer space available.
static struct tlan_private * priv
int(* probe)(struct pci_device *pci)
Probe device.
mcp_cmd_response_t command_response
void * data
Start of data.
#define EIO
Input/output error.
struct net_device * alloc_etherdev(size_t priv_size)
Allocate Ethernet device.
u8 request[0]
List of IEs requested.
static int myri10ge_nvs_write(struct nvs_device *nvs, unsigned int addr, const void *_buf, size_t len)
int pci_write_config_dword(struct pci_device *pci, unsigned int where, uint32_t value)
Write 32-bit dword to PCI configuration space.
#define MXGEFW_FLAGS_NO_TSO
uint8_t data[48]
Additional event data.
static void free_phys(void *ptr, size_t size)
Free memory allocated with malloc_phys()
struct myri10ge_dma_buffers * dma
void mb(void)
Memory barrier.
static void myri10ge_interrupt_handler(struct net_device *netdev)
static int myri10ge_pci_probe(struct pci_device *)
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
#define DBG(...)
Print a debugging message.
static __always_inline physaddr_t dma(struct dma_mapping *map, void *addr)
Get DMA address from virtual address.
static int myri10ge_net_open(struct net_device *)
static int myri10ge_nvs_read(struct nvs_device *nvs, unsigned int addr, void *_buf, size_t len)
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
uint8_t hw_addr[MAX_HW_ADDR_LEN]
Hardware address.
#define NULL
NULL pointer (VOID *)
static void myri10ge_post_receive(struct myri10ge_private *priv, struct io_buffer *iob)
#define ETIMEDOUT
Connection timed out.
#define PCI_ROM(_vendor, _device, _name, _description, _data)
void iob_pad(struct io_buffer *iobuf, size_t min_len)
Pad I/O buffer.
#define VS_MODE_EEPROM_STREAM_WRITE
#define MYRI10GE_TRANSMIT_WRAP
struct mcp_kreq_ether_send mcp_kreq_ether_send_t
#define VS_LOCATE_STRING_SPECS
void * memset(void *dest, int character, size_t len) __nonnull
mcp_slot_t receive_completion[1+MYRI10GE_RECEIVE_COMPLETION_WRAP]
int pci_read_config_byte(struct pci_device *pci, unsigned int where, uint8_t *value)
Read byte from PCI configuration space.
#define MXGEFW_FLAGS_SMALL