53 #define PHN_MAX_NUM_PORTS 8 69 #define PHN_CMDPEG_INIT_TIMEOUT_SEC 50 72 #define PHN_RCVPEG_INIT_TIMEOUT_SEC 2 75 #define PHN_ISSUE_CMD_TIMEOUT_MS 2000 78 #define PHN_TEST_MEM_TIMEOUT_MS 100 81 #define PHN_CLP_CMD_TIMEOUT_MS 500 87 #define PHN_LINK_POLL_FREQUENCY 4096 90 #define PHN_NUM_RDS 32 93 #define PHN_RDS_MAX_FILL 16 96 #define PHN_RX_BUFSIZE ( 32 + \ 100 #define PHN_NUM_SDS 32 103 #define PHN_NUM_CDS 8 242 unsigned long reg ) {
243 unsigned long offset = ( 0x6000000 + (
reg & 0x1ffffff ) );
254 assert ( verify_window == window );
271 unsigned long reg ) {
272 unsigned long offset = (
reg & 0x1ffffff );
283 assert ( verify_window == window );
300 unsigned long reg ) {
301 static const struct {
304 } reg_window_hi[] = {
321 for ( i = 0 ; i < (
sizeof ( reg_window_hi ) /
322 sizeof ( reg_window_hi[0] ) ) ; i++ ) {
327 window = ( ( reg_window_hi[i].window_hi << 20 ) |
328 (
offset & 0x000f0000 ) );
338 assert ( verify_window == window );
344 return ( 0x1e0000 + (
offset & 0xffff ) );
359 unsigned long reg ) {
374 unsigned long reg ) {
391 unsigned long lo_offset,
392 unsigned long hi_offset ) {
417 unsigned int retries;
437 DBGC ( phantom,
"Phantom %p timed out waiting for test memory\n",
455 static unsigned long cache_offset = -1UL;
456 unsigned long sub_offset;
459 sub_offset = (
offset & (
sizeof ( cache ) - 1 ) );
462 if ( cache_offset !=
offset ) {
464 cache.dwords )) !=0 )
469 return cache.bytes[sub_offset];
481 unsigned int max_lines ) {
496 DBGC ( phantom,
"Phantom %p firmware dmesg buffer %d (%08x-%08x)\n",
497 phantom, log,
head, tail );
500 DBGC ( phantom,
"Warning: bad signature %08x (want %08lx)\n",
509 if ( (
byte ==
'\n' ) && ( max_lines-- == 0 ) )
550 unsigned int retries;
570 DBGC ( phantom,
"Phantom %p timed out waiting for firmware to accept " 571 "command\n", phantom );
594 DBGC2 ( phantom,
"Phantom %p issuing command %08x (%08x, %08x, " 605 DBGC ( phantom,
"Phantom %p could not issue command: %s\n",
629 ( physaddr & 0xffffffffUL ),
len );
648 memset ( buf, 0,
sizeof ( *buf ) );
673 DBGC ( phantom,
"Phantom %p creating RX context\n", phantom );
681 sizeof ( buf->
hostrq ) ) ) != 0 ) {
682 DBGC ( phantom,
"Phantom %p could not create RX context: " 684 DBGC ( phantom,
"Request:\n" );
687 DBGC ( phantom,
"Response:\n" );
706 DBGC ( phantom,
"Phantom %p created RX context (id %04x, port phys " 711 DBGC ( phantom,
"Phantom %p RDS producer CRB is %08lx\n",
713 DBGC ( phantom,
"Phantom %p SDS consumer CRB is %08lx\n",
715 DBGC ( phantom,
"Phantom %p SDS interrupt mask CRB is %08lx\n",
732 DBGC ( phantom,
"Phantom %p destroying RX context (id %04x)\n",
740 DBGC ( phantom,
"Phantom %p could not destroy RX context: " 773 memset ( buf, 0,
sizeof ( *buf ) );
788 DBGC ( phantom,
"Phantom %p creating TX context\n", phantom );
796 sizeof ( buf->
hostrq ) ) ) != 0 ) {
797 DBGC ( phantom,
"Phantom %p could not create TX context: " 799 DBGC ( phantom,
"Request:\n" );
802 DBGC ( phantom,
"Response:\n" );
815 DBGC ( phantom,
"Phantom %p created TX context (id %04x, port phys " 820 DBGC ( phantom,
"Phantom %p CDS producer CRB is %08lx\n",
837 DBGC ( phantom,
"Phantom %p destroying TX context (id %04x)\n",
845 DBGC ( phantom,
"Phantom %p could not destroy TX context: " 873 unsigned int rds_producer_idx;
874 unsigned int next_rds_producer_idx;
883 next_rds_producer_idx = ( ( rds_producer_idx + 1 ) %
PHN_NUM_RDS );
885 DBGC ( phantom,
"Phantom %p RDS ring full (index %d not " 886 "consumed)\n", phantom, next_rds_producer_idx );
890 return rds_producer_idx;
901 unsigned int rds_producer_idx;
902 unsigned int next_rds_producer_idx;
907 entry = &phantom->
desc->
rds[rds_producer_idx];
908 memcpy ( entry, rds,
sizeof ( *entry ) );
909 DBGC2 ( phantom,
"Phantom %p posting RDS %ld (slot %d):\n",
914 next_rds_producer_idx = ( ( rds_producer_idx + 1 ) %
PHN_NUM_RDS );
928 unsigned int cds_producer_idx;
929 unsigned int next_cds_producer_idx;
936 next_cds_producer_idx = ( ( cds_producer_idx + 1 ) %
PHN_NUM_CDS );
938 DBGC ( phantom,
"Phantom %p CDS ring full (index %d not " 939 "consumed)\n", phantom, next_cds_producer_idx );
943 return cds_producer_idx;
954 unsigned int cds_producer_idx;
955 unsigned int next_cds_producer_idx;
960 entry = &phantom->
desc->
cds[cds_producer_idx];
961 memcpy ( entry, cds,
sizeof ( *entry ) );
962 DBGC2 ( phantom,
"Phantom %p posting CDS %d:\n",
963 phantom, cds_producer_idx );
967 next_cds_producer_idx = ( ( cds_producer_idx + 1 ) %
PHN_NUM_CDS );
1000 memset ( &cds, 0,
sizeof ( cds ) );
1005 nic_request.header.context_id, phantom->
port );
1007 nic_request.body.mac_request.opcode,
opcode,
1008 nic_request.body.mac_request.mac_addr_0, ll_addr[0],
1009 nic_request.body.mac_request.mac_addr_1, ll_addr[1],
1010 nic_request.body.mac_request.mac_addr_2, ll_addr[2],
1011 nic_request.body.mac_request.mac_addr_3, ll_addr[3],
1012 nic_request.body.mac_request.mac_addr_4, ll_addr[4],
1013 nic_request.body.mac_request.mac_addr_5, ll_addr[5] );
1031 DBGC ( phantom,
"Phantom %p adding MAC address %s\n",
1047 DBGC ( phantom,
"Phantom %p removing MAC address %s\n",
1077 DBGC ( phantom,
"Phantom %p new link state %08x (was %08x)\n",
1086 DBGC ( phantom,
"Phantom %p link is up\n", phantom );
1090 DBGC ( phantom,
"Phantom %p link is down\n", phantom );
1094 DBGC ( phantom,
"Phantom %p bad link state %d\n",
1140 memset ( &rds, 0,
sizeof ( rds ) );
1169 if ( ! phantom->
desc ) {
1171 goto err_alloc_desc;
1177 goto err_create_rx_ctx;
1181 goto err_create_tx_ctx;
1196 goto err_add_macaddr_broadcast;
1199 goto err_add_macaddr_unicast;
1204 err_add_macaddr_unicast:
1206 err_add_macaddr_broadcast:
1271 memset ( &cds, 0,
sizeof ( cds ) );
1278 tx.context_id, phantom->
port );
1302 unsigned int irq_vector;
1303 unsigned int irq_state;
1304 unsigned int cds_consumer_idx;
1305 unsigned int raw_new_cds_consumer_idx;
1306 unsigned int new_cds_consumer_idx;
1307 unsigned int rds_consumer_idx;
1308 unsigned int sds_consumer_idx;
1310 unsigned int sds_handle;
1311 unsigned int sds_opcode;
1342 new_cds_consumer_idx =
le32_to_cpu ( raw_new_cds_consumer_idx );
1343 while ( cds_consumer_idx != new_cds_consumer_idx ) {
1344 DBGC2 ( phantom,
"Phantom %p CDS %d complete\n",
1345 phantom, cds_consumer_idx );
1349 if ( ( iobuf = phantom->
cds_iobuf[cds_consumer_idx] ) ) {
1353 cds_consumer_idx = ( ( cds_consumer_idx + 1 ) %
PHN_NUM_CDS );
1361 sds = &phantom->
desc->
sds[sds_consumer_idx];
1365 DBGC2 ( phantom,
"Phantom %p SDS %d status:\n",
1366 phantom, sds_consumer_idx );
1377 if (
NX_GET ( sds, total_length ) == 0 ) {
1378 DBGC ( phantom,
"Phantom %p SDS %d " 1379 "incomplete; deferring\n",
1380 phantom, sds_consumer_idx );
1391 DBGC2 ( phantom,
"Phantom %p RDS %d complete\n",
1392 phantom, sds_handle );
1409 DBGC ( phantom,
"Phantom %p unexpected SDS opcode " 1410 "%02x\n", phantom, sds_opcode );
1412 sds,
sizeof ( *sds ) );
1416 memset ( sds, 0,
sizeof ( *sds ) );
1419 sds_consumer_idx = ( ( sds_consumer_idx + 1 ) %
PHN_NUM_SDS );
1483 #define PHN_CLP_BLKSIZE ( sizeof ( union phantom_clp_data ) ) 1492 unsigned int retries;
1502 DBGC ( phantom,
"Phantom %p timed out waiting for CLP command\n",
1520 unsigned int opcode,
const void *data_in,
1521 void *data_out,
size_t offset,
size_t len ) {
1524 unsigned int last = 0;
1531 size_t out_frag_len;
1538 DBGC ( phantom,
"Phantom %p invalid CLP length %zd\n",
1552 if ( in_frag_len >
sizeof (
data ) ) {
1553 in_frag_len =
sizeof (
data );
1557 in_frag = &
data.bytes[
sizeof (
data ) - in_frag_len ];
1567 (
port << 8 ) | ( last << 7 ) | (
opcode << 0 ) );
1579 read_len = ( (
status >> 16 ) & 0xff );
1582 DBGC ( phantom,
"Phantom %p CLP command error %02x\n",
1593 out_frag_len = ( read_len -
offset );
1594 if ( out_frag_len >
sizeof (
data ) )
1595 out_frag_len =
sizeof (
data );
1596 out_frag = &
data.bytes[
sizeof (
data ) - out_frag_len ];
1599 memcpy ( ( data_out +
offset ), out_frag, out_frag_len );
1652 if (
offset >= (
unsigned ) read_len )
1670 { &mac_setting, 0x01 },
1697 DBGC2 ( phantom,
"Phantom %p has no \"%s\" setting\n",
1714 unsigned int clp_setting;
1718 return ( clp_setting != 0 );
1732 const void *
data,
size_t len ) {
1735 unsigned int clp_setting;
1740 assert ( clp_setting != 0 );
1744 clp_setting,
data,
len ) ) != 0 ) {
1745 DBGC ( phantom,
"Phantom %p could not store setting \"%s\": " 1767 unsigned int clp_setting;
1773 assert ( clp_setting != 0 );
1777 clp_setting,
data,
len ) ) < 0 ){
1779 DBGC ( phantom,
"Phantom %p could not fetch setting \"%s\": " 1808 unsigned long bar0_start;
1809 unsigned long bar0_size;
1813 DBGC ( phantom,
"Phantom %p is " PCI_FMT " with BAR0 at %08lx+%lx\n",
1814 phantom,
PCI_ARGS ( pci ), bar0_start, bar0_size );
1816 if ( ! bar0_start ) {
1817 DBGC ( phantom,
"Phantom %p BAR not assigned; ignoring\n",
1822 switch ( bar0_size ) {
1823 case ( 128 * 1024 * 1024 ) :
1824 DBGC ( phantom,
"Phantom %p has 128MB BAR\n", phantom );
1827 case ( 32 * 1024 * 1024 ) :
1828 DBGC ( phantom,
"Phantom %p has 32MB BAR\n", phantom );
1831 case ( 2 * 1024 * 1024 ) :
1832 DBGC ( phantom,
"Phantom %p has 2MB BAR\n", phantom );
1836 DBGC ( phantom,
"Phantom %p has bad BAR size\n", phantom );
1841 if ( ! phantom->
bar0 ) {
1842 DBGC ( phantom,
"Phantom %p could not map BAR0\n", phantom );
1883 unsigned int retries;
1893 DBGC ( phantom,
"Phantom %p command PEG already initialized\n",
1906 DBGC ( phantom,
"Phantom %p coming up from cold boot\n",
1910 DBGC ( phantom,
"Phantom %p reset failed: %08x\n",
1911 phantom, sw_reset );
1915 DBGC ( phantom,
"Phantom %p coming up from warm boot " 1916 "(%08x)\n", phantom, cold_boot );
1937 DBGC ( phantom,
"Phantom %p initialising command PEG (will take up to " 1942 if ( cmdpeg_state != last_cmdpeg_state ) {
1943 DBGC ( phantom,
"Phantom %p command PEG state is " 1944 "%08x after %d seconds...\n",
1945 phantom, cmdpeg_state, retries );
1946 last_cmdpeg_state = cmdpeg_state;
1958 DBGC ( phantom,
"Phantom %p timed out waiting for command PEG to " 1959 "initialise (status %08x)\n", phantom, cmdpeg_state );
1980 ( 12 * ( phantom->
port / 2 ) ) );
1981 for ( i = 0 ; i < 3 ; i++,
offset += 4 ) {
1986 for ( i = 0 ; i <
ETH_ALEN ; i++ ) {
1988 u.mac_addr[ phantom->
port & 1 ][i];
1990 DBGC ( phantom,
"Phantom %p MAC address is %s\n",
2008 unsigned long boot_enable;
2011 if ( ! ( boot_enable & ( 1 << phantom->
port ) ) ) {
2012 DBGC ( phantom,
"Phantom %p PXE boot is disabled\n",
2027 unsigned int retries;
2031 DBGC ( phantom,
"Phantom %p initialising receive PEG (will take up to " 2036 if ( rcvpeg_state != last_rcvpeg_state ) {
2037 DBGC ( phantom,
"Phantom %p receive PEG state is " 2038 "%08x after %d seconds...\n",
2039 phantom, rcvpeg_state, retries );
2040 last_rcvpeg_state = rcvpeg_state;
2047 DBGC ( phantom,
"Phantom %p timed out waiting for receive PEG to " 2048 "initialise (status %08x)\n", phantom, rcvpeg_state );
2070 goto err_alloc_etherdev;
2076 memset ( phantom, 0,
sizeof ( *phantom ) );
2097 for ( i = 0 ; i < 8 ; i++ ) {
2112 goto err_init_cmdpeg;
2116 goto err_init_rcvpeg;
2123 goto err_check_boot_enable;
2127 DBGC ( phantom,
"Phantom %p could not register net device: " 2129 goto err_register_netdev;
2135 parent_settings,
"clp" ) ) != 0 ) {
2136 DBGC ( phantom,
"Phantom %p could not register settings: " 2138 goto err_register_settings;
2144 err_register_settings:
2146 err_register_netdev:
2147 err_check_boot_enable:
2174 PCI_ROM ( 0x4040, 0x0100,
"nx",
"NX", 0 ),
static int phantom_check_boot_enable(struct phantom_nic *phantom)
Check Phantom is enabled for boot.
#define UNM_CAM_RAM_WOL_PORT_MODE
static struct settings_operations phantom_settings_operations
Phantom CLP settings operations.
#define PCI_FUNC(busdevfn)
#define UNM_PCIE_IRQ_MASK_F1
#define UNM_TEST_RDDATA_LO
#define iob_pull(iobuf, len)
static int phantom_store_setting(struct settings *settings, const struct setting *setting, const void *data, size_t len)
Store Phantom CLP setting.
#define EINVAL
Invalid argument.
unsigned long crb_window
Current CRB window.
struct phantom_create_rx_ctx_rqrsp::@93 hostrq
#define UNM_PCIE_IRQ_STATUS_MAGIC
#define PCI_BUS(busdevfn)
unsigned long cds_producer_crb
TX descriptor producer CRB offset.
struct arbelprm_rc_send_wqe rc
unsigned int sds_irq_enabled
RX interrupts enabled.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
static void netdev_tx_complete(struct net_device *netdev, struct io_buffer *iobuf)
Complete network transmission.
#define UNM_NIC_REG_XG_STATE_P3
struct phantom_rds rds[PHN_NUM_RDS]
RX descriptors.
#define PHN_RX_BUFSIZE
RX buffer size.
#define iob_put(iobuf, len)
#define UNM_ROMUSB_GLB_SW_RESET
static int phantom_alloc_cds(struct phantom_nic *phantom)
Allocate Phantom TX descriptor.
#define UNM_ROMUSB_GLB_PEGTUNE_DONE
void netdev_rx_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Discard received packet.
#define UNM_TEST_CONTROL_ENABLE
#define UNM_CAM_RAM_DMESG_SIG_MAGIC
static void phantom_post_cds(struct phantom_nic *phantom, union phantom_cds *cds)
Post Phantom TX descriptor.
struct nx_hostrq_rds_ring_s rds
#define UNM_PEG_3_HALT_STATUS
static void phantom_get_macaddr(struct phantom_nic *phantom, uint8_t *hw_addr)
Read Phantom MAC address.
#define UNM_PCIE_IRQ_STATUS_F6
static unsigned int unsigned int reg
#define UNM_PCIE_IRQ_VECTOR_BIT(n)
void unregister_settings(struct settings *settings)
Unregister settings block.
#define le32_to_cpu(value)
int(* open)(struct net_device *netdev)
Open network device.
unsigned long link_poll_timer
Link state poll timer.
#define UNM_NIC_REG_RCVPEG_STATE_INITIALIZED
#define UNM_TEST_CONTROL_START
uint16_t tx_context_id
TX context ID.
#define NX_FILL_1(_ptr, _index,...)
#define NX_FILL_7(_ptr, _index,...)
#define UNM_CAM_RAM_NUM_DMESG_BUFFERS
TX context creation request and response buffers.
struct phantom_create_rx_ctx_rqrsp::@94 cardrsp
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
#define PHN_NUM_SDS
Number of RX status descriptors.
struct pci_device_id * ids
PCI ID table.
static int phantom_read_test_mem(struct phantom_nic *phantom, unsigned long offset)
Read single byte from Phantom test memory.
struct arbelprm_completion_with_error error
struct nx_hostrq_tx_ctx_s tx_ctx
#define PHN_CMDPEG_INIT_TIMEOUT_SEC
Maximum time to wait for command PEG to initialise.
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
#define UNM_PCIE_IRQ_MASK_F6
#define PHN_RCVPEG_INIT_TIMEOUT_SEC
Maximum time to wait for receive PEG to initialise.
A Phantom descriptor ring set.
#define UNM_CAM_RAM_COLD_BOOT
#define UNM_NIC_REG_NX_ARG3
#define UNM_NIC_REG_DUMMY_BUF
const uint8_t * ll_broadcast
Link-layer broadcast address.
#define UNM_PCIE_IRQ_MASK_MAGIC
#define __unm_dma_aligned
Mark structure as DMA-aligned.
unsigned long long uint64_t
static void *__malloc malloc_phys(size_t size, size_t phys_align)
Allocate memory with specified physical alignment.
#define PCI_BASE_ADDRESS_0
static unsigned int phantom_clp_setting(struct phantom_nic *phantom, const struct setting *setting)
Find Phantom CLP setting.
#define UNM_32M_CRB_WINDOW
#define cpu_to_le64(value)
void netdev_link_down(struct net_device *netdev)
Mark network device as having link down.
#define PHN_NUM_RDS
Number of RX descriptors.
#define UNM_CAM_RAM_CLP_STATUS_START
uint32_t buffer
Buffer index (or NETVSC_RNDIS_NO_BUFFER)
#define UNM_NIC_REG_CMDPEG_STATE_INITIALIZE_ACK
static int phantom_setting_applies(struct settings *settings, const struct setting *setting)
Check applicability of Phantom CLP setting.
static int phantom_add_macaddr(struct phantom_nic *phantom, const uint8_t *ll_addr)
Add MAC address.
#define UNM_NIC_REG_CMDPEG_STATE_INITIALIZED
#define UNM_PCIE_IRQ_STATUS_F7
#define NX_CDRP_RSP_TIMEOUT
static void phantom_write_hilo(struct phantom_nic *phantom, uint64_t value, unsigned long lo_offset, unsigned long hi_offset)
Write to Phantom CRB HI/LO register pair.
void adjust_pci_device(struct pci_device *pci)
Enable PCI device.
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
struct device dev
Generic device.
static struct settings * netdev_settings(struct net_device *netdev)
Get per-netdevice configuration settings block.
#define NX_CDRP_CMD_CREATE_RX_CTX
static void settings_init(struct settings *settings, struct settings_operations *op, struct refcnt *refcnt, const struct settings_scope *default_scope)
Initialise a settings block.
#define UNM_NIC_REG_CMDPEG_STATE
#define ECANCELED
Operation canceled.
static int phantom_clp_wait(struct phantom_nic *phantom)
Wait for Phantom CLP command to complete.
#define ENOTSUP
Operation not supported.
static int phantom_read_test_mem_block(struct phantom_nic *phantom, unsigned long offset, uint32_t buf[2])
Read from Phantom test memory.
static unsigned int unsigned long arg1
#define NX_CDRP_IS_RSP(rsp)
Dynamic memory allocation.
struct phantom_clp_data::@97 dwords
Dwords for the CLP interface.
struct phantom_descriptor_rings * desc
Descriptor rings.
#define UNM_PCIE_IRQ_MASK_F5
static int phantom_map_crb(struct phantom_nic *phantom, struct pci_device *pci)
Map Phantom CRB window.
#define UNM_PCIE_IRQ_STATUS_F0
#define UNM_NIC_REG_DUMMY_BUF_INIT
uint64_t tag
Setting tag, if applicable.
static void netdev_init(struct net_device *netdev, struct net_device_operations *op)
Initialise a network device.
static void pci_set_drvdata(struct pci_device *pci, void *priv)
Set PCI driver-private data.
uint16_t busdevfn
PCI bus:dev.fn address.
#define ENOMEM
Not enough space.
#define PHN_ISSUE_CMD_TIMEOUT_MS
Maximum time to wait for firmware to accept a command.
const struct setting * setting
iPXE setting
#define UNM_TEST_CONTROL_BUSY
#define NX_CDRP_CMD_DESTROY_TX_CTX
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define PHN_RDS_MAX_FILL
RX maximum fill level.
volatile uint32_t cmd_cons
TX consumer index.
#define UNM_CAM_RAM_CLP_COMMAND
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
#define UNM_2M_CRB_WINDOW
struct phantom_sds sds[PHN_NUM_SDS]
RX status descriptors.
#define UNM_DMA_BUFFER_ALIGN
DMA buffer alignment.
#define be32_to_cpu(value)
#define UNM_ROMUSB_GLB_SW_RESET_MAGIC
#define PHN_LINK_POLL_FREQUENCY
Link state poll frequency.
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
#define NX_CAP0_LEGACY_CONTEXT
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.
#define NX_CDRP_SIGNATURE_MAKE(pcifn, version)
static int phantom_dmesg(struct phantom_nic *phantom, unsigned int log, unsigned int max_lines)
Dump Phantom firmware dmesg log.
#define UNM_CRB_OFFSET(reg)
void * priv
Driver private data.
pseudo_bit_t value[0x00020]
#define UNM_PCIE_IRQ_STATUS_F2
static void phantom_post_rds(struct phantom_nic *phantom, struct phantom_rds *rds)
Post Phantom RX descriptor.
static void netdev_link_up(struct net_device *netdev)
Mark network device as having link up.
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
#define UNM_CAM_RAM_MAC_ADDRS
uint32_t hi
High dword, in network byte order.
#define UNM_PEG_2_HALT_STATUS
#define UNM_PCIE_IRQ_MASK_F7
unsigned int rds_producer_idx
RX producer index.
static struct net_device * netdev
#define UNM_CAM_RAM_DMESG_TAIL(n)
u32 link
Link to next descriptor.
unsigned long pci_bar_start(struct pci_device *pci, unsigned int reg)
Find the start of a PCI BAR.
#define UNM_CAM_RAM_CLP_STATUS
#define NX_CDRP_FORM_CMD(cmd)
struct settings settings
Non-volatile settings.
#define UNM_CAM_RAM_BOOT_ENABLE
static int phantom_init_rcvpeg(struct phantom_nic *phantom)
Initialise Phantom receive PEG.
#define UNM_TEST_RDDATA_HI
void unregister_netdev(struct net_device *netdev)
Unregister network device.
struct nx_hostrq_sds_ring_s sds
#define UNM_PEG_1_HALT_STATUS
#define cpu_to_le32(value)
#define EPROTO
Protocol error.
#define PHN_CLP_CMD_TIMEOUT_MS
Maximum time to wait for CLP command to be issued.
static void phantom_destroy_rx_ctx(struct phantom_nic *phantom)
Destroy Phantom RX context.
#define UNM_CAM_RAM_CLP_DATA_LO
union phantom_cds cds[PHN_NUM_CDS]
TX descriptors.
#define PCI_BUSDEVFN(segment, bus, slot, func)
#define UNM_CAM_RAM_DMESG_SIG(n)
nx_hostrq_cds_ring_t cds_ring
static int phantom_create_rx_ctx(struct phantom_nic *phantom)
Create Phantom RX context.
static int phantom_probe(struct pci_device *pci)
Probe PCI device.
static unsigned long phantom_crb_access_128m(struct phantom_nic *phantom, unsigned long reg)
Prepare for access to CRB register via 128MB BAR.
char * strerror(int errno)
Retrieve string representation of error number.
static void phantom_irq(struct net_device *netdev, int enable)
Enable/disable interrupts.
struct phantom_create_tx_ctx_rqrsp::@95 hostrq
static const struct settings_scope phantom_settings_scope
Phantom CLP settings scope.
struct refcnt refcnt
Reference counter.
#define UNM_CAM_RAM_DMESG_HEAD(n)
#define UNM_CAM_RAM_CLP_DATA_HI
#define PCI_FMT
PCI device debug message format.
uint32_t link_state
Last known link state.
#define PCI_SLOT(busdevfn)
#define UNM_PEG_0_HALT_STATUS
static struct phantom_clp_setting clp_settings[]
Phantom CLP settings.
int register_netdev(struct net_device *netdev)
Register network device.
uint8_t bytes[8]
Data bytes.
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
const char * eth_ntoa(const void *ll_addr)
Transcribe Ethernet address.
static void phantom_destroy_tx_ctx(struct phantom_nic *phantom)
Destroy Phantom TX context.
#define UNM_PCIE_IRQ_STATUS_F3
static unsigned long phantom_crb_access_2m(struct phantom_nic *phantom, unsigned long reg)
Prepare for access to CRB register via 2MB BAR.
static unsigned long phantom_crb_access_32m(struct phantom_nic *phantom, unsigned long reg)
Prepare for access to CRB register via 32MB BAR.
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
Settings block operations.
#define UNM_PCIE_IRQ_MASK_F0
static void phantom_poll(struct net_device *netdev)
Poll for received packets.
#define UNM_NIC_REG_RCVPEG_STATE
#define UNM_NIC_REG_XG_STATE_P3_LINK_DOWN
static uint32_t phantom_readl(struct phantom_nic *phantom, unsigned long reg)
Read from Phantom CRB register.
static void phantom_refill_rx_ring(struct net_device *netdev)
Refill descriptor ring.
RX context creation request and response buffers.
unsigned int clp_setting
Setting number.
static int phantom_issue_buf_cmd(struct phantom_nic *phantom, uint32_t command, void *buffer, size_t len)
Issue buffer-format command to firmware.
#define UNM_PCIE_IRQ_VECTOR
struct io_buffer * cds_iobuf[PHN_NUM_CDS]
TX I/O buffers.
#define NX_CDRP_FORM_RSP(rsp)
A PCI device ID list entry.
#define UNM_CAM_RAM_COLD_BOOT_MAGIC
#define le16_to_cpu(value)
static int phantom_create_tx_ctx(struct phantom_nic *phantom)
Create Phantom TX context.
static struct pci_device_id phantom_nics[]
Phantom PCI IDs.
#define PHN_TEST_MEM_TIMEOUT_MS
Maximum time to wait for test memory.
#define UNM_NIC_REG_XG_STATE_P3_LINK(port, state_p3)
#define UNM_NIC_REG_NX_SIGN
#define UNM_PCIE_IRQ_STATUS_F1
static struct xen_remove_from_physmap * remove
struct nx_hostrq_rx_ctx_s rx_ctx
Network device operations.
static const unsigned long phantom_irq_status_reg[PHN_MAX_NUM_PORTS]
Interrupt status registers.
void netdev_rx(struct net_device *netdev, struct io_buffer *iobuf)
Add packet to receive queue.
struct device * dev
Underlying hardware device.
#define NX_CAP0_LEGACY_MN
Network device management.
#define UNM_PCIE_IRQ_STATE
unsigned long(* crb_access)(struct phantom_nic *phantom, unsigned long reg)
CRB window access method.
static void * pci_get_drvdata(struct pci_device *pci)
Get PCI driver-private data.
unsigned long sds_consumer_crb
RX status descriptor consumer CRB offset.
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
#define cpu_to_be32(value)
static int phantom_fetch_setting(struct settings *settings, struct setting *setting, void *data, size_t len)
Fetch Phantom CLP setting.
uint32_t busdevfn
Segment, bus, device, and function (bus:dev.fn) number.
static void phantom_unhalt_pegs(struct phantom_nic *phantom)
Unhalt all PEGs.
void netdev_tx_complete_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Complete network transmission.
#define NX_CDRP_CMD_CREATE_TX_CTX
static void phantom_dmesg_all(struct phantom_nic *phantom, unsigned int max_lines)
Dump Phantom firmware dmesg logs.
unsigned int rds_consumer_idx
RX consumer index.
#define ENOBUFS
No buffer space available.
#define NX_RDS_RING_TYPE_NORMAL
uint8_t block[3][8]
DES-encrypted blocks.
uint16_t rx_context_id
RX context ID.
int(* probe)(struct pci_device *pci)
Probe device.
#define UNM_NIC_REG_NX_CDRP
static int phantom_wait_for_cmd(struct phantom_nic *phantom)
Wait for firmware to accept command.
static void phantom_writel(struct phantom_nic *phantom, uint32_t value, unsigned long reg)
Write to Phantom CRB register.
static int phantom_clp_cmd(struct phantom_nic *phantom, unsigned int port, unsigned int opcode, const void *data_in, void *data_out, size_t offset, size_t len)
Issue Phantom CLP command.
void * data
Start of data.
#define UNM_PCIE_IRQ_MASK_F4
#define EIO
Input/output error.
#define UNM_128M_CRB_WINDOW
struct net_device * alloc_etherdev(size_t priv_size)
Allocate Ethernet device.
#define PCI_ARGS(pci)
PCI device debug message arguments.
#define PHN_MAX_NUM_PORTS
Maximum number of ports.
#define PHN_NUM_CDS
Number of TX descriptors.
int pci_write_config_dword(struct pci_device *pci, unsigned int where, uint32_t value)
Write 32-bit dword to PCI configuration space.
#define UNM_PCIE_IRQ_STATUS_F5
#define cpu_to_le16(value)
#define NX_DESTROY_CTX_RESET
uint8_t data[48]
Additional event data.
unsigned long rds_producer_crb
RX descriptor producer CRB offset.
#define UNM_PCIE_IRQ_STATE_TRIGGERED(state)
static void phantom_close(struct net_device *netdev)
Close NIC.
struct pci_driver phantom_driver __pci_driver
Phantom PCI driver.
static int phantom_del_macaddr(struct phantom_nic *phantom, const uint8_t *ll_addr)
Remove MAC address.
#define UNM_CAM_RAM_PORT_MODE_AUTO_NEG_1G
unsigned int sds_consumer_idx
RX status consumer index.
static void free_phys(void *ptr, size_t size)
Free memory allocated with malloc_phys()
int(* applies)(struct settings *settings, const struct setting *setting)
Check applicability of setting.
int register_settings(struct settings *settings, struct settings *parent, const char *name)
Register settings block.
uint16_t offset
Offset to command line.
#define NX_FILL_3(_ptr, _index,...)
void mb(void)
Memory barrier.
static int phantom_issue_cmd(struct phantom_nic *phantom, uint32_t command, uint32_t arg1, uint32_t arg2, uint32_t arg3)
Issue command to firmware.
static void phantom_remove(struct pci_device *pci)
Remove PCI device.
unsigned int cds_consumer_idx
TX consumer index.
static int phantom_init_cmdpeg(struct phantom_nic *phantom)
Initialise the Phantom command PEG.
#define NX_CDRP_CMD_DESTROY_RX_CTX
unsigned long sds_irq_mask_crb
RX interrupt mask CRB offset.
struct phantom_create_tx_ctx_rqrsp::@96 cardrsp
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
#define UNM_NIC_REG_DUMMY_BUF_ADDR_HI
#define NX_HOST_INT_CRB_MODE_SHARED
#define DBG(...)
Print a debugging message.
#define UNM_NIC_REG_NX_ARG1
unsigned int cds_producer_idx
TX producer index.
void * pci_ioremap(struct pci_device *pci, unsigned long bus_addr, size_t len)
Map PCI bus address as an I/O address.
const struct settings_scope * scope
Setting scope (or NULL)
static unsigned int unsigned long unsigned long arg2
#define NX_FILL_2(_ptr, _index,...)
static const unsigned long phantom_irq_mask_reg[PHN_MAX_NUM_PORTS]
Interrupt mask registers.
#define UNM_PEG_4_HALT_STATUS
static int phantom_update_macaddr(struct phantom_nic *phantom, const uint8_t *ll_addr, unsigned int opcode)
Add/remove MAC address.
#define UNM_PCIE_IRQ_STATUS_F4
static unsigned int unsigned long unsigned long unsigned long arg3
static int phantom_clp_store(struct phantom_nic *phantom, unsigned int port, unsigned int setting, const void *data, size_t len)
Store Phantom CLP setting.
static int phantom_transmit(struct net_device *netdev, struct io_buffer *iobuf)
Transmit packet.
uint32_t lo
Low dword, in network byte order.
u8 signature
CPU signature.
static void phantom_poll_link_state(struct net_device *netdev)
Poll link state.
#define PCI_SEG(busdevfn)
int setting_cmp(const struct setting *a, const struct setting *b)
Compare two settings.
uint8_t hw_addr[MAX_HW_ADDR_LEN]
Hardware address.
#define NULL
NULL pointer (VOID *)
#define UNM_PCIE_IRQ_MASK_F2
#define ETIMEDOUT
Connection timed out.
#define NX_GET(_ptr, _field)
Extract value of named field (for fields up to the size of a long)
#define PCI_ROM(_vendor, _device, _name, _description, _data)
#define UNM_NIC_REG_XG_STATE_P3_LINK_UP
#define UNM_NIC_REG_NX_ARG2
#define UNM_NIC_REG_DUMMY_BUF_ADDR_LO
unsigned int port
Port number.
struct io_buffer * rds_iobuf[PHN_RDS_MAX_FILL]
RX I/O buffers.
static int phantom_open(struct net_device *netdev)
Open NIC.
u8 tx[WPA_TKIP_MIC_KEY_LEN]
MIC key for packets to the AP.
#define NX_HOST_RDS_CRB_MODE_UNIQUE
#define UNM_ROMUSB_GLB_PEGTUNE_DONE_MAGIC
static struct net_device_operations phantom_operations
Phantom net device operations.
#define UNM_CAM_RAM_CLP_STATUS_DONE
void * memset(void *dest, int character, size_t len) __nonnull
static int phantom_alloc_rds(struct phantom_nic *phantom)
Allocate Phantom RX descriptor.
#define UNM_PCIE_IRQ_MASK_F3
static int phantom_clp_fetch(struct phantom_nic *phantom, unsigned int port, unsigned int setting, void *data, size_t len)
Fetch Phantom CLP setting.