From: Kieran Mansley Subject: sync Solarflare accelerator headers References: bnc#489105 Sync the headers used by sfc_netback and sfc_netutil with those in the sfc_resource driver to give a consistent view of cross-module APIs. Update sfc_netback to use efx_vi_alloc() as defined by the version of sfc_resource module in SLES11. It now takes a net driver interface index rather than a NIC index. efx_vi_hw_resource_get_phys() no longer returns a version. Set efhw_arch field of device type. Acked-by: jbeulich@novell.com --- sle11-2009-03-24.orig/drivers/net/sfc/sfc_resource/ci/efhw/common.h 2009-03-30 16:16:28.000000000 +0200 +++ sle11-2009-03-24/drivers/net/sfc/sfc_resource/ci/efhw/common.h 2009-03-30 16:21:54.000000000 +0200 @@ -41,6 +41,10 @@ #include +enum efhw_arch { + EFHW_ARCH_FALCON, +}; + typedef uint32_t efhw_buffer_addr_t; #define EFHW_BUFFER_ADDR_FMT "[ba:%"PRIx32"]" --- sle11-2009-03-24.orig/drivers/net/sfc/sfc_resource/nic.c 2009-03-30 16:16:28.000000000 +0200 +++ sle11-2009-03-24/drivers/net/sfc/sfc_resource/nic.c 2009-03-30 16:21:54.000000000 +0200 @@ -47,6 +47,7 @@ int efhw_device_type_init(struct efhw_de switch (device_id) { case 0x0703: case 0x6703: + dt->arch = EFHW_ARCH_FALCON; dt->variant = 'A'; switch (class_revision) { case 0: @@ -60,6 +61,7 @@ int efhw_device_type_init(struct efhw_de } break; case 0x0710: + dt->arch = EFHW_ARCH_FALCON; dt->variant = 'B'; switch (class_revision) { case 2: --- sle11-2009-03-24.orig/drivers/xen/sfc_netback/accel.h 2009-03-30 16:16:28.000000000 +0200 +++ sle11-2009-03-24/drivers/xen/sfc_netback/accel.h 2009-03-30 16:00:09.000000000 +0200 @@ -123,8 +123,6 @@ struct netback_accel { enum net_accel_hw_type hw_type; /*! State of allocation */ int hw_state; - /*! Index into ci_driver.nics[] for this interface */ - int nic_index; /*! How to set up the acceleration for this hardware */ int (*accel_setup)(struct netback_accel *); /*! And how to stop it. */ --- sle11-2009-03-24.orig/drivers/xen/sfc_netback/accel_solarflare.c 2009-03-30 16:16:28.000000000 +0200 +++ sle11-2009-03-24/drivers/xen/sfc_netback/accel_solarflare.c 2009-03-30 16:10:59.000000000 +0200 @@ -87,7 +87,6 @@ struct driverlink_port { enum net_accel_hw_type type; struct net_device *net_dev; struct efx_dl_device *efx_dl_dev; - int nic_index; void *fwd_priv; }; @@ -164,34 +163,6 @@ static struct netback_accel_hooks accel_ }; -/* - * Handy helper which given an efx_dl_device works out which - * efab_nic_t index into efrm_nic_table.nics[] it corresponds to - */ -static int efx_device_to_efab_nic_index(struct efx_dl_device *efx_dl_dev) -{ - int i; - - for (i = 0; i < EFHW_MAX_NR_DEVS; i++) { - struct efhw_nic *nic = efrm_nic_table.nic[i]; - - /* - * It's possible for the nic structure to have not - * been initialised if the resource driver failed its - * driverlink probe - */ - if (nic == NULL || nic->net_driver_dev == NULL) - continue; - - /* Work out if these are talking about the same NIC */ - if (nic->net_driver_dev->pci_dev == efx_dl_dev->pci_dev) - return i; - } - - return -1; -} - - /* Driver link probe - register our callbacks */ static int bend_dl_probe(struct efx_dl_device *efx_dl_dev, const struct net_device *net_dev, @@ -225,17 +196,6 @@ static int bend_dl_probe(struct efx_dl_d port->efx_dl_dev = efx_dl_dev; efx_dl_dev->priv = port; - port->nic_index = efx_device_to_efab_nic_index(efx_dl_dev); - if (port->nic_index < 0) { - /* - * This can happen in theory if the resource driver - * failed to initialise properly - */ - EPRINTK("%s: nic structure not found\n", __FUNCTION__); - rc = -EINVAL; - goto fail2; - } - port->fwd_priv = netback_accel_init_fwd_port(); if (port->fwd_priv == NULL) { EPRINTK("%s: failed to set up forwarding for port\n", @@ -377,8 +337,6 @@ int netback_accel_sf_hwtype(struct netba bend->accel_setup = netback_accel_setup_vnic_hw; bend->accel_shutdown = netback_accel_shutdown_vnic_hw; bend->fwd_priv = port->fwd_priv; - /* This is just needed to pass to efx_vi_alloc */ - bend->nic_index = port->nic_index; bend->net_dev = port->net_dev; mutex_unlock(&accel_mutex); return 0; @@ -505,7 +463,7 @@ static int ef_get_vnic(struct netback_ac accel_hw_priv = bend->accel_hw_priv; - rc = efx_vi_alloc(&accel_hw_priv->efx_vih, bend->nic_index); + rc = efx_vi_alloc(&accel_hw_priv->efx_vih, bend->net_dev->ifindex); if (rc != 0) { EPRINTK("%s: efx_vi_alloc failed %d\n", __FUNCTION__, rc); free_page_state(bend); @@ -600,9 +558,6 @@ static int ef_bend_hwinfo_falcon_common( return rc; } - if (res_mdata.version != 0) - return -EPROTO; - hwinfo->nic_arch = res_mdata.nic_arch; hwinfo->nic_variant = res_mdata.nic_variant; hwinfo->nic_revision = res_mdata.nic_revision; --- sle11-2009-03-24.orig/drivers/xen/sfc_netback/ci/driver/resource/efx_vi.h 2009-03-30 16:16:28.000000000 +0200 +++ sle11-2009-03-24/drivers/xen/sfc_netback/ci/driver/resource/efx_vi.h 2009-03-30 16:00:09.000000000 +0200 @@ -49,11 +49,11 @@ struct efx_vi_state; * Allocate an efx_vi, including event queue and pt_endpoint * * \param vih_out Pointer to a handle that is set on success - * \param nic_index Index of NIC to apply this resource to + * \param ifindex Index of the network interface desired * \return Zero on success (and vih_out set), non-zero on failure. */ extern int -efx_vi_alloc(struct efx_vi_state **vih_out, int nic_index); +efx_vi_alloc(struct efx_vi_state **vih_out, int ifindex); /*! * Free a previously allocated efx_vi @@ -190,8 +190,6 @@ efx_vi_filter_stop(struct efx_vi_state * /*! Constants for the type field in efx_vi_hw_resource */ #define EFX_VI_HW_RESOURCE_TXDMAQ 0x0 /* PFN of TX DMA Q */ #define EFX_VI_HW_RESOURCE_RXDMAQ 0x1 /* PFN of RX DMA Q */ -#define EFX_VI_HW_RESOURCE_TXBELL 0x2 /* PFN of TX Doorbell (EF1) */ -#define EFX_VI_HW_RESOURCE_RXBELL 0x3 /* PFN of RX Doorbell (EF1) */ #define EFX_VI_HW_RESOURCE_EVQTIMER 0x4 /* Address of event q timer */ /* Address of event q pointer (EF1) */ @@ -229,7 +227,6 @@ struct efx_vi_hw_resource { * Metadata concerning the list of hardware resource mappings */ struct efx_vi_hw_resource_metadata { - int version; int evq_order; int evq_offs; int evq_capacity; --- sle11-2009-03-24.orig/drivers/xen/sfc_netback/ci/efhw/common.h 2009-03-30 16:16:28.000000000 +0200 +++ sle11-2009-03-24/drivers/xen/sfc_netback/ci/efhw/common.h 2009-03-30 16:21:54.000000000 +0200 @@ -43,7 +43,6 @@ enum efhw_arch { EFHW_ARCH_FALCON, - EFHW_ARCH_SIENA, }; typedef uint32_t efhw_buffer_addr_t; @@ -56,25 +55,21 @@ typedef union { uint32_t a; uint32_t b; } opaque; - struct { - uint32_t code; - uint32_t status; - } ev1002; } efhw_event_t; /* Flags for TX/RX queues */ -#define EFHW_VI_JUMBO_EN 0x01 /*! scatter RX over multiple desc */ -#define EFHW_VI_ISCSI_RX_HDIG_EN 0x02 /*! iscsi rx header digest */ -#define EFHW_VI_ISCSI_TX_HDIG_EN 0x04 /*! iscsi tx header digest */ -#define EFHW_VI_ISCSI_RX_DDIG_EN 0x08 /*! iscsi rx data digest */ -#define EFHW_VI_ISCSI_TX_DDIG_EN 0x10 /*! iscsi tx data digest */ -#define EFHW_VI_TX_PHYS_ADDR_EN 0x20 /*! TX physical address mode */ -#define EFHW_VI_RX_PHYS_ADDR_EN 0x40 /*! RX physical address mode */ -#define EFHW_VI_RM_WITH_INTERRUPT 0x80 /*! VI with an interrupt */ -#define EFHW_VI_TX_IP_CSUM_DIS 0x100 /*! enable ip checksum generation */ -#define EFHW_VI_TX_TCPUDP_CSUM_DIS 0x200 /*! enable tcp/udp checksum - generation */ -#define EFHW_VI_TX_TCPUDP_ONLY 0x400 /*! drop non-tcp/udp packets */ +#define EFHW_VI_JUMBO_EN 0x01 /*! scatter RX over multiple desc */ +#define EFHW_VI_ISCSI_RX_HDIG_EN 0x02 /*! iscsi rx header digest */ +#define EFHW_VI_ISCSI_TX_HDIG_EN 0x04 /*! iscsi tx header digest */ +#define EFHW_VI_ISCSI_RX_DDIG_EN 0x08 /*! iscsi rx data digest */ +#define EFHW_VI_ISCSI_TX_DDIG_EN 0x10 /*! iscsi tx data digest */ +#define EFHW_VI_TX_PHYS_ADDR_EN 0x20 /*! TX physical address mode */ +#define EFHW_VI_RX_PHYS_ADDR_EN 0x40 /*! RX physical address mode */ +#define EFHW_VI_RM_WITH_INTERRUPT 0x80 /*! VI with an interrupt */ +#define EFHW_VI_TX_IP_CSUM_DIS 0x100 /*! enable ip checksum generation */ +#define EFHW_VI_TX_TCPUDP_CSUM_DIS 0x200 /*! enable tcp/udp checksum + generation */ +#define EFHW_VI_TX_TCPUDP_ONLY 0x400 /*! drop non-tcp/udp packets */ /* Types of hardware filter */ /* Each of these values implicitly selects scatter filters on B0 - or in --- sle11-2009-03-24.orig/drivers/xen/sfc_netback/ci/efhw/common_sysdep.h 2009-03-30 16:16:28.000000000 +0200 +++ sle11-2009-03-24/drivers/xen/sfc_netback/ci/efhw/common_sysdep.h 2009-03-30 16:00:09.000000000 +0200 @@ -41,7 +41,6 @@ #define __CI_EFHW_COMMON_LINUX_H__ #include -#include /* Dirty hack, but Linux kernel does not provide DMA_ADDR_T_FMT */ #if BITS_PER_LONG == 64 || defined(CONFIG_HIGHMEM64G) @@ -52,16 +51,11 @@ /* Linux kernel also does not provide PRIx32... Sigh. */ #define PRIx32 "x" -#define PRIx64 "llx" - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) -enum { - false = 0, - true = 1 -}; - -typedef _Bool bool; -#endif /* LINUX_VERSION_CODE < 2.6.19 */ +#ifdef __ia64__ +# define PRIx64 "lx" +#else +# define PRIx64 "llx" +#endif #endif /* __CI_EFHW_COMMON_LINUX_H__ */ --- sle11-2009-03-24.orig/drivers/xen/sfc_netback/ci/efhw/efhw_types.h 2009-03-30 16:16:28.000000000 +0200 +++ sle11-2009-03-24/drivers/xen/sfc_netback/ci/efhw/efhw_types.h 2009-03-30 16:00:09.000000000 +0200 @@ -45,14 +45,6 @@ /*-------------------------------------------------------------------- * - * hardware limits used in the types - * - *--------------------------------------------------------------------*/ - -#define EFHW_KEVENTQ_MAX 8 - -/*-------------------------------------------------------------------- - * * forward type declarations * *--------------------------------------------------------------------*/ @@ -72,7 +64,7 @@ struct efhw_buffer_table_allocation{ struct eventq_resource_hardware { /*!iobuffer allocated for eventq - can be larger than eventq */ - efhw_iopages_t iobuff; + struct efhw_iopages iobuff; unsigned iobuff_off; struct efhw_buffer_table_allocation buf_tbl_alloc; int capacity; /*!< capacity of event queue */ @@ -85,7 +77,7 @@ struct eventq_resource_hardware { *--------------------------------------------------------------------*/ struct efhw_keventq { - volatile int lock; + int lock; caddr_t evq_base; int32_t evq_ptr; uint32_t evq_mask; @@ -94,6 +86,37 @@ struct efhw_keventq { struct efhw_ev_handler *ev_handlers; }; +/*-------------------------------------------------------------------- + * + * filters + * + *--------------------------------------------------------------------*/ + +struct efhw_filter_spec { + uint dmaq_id; + uint32_t saddr_le32; + uint32_t daddr_le32; + uint16_t sport_le16; + uint16_t dport_le16; + unsigned tcp : 1; + unsigned full : 1; + unsigned rss : 1; /* not supported on A1 */ + unsigned scatter : 1; /* not supported on A1 */ +}; + +struct efhw_filter_depth { + unsigned needed; + unsigned max; +}; + +struct efhw_filter_search_limits { + unsigned tcp_full; + unsigned tcp_wild; + unsigned udp_full; + unsigned udp_wild; +}; + + /********************************************************************** * Portable HW interface. *************************************** **********************************************************************/ @@ -115,7 +138,7 @@ struct efhw_func_ops { /*! initialise all hardware functional units */ int (*init_hardware) (struct efhw_nic *nic, struct efhw_ev_handler *, - const uint8_t *mac_addr); + const uint8_t *mac_addr, int non_irq_evq); /*-------------- Interrupt support ------------ */ @@ -130,17 +153,17 @@ struct efhw_func_ops { */ int (*interrupt) (struct efhw_nic *nic); - /*! Enable given interrupt mask for the given IRQ unit */ - void (*interrupt_enable) (struct efhw_nic *nic, uint idx); + /*! Enable the interrupt */ + void (*interrupt_enable) (struct efhw_nic *nic); - /*! Disable given interrupt mask for the given IRQ unit */ - void (*interrupt_disable) (struct efhw_nic *nic, uint idx); + /*! Disable the interrupt */ + void (*interrupt_disable) (struct efhw_nic *nic); /*! Set interrupt moderation strategy for the given IRQ unit ** val is in usec */ - void (*set_interrupt_moderation)(struct efhw_nic *nic, - uint idx, uint val); + void (*set_interrupt_moderation)(struct efhw_nic *nic, int evq, + uint val); /*-------------- Event support ------------ */ @@ -152,7 +175,8 @@ struct efhw_func_ops { void (*event_queue_enable) (struct efhw_nic *nic, uint evq, /* evnt queue index */ uint evq_size, /* units of #entries */ - dma_addr_t q_base_addr, uint buf_base_id); + dma_addr_t q_base_addr, uint buf_base_id, + int interrupting); /*! Disable the given event queue (and any associated timer) */ void (*event_queue_disable) (struct efhw_nic *nic, uint evq, @@ -165,7 +189,7 @@ struct efhw_func_ops { /*! Push a SW event on a given eventQ */ void (*sw_event) (struct efhw_nic *nic, int data, int evq); - /*-------------- Filter support ------------ */ + /*-------------- IP Filter API ------------ */ /*! Setup a given filter - The software can request a filter_i, * but some EtherFabric implementations will override with @@ -176,13 +200,6 @@ struct efhw_func_ops { unsigned saddr_be32, unsigned sport_be16, unsigned daddr_be32, unsigned dport_be16); - /*! Attach a given filter to a DMAQ */ - void (*ipfilter_attach) (struct efhw_nic *nic, int filter_idx, - int dmaq_idx); - - /*! Detach a filter from its DMAQ */ - void (*ipfilter_detach) (struct efhw_nic *nic, int filter_idx); - /*! Clear down a given filter */ void (*ipfilter_clear) (struct efhw_nic *nic, int filter_idx); @@ -231,6 +248,14 @@ struct efhw_func_ops { /*! Commit a buffer table update */ void (*buffer_table_commit) (struct efhw_nic *nic); + /*-------------- New filter API ------------ */ + + /*! Set a given filter */ + int (*filter_set) (struct efhw_nic *nic, struct efhw_filter_spec *spec, + int *filter_idx_out); + + /*! Clear a given filter */ + void (*filter_clear) (struct efhw_nic *nic, int filter_idx); }; @@ -255,12 +280,10 @@ struct efhw_device_type { /*! */ struct efhw_nic { - /*! zero base index in efrm_nic_table.nic array */ - volatile int index; + /*! zero base index in efrm_nic_tablep->nic array */ + int index; int ifindex; /*!< OS level nic index */ -#ifdef HAS_NET_NAMESPACE struct net *nd_net; -#endif struct efhw_device_type devtype; @@ -276,14 +299,13 @@ struct efhw_nic { # define NIC_FLAG_TRY_MSI 0x02 # define NIC_FLAG_MSI 0x04 # define NIC_FLAG_OS_IRQ_EN 0x08 -# define NIC_FLAG_10G 0x10 unsigned mtu; /*!< MAC MTU (includes MAC hdr) */ /* hardware resources */ /*! I/O address of the start of the bar */ - efhw_ioaddr_t bar_ioaddr; + volatile char __iomem *bar_ioaddr; /*! Bar number of control aperture. */ unsigned ctr_ap_bar; @@ -295,9 +317,6 @@ struct efhw_nic { /*! EtherFabric Functional Units -- functions */ const struct efhw_func_ops *efhw_func; - /* Value read from FPGA version register. Zero for asic. */ - unsigned fpga_version; - /*! This lock protects a number of misc NIC resources. It should * only be used for things that can be at the bottom of the lock * order. ie. You mustn't attempt to grab any other lock while @@ -312,14 +331,17 @@ struct efhw_nic { void (*irq_handler) (struct efhw_nic *, int unit); /*! event queues per driver */ - struct efhw_keventq evq[EFHW_KEVENTQ_MAX]; + struct efhw_keventq interrupting_evq; /* for marking when we are not using an IRQ unit - 0 is a valid offset to an IRQ unit on EF1! */ #define EFHW_IRQ_UNIT_UNUSED 0xffff - /*! interrupt unit in use */ - unsigned int irq_unit[EFHW_KEVENTQ_MAX]; - efhw_iopage_t irq_iobuff; /*!< Falcon SYSERR interrupt */ + /*! interrupt unit in use for the interrupting event queue */ + unsigned int irq_unit; + + struct efhw_keventq non_interrupting_evq; + + struct efhw_iopage irq_iobuff; /*!< Falcon SYSERR interrupt */ /* The new driverlink infrastructure. */ struct efx_dl_device *net_driver_dev; @@ -331,8 +353,26 @@ struct efhw_nic { unsigned rxq_sizes; unsigned txq_sizes; - /* Size of filter table (including odd and even banks). */ - unsigned filter_tbl_size; + /* Size of filter table. */ + unsigned ip_filter_tbl_size; + + /* Number of filters currently used */ + unsigned ip_filter_tbl_used; + + /* Dynamically allocated filter state. */ + uint8_t *filter_in_use; + struct efhw_filter_spec *filter_spec_cache; + + /* Currently required and maximum filter table search depths. */ + struct efhw_filter_depth tcp_full_srch; + struct efhw_filter_depth tcp_wild_srch; + struct efhw_filter_depth udp_full_srch; + struct efhw_filter_depth udp_wild_srch; + + /* Number of event queues, DMA queues and timers. */ + unsigned num_evqs; + unsigned num_dmaqs; + unsigned num_timers; }; --- sle11-2009-03-24.orig/drivers/xen/sfc_netback/ci/efhw/hardware_sysdep.h 2009-03-30 16:16:28.000000000 +0200 +++ sle11-2009-03-24/drivers/xen/sfc_netback/ci/efhw/hardware_sysdep.h 2009-03-30 16:00:09.000000000 +0200 @@ -40,7 +40,7 @@ #ifndef __CI_EFHW_HARDWARE_LINUX_H__ #define __CI_EFHW_HARDWARE_LINUX_H__ -#include +#include #ifdef __LITTLE_ENDIAN #define EFHW_IS_LITTLE_ENDIAN @@ -50,23 +50,8 @@ #error Unknown endianness #endif -#ifndef mmiowb - #if defined(__i386__) || defined(__x86_64__) - #define mmiowb() - #elif defined(__ia64__) - #ifndef ia64_mfa - #define ia64_mfa() asm volatile ("mf.a" ::: "memory") - #endif - #define mmiowb ia64_mfa - #else - #error "Need definition for mmiowb()" - #endif -#endif - -typedef char *efhw_ioaddr_t; - #ifndef readq -static inline uint64_t __readq(void __iomem *addr) +static inline uint64_t __readq(volatile void __iomem *addr) { return *(volatile uint64_t *)addr; } @@ -74,7 +59,7 @@ static inline uint64_t __readq(void __io #endif #ifndef writeq -static inline void __writeq(uint64_t v, void __iomem *addr) +static inline void __writeq(uint64_t v, volatile void __iomem *addr) { *(volatile uint64_t *)addr = v; } --- sle11-2009-03-24.orig/drivers/xen/sfc_netback/ci/efhw/iopage_types.h 2009-03-30 16:16:28.000000000 +0200 +++ sle11-2009-03-24/drivers/xen/sfc_netback/ci/efhw/iopage_types.h 2009-03-30 16:00:09.000000000 +0200 @@ -3,7 +3,8 @@ * resource management for Xen backend, OpenOnload, etc * (including support for SFE4001 10GBT NIC) * - * This file provides efhw_page_t and efhw_iopage_t for Linux kernel. + * This file provides struct efhw_page and struct efhw_iopage for Linux + * kernel. * * Copyright 2005-2007: Solarflare Communications Inc, * 9501 Jeronimo Road, Suite 250, @@ -40,75 +41,76 @@ #include #include +#include #include /*-------------------------------------------------------------------- * - * efhw_page_t: A single page of memory. Directly mapped in the driver, - * and can be mapped to userlevel. + * struct efhw_page: A single page of memory. Directly mapped in the + * driver, and can be mapped to userlevel. * *--------------------------------------------------------------------*/ -typedef struct { +struct efhw_page { unsigned long kva; -} efhw_page_t; +}; -static inline int efhw_page_alloc(efhw_page_t *p) +static inline int efhw_page_alloc(struct efhw_page *p) { p->kva = __get_free_page(in_interrupt()? GFP_ATOMIC : GFP_KERNEL); return p->kva ? 0 : -ENOMEM; } -static inline int efhw_page_alloc_zeroed(efhw_page_t *p) +static inline int efhw_page_alloc_zeroed(struct efhw_page *p) { p->kva = get_zeroed_page(in_interrupt()? GFP_ATOMIC : GFP_KERNEL); return p->kva ? 0 : -ENOMEM; } -static inline void efhw_page_free(efhw_page_t *p) +static inline void efhw_page_free(struct efhw_page *p) { free_page(p->kva); EFHW_DO_DEBUG(memset(p, 0, sizeof(*p))); } -static inline char *efhw_page_ptr(efhw_page_t *p) +static inline char *efhw_page_ptr(struct efhw_page *p) { return (char *)p->kva; } -static inline unsigned efhw_page_pfn(efhw_page_t *p) +static inline unsigned efhw_page_pfn(struct efhw_page *p) { return (unsigned)(__pa(p->kva) >> PAGE_SHIFT); } -static inline void efhw_page_mark_invalid(efhw_page_t *p) +static inline void efhw_page_mark_invalid(struct efhw_page *p) { p->kva = 0; } -static inline int efhw_page_is_valid(efhw_page_t *p) +static inline int efhw_page_is_valid(struct efhw_page *p) { return p->kva != 0; } -static inline void efhw_page_init_from_va(efhw_page_t *p, void *va) +static inline void efhw_page_init_from_va(struct efhw_page *p, void *va) { p->kva = (unsigned long)va; } /*-------------------------------------------------------------------- * - * efhw_iopage_t: A single page of memory. Directly mapped in the driver, + * struct efhw_iopage: A single page of memory. Directly mapped in the driver, * and can be mapped to userlevel. Can also be accessed by the NIC. * *--------------------------------------------------------------------*/ -typedef struct { - efhw_page_t p; +struct efhw_iopage { + struct efhw_page p; dma_addr_t dma_addr; -} efhw_iopage_t; +}; -static inline dma_addr_t efhw_iopage_dma_addr(efhw_iopage_t *p) +static inline dma_addr_t efhw_iopage_dma_addr(struct efhw_iopage *p) { return p->dma_addr; } @@ -120,9 +122,9 @@ static inline dma_addr_t efhw_iopage_dma /*-------------------------------------------------------------------- * - * efhw_iopages_t: A set of pages that are contiguous in physical memory. - * Directly mapped in the driver, and can be mapped to userlevel. Can also - * be accessed by the NIC. + * struct efhw_iopages: A set of pages that are contiguous in physical + * memory. Directly mapped in the driver, and can be mapped to userlevel. + * Can also be accessed by the NIC. * * NB. The O/S may be unwilling to allocate many, or even any of these. So * only use this type where the NIC really needs a physically contiguous @@ -130,44 +132,44 @@ static inline dma_addr_t efhw_iopage_dma * *--------------------------------------------------------------------*/ -typedef struct { +struct efhw_iopages { caddr_t kva; unsigned order; dma_addr_t dma_addr; -} efhw_iopages_t; +}; -static inline caddr_t efhw_iopages_ptr(efhw_iopages_t *p) +static inline caddr_t efhw_iopages_ptr(struct efhw_iopages *p) { return p->kva; } -static inline unsigned efhw_iopages_pfn(efhw_iopages_t *p) +static inline unsigned efhw_iopages_pfn(struct efhw_iopages *p) { return (unsigned)(__pa(p->kva) >> PAGE_SHIFT); } -static inline dma_addr_t efhw_iopages_dma_addr(efhw_iopages_t *p) +static inline dma_addr_t efhw_iopages_dma_addr(struct efhw_iopages *p) { return p->dma_addr; } -static inline unsigned efhw_iopages_size(efhw_iopages_t *p) +static inline unsigned efhw_iopages_size(struct efhw_iopages *p) { return 1u << (p->order + PAGE_SHIFT); } -/* efhw_iopage_t <-> efhw_iopages_t conversions for handling physically - * contiguous allocations in iobufsets for iSCSI. This allows the - * essential information about contiguous allocations from - * efhw_iopages_alloc() to be saved away in the efhw_iopage_t array in an - * iobufset. (Changing the iobufset resource to use a union type would +/* struct efhw_iopage <-> struct efhw_iopages conversions for handling + * physically contiguous allocations in iobufsets for iSCSI. This allows + * the essential information about contiguous allocations from + * efhw_iopages_alloc() to be saved away in the struct efhw_iopage array in + * an iobufset. (Changing the iobufset resource to use a union type would * involve a lot of code changes, and make the iobufset's metadata larger * which could be bad as it's supposed to fit into a single page on some * platforms.) */ static inline void -efhw_iopage_init_from_iopages(efhw_iopage_t *iopage, - efhw_iopages_t *iopages, unsigned pageno) +efhw_iopage_init_from_iopages(struct efhw_iopage *iopage, + struct efhw_iopages *iopages, unsigned pageno) { iopage->p.kva = ((unsigned long)efhw_iopages_ptr(iopages)) + (pageno * PAGE_SIZE); @@ -176,8 +178,8 @@ efhw_iopage_init_from_iopages(efhw_iopag } static inline void -efhw_iopages_init_from_iopage(efhw_iopages_t *iopages, - efhw_iopage_t *iopage, unsigned order) +efhw_iopages_init_from_iopage(struct efhw_iopages *iopages, + struct efhw_iopage *iopage, unsigned order) { iopages->kva = (caddr_t) efhw_iopage_ptr(iopage); EFHW_ASSERT(iopages->kva); --- sle11-2009-03-24.orig/drivers/xen/sfc_netback/ci/efhw/public.h 2009-03-30 16:16:28.000000000 +0200 +++ sle11-2009-03-24/drivers/xen/sfc_netback/ci/efhw/public.h 2009-03-30 16:00:09.000000000 +0200 @@ -70,11 +70,32 @@ int efhw_nic_event_queue_alloc_iobuffer( extern void falcon_nic_set_rx_usr_buf_size(struct efhw_nic *, int rx_usr_buf_size); +/*! Get RX filter search limits from RX_FILTER_CTL_REG. + * use_raw_values = 0 to get actual depth of search, or 1 to get raw values + * from register. + */ +extern void +falcon_nic_get_rx_filter_search_limits(struct efhw_nic *nic, + struct efhw_filter_search_limits *lim, + int use_raw_values); + +/*! Set RX filter search limits in RX_FILTER_CTL_REG. + * use_raw_values = 0 if specifying actual depth of search, or 1 if specifying + * raw values to write to the register. + */ +extern void +falcon_nic_set_rx_filter_search_limits(struct efhw_nic *nic, + struct efhw_filter_search_limits *lim, + int use_raw_values); + + +/*! Legacy RX IP filter search depth control interface */ extern void falcon_nic_rx_filter_ctl_set(struct efhw_nic *nic, uint32_t tcp_full, uint32_t tcp_wild, uint32_t udp_full, uint32_t udp_wild); +/*! Legacy RX IP filter search depth control interface */ extern void falcon_nic_rx_filter_ctl_get(struct efhw_nic *nic, uint32_t *tcp_full, uint32_t *tcp_wild, --- sle11-2009-03-24.orig/drivers/xen/sfc_netback/ci/efhw/sysdep.h 2009-03-30 16:16:28.000000000 +0200 +++ sle11-2009-03-24/drivers/xen/sfc_netback/ci/efhw/sysdep.h 2009-03-30 16:00:09.000000000 +0200 @@ -39,34 +39,17 @@ #ifndef __CI_EFHW_SYSDEP_LINUX_H__ #define __CI_EFHW_SYSDEP_LINUX_H__ -#include #include #include #include +#include #include #include /* necessary for etherdevice.h on some kernels */ #include -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,21) -static inline int is_local_ether_addr(const u8 *addr) -{ - return (0x02 & addr[0]); -} -#endif - typedef unsigned long irq_flags_t; #define spin_lock_destroy(l_) do {} while (0) -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24) -#define HAS_NET_NAMESPACE -#endif - -/* Funny, but linux has round_up for x86 only, defined in - * x86-specific header */ -#ifndef round_up -#define round_up(x, y) (((x) + (y) - 1) & ~((y)-1)) -#endif - #endif /* __CI_EFHW_SYSDEP_LINUX_H__ */ --- sle11-2009-03-24.orig/drivers/xen/sfc_netback/ci/efrm/nic_table.h 2009-03-30 16:16:28.000000000 +0200 +++ sle11-2009-03-24/drivers/xen/sfc_netback/ci/efrm/nic_table.h 2009-03-30 16:09:06.000000000 +0200 @@ -62,21 +62,21 @@ struct efrm_nic_table { }; /* Resource driver structures used by other drivers as well */ -extern struct efrm_nic_table efrm_nic_table; +extern struct efrm_nic_table *efrm_nic_tablep; static inline void efrm_nic_table_hold(void) { - atomic_inc(&efrm_nic_table.ref_count); + atomic_inc(&efrm_nic_tablep->ref_count); } static inline void efrm_nic_table_rele(void) { - atomic_dec(&efrm_nic_table.ref_count); + atomic_dec(&efrm_nic_tablep->ref_count); } static inline int efrm_nic_table_held(void) { - return (atomic_read(&efrm_nic_table.ref_count) != 0); + return atomic_read(&efrm_nic_tablep->ref_count) != 0; } /* Run code block _x multiple times with variable nic set to each @@ -86,13 +86,13 @@ static inline int efrm_nic_table_held(vo for ((_nic_i) = (efrm_nic_table_hold(), 0); \ (_nic_i) < EFHW_MAX_NR_DEVS || (efrm_nic_table_rele(), 0); \ (_nic_i)++) \ - if (((_nic) = efrm_nic_table.nic[_nic_i])) + if (((_nic) = efrm_nic_tablep->nic[_nic_i])) #define EFRM_FOR_EACH_NIC_IN_SET(_set, _i, _nic) \ for ((_i) = (efrm_nic_table_hold(), 0); \ (_i) < EFHW_MAX_NR_DEVS || (efrm_nic_table_rele(), 0); \ ++(_i)) \ - if (((_nic) = efrm_nic_table.nic[_i]) && \ + if (((_nic) = efrm_nic_tablep->nic[_i]) && \ efrm_nic_set_read((_set), (_i))) #endif /* __CI_EFRM_NIC_TABLE_H__ */ --- sle11-2009-03-24.orig/drivers/xen/sfc_netback/ci/efrm/sysdep.h 2009-03-30 16:16:28.000000000 +0200 +++ sle11-2009-03-24/drivers/xen/sfc_netback/ci/efrm/sysdep.h 2009-03-30 16:00:09.000000000 +0200 @@ -41,14 +41,6 @@ /* Spinlocks are defined in efhw/sysdep.h */ #include -#if defined(__linux__) && defined(__KERNEL__) - -# include - -#else - -# include - -#endif +#include #endif /* __CI_EFRM_SYSDEP_H__ */ --- sle11-2009-03-24.orig/drivers/xen/sfc_netback/ci/efrm/sysdep_linux.h 2009-03-30 16:16:28.000000000 +0200 +++ sle11-2009-03-24/drivers/xen/sfc_netback/ci/efrm/sysdep_linux.h 2009-03-30 16:00:09.000000000 +0200 @@ -42,7 +42,6 @@ #ifndef __CI_EFRM_SYSDEP_LINUX_H__ #define __CI_EFRM_SYSDEP_LINUX_H__ -#include #include #include #include @@ -55,28 +54,15 @@ #include #include #include - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) -/* get roundup_pow_of_two(), which was in kernel.h in early kernel versions */ #include -#endif +#include + /******************************************************************** * * List API * ********************************************************************/ -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) -static inline void -list_replace_init(struct list_head *old, struct list_head *new) -{ - new->next = old->next; - new->next->prev = new; - new->prev = old->prev; - new->prev->next = new; - INIT_LIST_HEAD(old); -} -#endif static inline struct list_head *list_pop(struct list_head *list) { @@ -94,151 +80,10 @@ static inline struct list_head *list_pop /******************************************************************** * - * Workqueue API - * - ********************************************************************/ - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) -#define NEED_OLD_WORK_API - -/** - * The old and new work function prototypes just change - * the type of the pointer in the only argument, so it's - * safe to cast one function type to the other - */ -typedef void (*efrm_old_work_func_t) (void *p); - -#undef INIT_WORK -#define INIT_WORK(_work, _func) \ - do { \ - INIT_LIST_HEAD(&(_work)->entry); \ - (_work)->pending = 0; \ - PREPARE_WORK((_work), \ - (efrm_old_work_func_t) (_func), \ - (_work)); \ - } while (0) - -#endif - -/******************************************************************** - * * Kfifo API * ********************************************************************/ -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10) - -#if !defined(RHEL_RELEASE_CODE) || (RHEL_RELEASE_CODE < 1029) -typedef unsigned gfp_t; -#endif - -#define HAS_NO_KFIFO - -struct kfifo { - unsigned char *buffer; /* the buffer holding the data */ - unsigned int size; /* the size of the allocated buffer */ - unsigned int in; /* data is added at offset (in % size) */ - unsigned int out; /* data is extracted from off. (out % size) */ - spinlock_t *lock; /* protects concurrent modifications */ -}; - -extern struct kfifo *kfifo_init(unsigned char *buffer, unsigned int size, - gfp_t gfp_mask, spinlock_t *lock); -extern struct kfifo *kfifo_alloc(unsigned int size, gfp_t gfp_mask, - spinlock_t *lock); -extern void kfifo_free(struct kfifo *fifo); -extern unsigned int __kfifo_put(struct kfifo *fifo, - unsigned char *buffer, unsigned int len); -extern unsigned int __kfifo_get(struct kfifo *fifo, - unsigned char *buffer, unsigned int len); - -/** - * kfifo_put - puts some data into the FIFO - * @fifo: the fifo to be used. - * @buffer: the data to be added. - * @len: the length of the data to be added. - * - * This function copies at most @len bytes from the @buffer into - * the FIFO depending on the free space, and returns the number of - * bytes copied. - */ -static inline unsigned int -kfifo_put(struct kfifo *fifo, unsigned char *buffer, unsigned int len) -{ - unsigned long flags; - unsigned int ret; - - spin_lock_irqsave(fifo->lock, flags); - - ret = __kfifo_put(fifo, buffer, len); - - spin_unlock_irqrestore(fifo->lock, flags); - - return ret; -} - -/** - * kfifo_get - gets some data from the FIFO - * @fifo: the fifo to be used. - * @buffer: where the data must be copied. - * @len: the size of the destination buffer. - * - * This function copies at most @len bytes from the FIFO into the - * @buffer and returns the number of copied bytes. - */ -static inline unsigned int -kfifo_get(struct kfifo *fifo, unsigned char *buffer, unsigned int len) -{ - unsigned long flags; - unsigned int ret; - - spin_lock_irqsave(fifo->lock, flags); - - ret = __kfifo_get(fifo, buffer, len); - - /* - * optimization: if the FIFO is empty, set the indices to 0 - * so we don't wrap the next time - */ - if (fifo->in == fifo->out) - fifo->in = fifo->out = 0; - - spin_unlock_irqrestore(fifo->lock, flags); - - return ret; -} - -/** - * __kfifo_len - returns the number of bytes available in the FIFO, no locking version - * @fifo: the fifo to be used. - */ -static inline unsigned int __kfifo_len(struct kfifo *fifo) -{ - return fifo->in - fifo->out; -} - -/** - * kfifo_len - returns the number of bytes available in the FIFO - * @fifo: the fifo to be used. - */ -static inline unsigned int kfifo_len(struct kfifo *fifo) -{ - unsigned long flags; - unsigned int ret; - - spin_lock_irqsave(fifo->lock, flags); - - ret = __kfifo_len(fifo); - - spin_unlock_irqrestore(fifo->lock, flags); - - return ret; -} - -#else -#include -#endif - static inline void kfifo_vfree(struct kfifo *fifo) { vfree(fifo->buffer);