Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
988d2c13cd | ||
|
|
dced22d6de | ||
|
|
485f8ce554 | ||
|
|
da491eaae7 | ||
|
|
68f1914aae | ||
|
|
ce841946df | ||
|
|
47098d7cb1 | ||
|
|
6769a7c3c6 | ||
|
|
fb91542f2a | ||
|
|
f47a45ea2d | ||
|
|
f43a8f8b9f | ||
|
|
6a8664d9ec | ||
|
|
3475f9162b | ||
|
|
e3eedb0be5 | ||
|
|
39f5293492 | ||
|
|
6e92d6213d | ||
|
|
be47c2c72c | ||
|
|
1b112e9d18 | ||
|
|
e4b6328c84 | ||
|
|
e33f521081 | ||
|
|
25b53afa5b | ||
|
|
2b6b02ee7e | ||
|
|
09fe2bbd34 | ||
|
|
cb0ba2f825 | ||
|
|
b6e2ea03b0 | ||
|
|
63625b43e9 | ||
|
|
354c252ee1 | ||
|
|
be49380f55 | ||
|
|
13a6d17296 | ||
|
|
6e01b74a8a | ||
|
|
a8442750e6 | ||
|
|
a2e5cf1a3f | ||
|
|
9ff61ab28d | ||
|
|
8d337ecdae | ||
|
|
70e6e83243 | ||
|
|
cf12a41703 | ||
|
|
24ef743778 | ||
|
|
9e280aecb7 | ||
|
|
0b5467b658 | ||
|
|
1295b4acff | ||
|
|
03314e8da9 | ||
|
|
76a7bfe939 | ||
|
|
b6eb17cbd7 | ||
|
|
e10a40d41f | ||
|
|
062711f1cf | ||
|
|
810dc5d6c3 | ||
|
|
fc5cf18dab | ||
|
|
83b8c0e211 | ||
|
|
5439329c99 | ||
|
|
0e26220902 | ||
|
|
580d9b00da | ||
|
|
38a54bd3b1 | ||
|
|
dda03c884d | ||
|
|
be1c87b722 | ||
|
|
36dde9b0bf | ||
|
|
f560e7b70b | ||
|
|
9b25f6e5cf | ||
|
|
16873703dd | ||
|
|
e5e2f3fba8 | ||
|
|
5b41b9a80f | ||
|
|
86c6c79fcd | ||
|
|
a2e44077cd | ||
|
|
bf051a76ee | ||
|
|
e6f9054d13 | ||
|
|
334f0074b1 | ||
|
|
04cb17de50 | ||
|
|
2d49ce6f08 | ||
|
|
6154b1fb20 | ||
|
|
b50ad5f09a | ||
|
|
f2c826179a | ||
|
|
1e8648f611 | ||
|
|
87e39a9c93 | ||
|
|
2091288eaa | ||
|
|
2bf0fd39ca | ||
|
|
bcf858c56d | ||
|
|
c504c1d693 | ||
|
|
49fd66a8c9 | ||
|
|
6ccd5239b1 | ||
|
|
0c25daad38 | ||
|
|
388d657080 | ||
|
|
3d43789914 | ||
|
|
02748d0a58 | ||
|
|
6d680bdec5 | ||
|
|
88288407af | ||
|
|
e30c26d01c | ||
|
|
ebf0166081 | ||
|
|
c70b3e04e8 | ||
|
|
fbb5989fd9 | ||
|
|
eede697ece | ||
|
|
0220141710 | ||
|
|
02280dc642 | ||
|
|
7c6fdf57ea | ||
|
|
7151fa3ffa | ||
|
|
8344803c93 | ||
|
|
8eb19a178a | ||
|
|
627b0ba2a0 | ||
|
|
fbb776f2f2 | ||
|
|
f42ba772c8 | ||
|
|
27e886c67b | ||
|
|
eecb75ba48 | ||
|
|
371af4eef2 | ||
|
|
ccfffc797a | ||
|
|
fe69934191 | ||
|
|
e08ad61bf7 | ||
|
|
4bd064de23 | ||
|
|
ef2c844d01 | ||
|
|
c63e61df75 | ||
|
|
fd47fa8fe1 | ||
|
|
70b1a641c5 | ||
|
|
b760523357 | ||
|
|
a08ee6e722 | ||
|
|
145311c62e | ||
|
|
afaf4272b1 | ||
|
|
c4d1ae0fcd | ||
|
|
8bc85ec6fa | ||
|
|
8d243e65c3 | ||
|
|
ee2dc525b4 | ||
|
|
0de5e60144 | ||
|
|
6ec33b8d6c | ||
|
|
45a0ca6de2 | ||
|
|
cede0c5ba1 | ||
|
|
4277942ac0 | ||
|
|
366206517e | ||
|
|
a95a2eafc5 | ||
|
|
78ca890c35 | ||
|
|
1832f8a9b0 | ||
|
|
b6eecb182e | ||
|
|
fcdd9c0982 | ||
|
|
f7ddda435c | ||
|
|
98d49e460a | ||
|
|
2f032c84a2 | ||
|
|
d2fb317fee | ||
|
|
586b723733 | ||
|
|
f727ed8a11 | ||
|
|
0f5d234335 | ||
|
|
e87760183d | ||
|
|
18d4be8aaf | ||
|
|
761ed4365a | ||
|
|
8ff5babb47 | ||
|
|
5d6fb72829 | ||
|
|
d5874c9f2b | ||
|
|
2ae5d43386 | ||
|
|
a87537d44c | ||
|
|
decee20ec8 | ||
|
|
8a1d66c7ae | ||
|
|
28cf9806d1 | ||
|
|
f982a71297 | ||
|
|
3f637d7462 | ||
|
|
a61b27b97f | ||
|
|
8830f2f351 | ||
|
|
2000297011 | ||
|
|
770a7bd43a | ||
|
|
7f2006a9ad | ||
|
|
bb74f00512 | ||
|
|
bd7a5e4b9c | ||
|
|
dc785b0fb6 | ||
|
|
2dac11eb1d | ||
|
|
9ee70fb95b | ||
|
|
6a6def775d | ||
|
|
ac28bbb7ea | ||
|
|
18d2162f64 | ||
|
|
d68befef1a | ||
|
|
ebff21a515 | ||
|
|
bdf0e029ae | ||
|
|
efc1ae5aba | ||
|
|
49319f1bc9 | ||
|
|
e3ca211071 | ||
|
|
e2e29e7ae3 | ||
|
|
446e8f14e8 | ||
|
|
0a74321915 | ||
|
|
c5306bcfa5 | ||
|
|
6248ac396a | ||
|
|
c625681ca1 | ||
|
|
18dc73d27e |
@@ -2,6 +2,9 @@ dist: trusty
|
||||
|
||||
sudo: false
|
||||
|
||||
git:
|
||||
depth: false
|
||||
|
||||
language: c
|
||||
|
||||
cache: ccache
|
||||
|
||||
@@ -74,6 +74,7 @@ SRCDIRS += drivers/net/phantom
|
||||
SRCDIRS += drivers/net/vxge
|
||||
SRCDIRS += drivers/net/efi
|
||||
SRCDIRS += drivers/net/tg3
|
||||
SRCDIRS += drivers/net/bnxt
|
||||
SRCDIRS += drivers/net/sfc
|
||||
SRCDIRS += drivers/block
|
||||
SRCDIRS += drivers/nvs
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
# -*- makefile -*- : Force emacs to use Makefile mode
|
||||
|
||||
# Enable stack protection if available
|
||||
#
|
||||
SPG_TEST = $(CC) -fstack-protector-strong -mstack-protector-guard=global \
|
||||
-x c -c /dev/null -o /dev/null >/dev/null 2>&1
|
||||
SPG_FLAGS := $(shell $(SPG_TEST) && $(ECHO) '-fstack-protector-strong ' \
|
||||
'-mstack-protector-guard=global')
|
||||
CFLAGS += $(SPG_FLAGS)
|
||||
|
||||
# The EFI linker script
|
||||
#
|
||||
LDSCRIPT = scripts/efi.lds
|
||||
|
||||
+10
-13
@@ -146,17 +146,6 @@ define NEWLINE
|
||||
|
||||
endef
|
||||
|
||||
# Some widespread patched versions of gcc include -fstack-protector by
|
||||
# default, even when -ffreestanding is specified. We therefore need
|
||||
# to disable -fstack-protector if the compiler supports it.
|
||||
#
|
||||
ifeq ($(CCTYPE),gcc)
|
||||
SP_TEST = $(CC) -fno-stack-protector -x c -c /dev/null \
|
||||
-o /dev/null >/dev/null 2>&1
|
||||
SP_FLAGS := $(shell $(SP_TEST) && $(ECHO) '-fno-stack-protector')
|
||||
WORKAROUND_CFLAGS += $(SP_FLAGS)
|
||||
endif
|
||||
|
||||
# gcc 4.4 generates .eh_frame sections by default, which distort the
|
||||
# output of "size". Inhibit this.
|
||||
#
|
||||
@@ -353,7 +342,7 @@ arch :
|
||||
# Determine build platform
|
||||
DEFAULT_PLATFORM := pcbios
|
||||
PLATFORM := $(firstword $(BIN_PLATFORM) $(DEFAULT_PLATFORM))
|
||||
CFLAGS += -DPLATFORM=$(PLATFORM)
|
||||
CFLAGS += -DPLATFORM=$(PLATFORM) -DPLATFORM_$(PLATFORM)
|
||||
platform :
|
||||
@$(ECHO) $(PLATFORM)
|
||||
|
||||
@@ -415,6 +404,13 @@ ifdef BIN
|
||||
incdirs :
|
||||
@$(ECHO) $(INCDIRS)
|
||||
|
||||
# Inhibit -fstack-protector (which is implicitly enabled in some
|
||||
# patched gcc versions) unless explicitly mentioned in CFLAGS.
|
||||
#
|
||||
ifeq ($(findstring -fstack-protector,$(CFLAGS)),)
|
||||
CFLAGS += -fno-stack-protector
|
||||
endif
|
||||
|
||||
# Common flags
|
||||
#
|
||||
CFLAGS += $(foreach INC,$(INCDIRS),-I$(INC))
|
||||
@@ -422,6 +418,7 @@ CFLAGS += -Os
|
||||
CFLAGS += -g
|
||||
ifeq ($(CCTYPE),gcc)
|
||||
CFLAGS += -ffreestanding
|
||||
CFLAGS += -fcommon
|
||||
CFLAGS += -Wall -W -Wformat-nonliteral
|
||||
HOST_CFLAGS += -Wall -W -Wformat-nonliteral
|
||||
endif
|
||||
@@ -859,7 +856,7 @@ define deps_template_parts
|
||||
@$(MKDIR) -p $(BIN)/deps/$(dir $(1))
|
||||
$(Q)$(CPP) $(CFLAGS) $(CFLAGS_$(2)) $(CFLAGS_$(3)) -DOBJECT=$(3) \
|
||||
-Wno-error -M $(1) -MG -MP | \
|
||||
sed 's/\.o\s*:/_DEPS +=/' > $(BIN)/deps/$(1).d
|
||||
sed 's/\.o[[:blank:]]*:/_DEPS +=/' > $(BIN)/deps/$(1).d
|
||||
endef
|
||||
|
||||
# rules_template : generate rules for a given source file
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
# -*- makefile -*- : Force emacs to use Makefile mode
|
||||
|
||||
# Avoid untranslatable relocations
|
||||
#
|
||||
CFLAGS += -fno-pic
|
||||
|
||||
# Specify EFI image builder
|
||||
#
|
||||
ELF2EFI = $(ELF2EFI64)
|
||||
|
||||
@@ -52,3 +52,4 @@ PROVIDE_PCIAPI_INLINE ( direct, pci_read_config_dword );
|
||||
PROVIDE_PCIAPI_INLINE ( direct, pci_write_config_byte );
|
||||
PROVIDE_PCIAPI_INLINE ( direct, pci_write_config_word );
|
||||
PROVIDE_PCIAPI_INLINE ( direct, pci_write_config_dword );
|
||||
PROVIDE_PCIAPI_INLINE ( direct, pci_ioremap );
|
||||
|
||||
@@ -30,6 +30,14 @@
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
|
||||
#include <string.h>
|
||||
#include <config/defaults.h>
|
||||
|
||||
/* Use generic_memcpy_reverse() if we cannot safely set the direction flag */
|
||||
#ifdef UNSAFE_STD
|
||||
#define USE_GENERIC_MEMCPY_REVERSE 1
|
||||
#else
|
||||
#define USE_GENERIC_MEMCPY_REVERSE 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Copy memory area
|
||||
@@ -77,6 +85,12 @@ void * __attribute__ (( noinline )) __memcpy_reverse ( void *dest,
|
||||
const void *esi = ( src + len - 1 );
|
||||
int discard_ecx;
|
||||
|
||||
/* Use unoptimised version if we are not permitted to modify
|
||||
* the direction flag.
|
||||
*/
|
||||
if ( USE_GENERIC_MEMCPY_REVERSE )
|
||||
return generic_memcpy_reverse ( dest, src, len );
|
||||
|
||||
/* Assume memmove() is not performance-critical, and perform a
|
||||
* bytewise copy for simplicity.
|
||||
*/
|
||||
|
||||
@@ -83,7 +83,7 @@ hv_alloc_pages ( struct hv_hypervisor *hv, ... ) {
|
||||
/* Allocate and zero pages */
|
||||
va_start ( args, hv );
|
||||
for ( i = 0 ; ( ( page = va_arg ( args, void ** ) ) != NULL ); i++ ) {
|
||||
*page = malloc_dma ( PAGE_SIZE, PAGE_SIZE );
|
||||
*page = malloc_phys ( PAGE_SIZE, PAGE_SIZE );
|
||||
if ( ! *page )
|
||||
goto err_alloc;
|
||||
memset ( *page, 0, PAGE_SIZE );
|
||||
@@ -97,7 +97,7 @@ hv_alloc_pages ( struct hv_hypervisor *hv, ... ) {
|
||||
va_start ( args, hv );
|
||||
for ( ; i >= 0 ; i-- ) {
|
||||
page = va_arg ( args, void ** );
|
||||
free_dma ( *page, PAGE_SIZE );
|
||||
free_phys ( *page, PAGE_SIZE );
|
||||
}
|
||||
va_end ( args );
|
||||
return -ENOMEM;
|
||||
@@ -116,7 +116,7 @@ hv_free_pages ( struct hv_hypervisor *hv, ... ) {
|
||||
|
||||
va_start ( args, hv );
|
||||
while ( ( page = va_arg ( args, void * ) ) != NULL )
|
||||
free_dma ( page, PAGE_SIZE );
|
||||
free_phys ( page, PAGE_SIZE );
|
||||
va_end ( args );
|
||||
}
|
||||
|
||||
@@ -131,8 +131,8 @@ static int hv_alloc_message ( struct hv_hypervisor *hv ) {
|
||||
/* Allocate buffer. Must be aligned to at least 8 bytes and
|
||||
* must not cross a page boundary, so align on its own size.
|
||||
*/
|
||||
hv->message = malloc_dma ( sizeof ( *hv->message ),
|
||||
sizeof ( *hv->message ) );
|
||||
hv->message = malloc_phys ( sizeof ( *hv->message ),
|
||||
sizeof ( *hv->message ) );
|
||||
if ( ! hv->message )
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -147,7 +147,7 @@ static int hv_alloc_message ( struct hv_hypervisor *hv ) {
|
||||
static void hv_free_message ( struct hv_hypervisor *hv ) {
|
||||
|
||||
/* Free buffer */
|
||||
free_dma ( hv->message, sizeof ( *hv->message ) );
|
||||
free_phys ( hv->message, sizeof ( *hv->message ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -106,7 +106,7 @@ static int hvm_map_hypercall ( struct hvm_device *hvm ) {
|
||||
|
||||
/* Allocate pages */
|
||||
hvm->hypercall_len = ( pages * PAGE_SIZE );
|
||||
hvm->xen.hypercall = malloc_dma ( hvm->hypercall_len, PAGE_SIZE );
|
||||
hvm->xen.hypercall = malloc_phys ( hvm->hypercall_len, PAGE_SIZE );
|
||||
if ( ! hvm->xen.hypercall ) {
|
||||
DBGC ( hvm, "HVM could not allocate %d hypercall page(s)\n",
|
||||
pages );
|
||||
@@ -141,7 +141,7 @@ static int hvm_map_hypercall ( struct hvm_device *hvm ) {
|
||||
static void hvm_unmap_hypercall ( struct hvm_device *hvm ) {
|
||||
|
||||
/* Free pages */
|
||||
free_dma ( hvm->xen.hypercall, hvm->hypercall_len );
|
||||
free_phys ( hvm->xen.hypercall, hvm->hypercall_len );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -175,7 +175,7 @@ static void * hvm_ioremap ( struct hvm_device *hvm, unsigned int space,
|
||||
}
|
||||
|
||||
/* Map this space */
|
||||
mmio = ioremap ( ( hvm->mmio + hvm->mmio_offset ), len );
|
||||
mmio = pci_ioremap ( hvm->pci, ( hvm->mmio + hvm->mmio_offset ), len );
|
||||
if ( ! mmio ) {
|
||||
DBGC ( hvm, "HVM could not map MMIO space [%08lx,%08lx)\n",
|
||||
( hvm->mmio + hvm->mmio_offset ),
|
||||
@@ -371,7 +371,8 @@ static int hvm_map_xenstore ( struct hvm_device *hvm ) {
|
||||
xenstore_phys = ( xenstore_pfn * PAGE_SIZE );
|
||||
|
||||
/* Map XenStore */
|
||||
hvm->xen.store.intf = ioremap ( xenstore_phys, PAGE_SIZE );
|
||||
hvm->xen.store.intf = pci_ioremap ( hvm->pci, xenstore_phys,
|
||||
PAGE_SIZE );
|
||||
if ( ! hvm->xen.store.intf ) {
|
||||
DBGC ( hvm, "HVM could not map XenStore at [%08lx,%08lx)\n",
|
||||
xenstore_phys, ( xenstore_phys + PAGE_SIZE ) );
|
||||
@@ -420,6 +421,7 @@ static int hvm_probe ( struct pci_device *pci ) {
|
||||
rc = -ENOMEM;
|
||||
goto err_alloc;
|
||||
}
|
||||
hvm->pci = pci;
|
||||
hvm->mmio = pci_bar_start ( pci, HVM_MMIO_BAR );
|
||||
hvm->mmio_len = pci_bar_size ( pci, HVM_MMIO_BAR );
|
||||
DBGC2 ( hvm, "HVM has MMIO space [%08lx,%08lx)\n",
|
||||
|
||||
@@ -39,6 +39,8 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
struct hvm_device {
|
||||
/** Xen hypervisor */
|
||||
struct xen_hypervisor xen;
|
||||
/** PCI device */
|
||||
struct pci_device *pci;
|
||||
/** CPUID base */
|
||||
uint32_t cpuid_base;
|
||||
/** Length of hypercall table */
|
||||
|
||||
@@ -110,7 +110,7 @@ static int com32_exec_loop ( struct image *image ) {
|
||||
/* Disable interrupts */
|
||||
"cli\n\t"
|
||||
/* Restore stack pointer */
|
||||
"movl 24(%%esp), %%esp\n\t"
|
||||
"movl 28(%%esp), %%esp\n\t"
|
||||
/* Restore registers */
|
||||
"popal\n\t" )
|
||||
:
|
||||
|
||||
@@ -167,28 +167,19 @@ bigint_is_zero_raw ( const uint32_t *value0, unsigned int size ) {
|
||||
static inline __attribute__ (( always_inline, pure )) int
|
||||
bigint_is_geq_raw ( const uint32_t *value0, const uint32_t *reference0,
|
||||
unsigned int size ) {
|
||||
const bigint_t ( size ) __attribute__ (( may_alias )) *value =
|
||||
( ( const void * ) value0 );
|
||||
const bigint_t ( size ) __attribute__ (( may_alias )) *reference =
|
||||
( ( const void * ) reference0 );
|
||||
void *discard_S;
|
||||
void *discard_D;
|
||||
long discard_c;
|
||||
long discard_tmp;
|
||||
int result;
|
||||
|
||||
__asm__ __volatile__ ( "std\n\t"
|
||||
"\n1:\n\t"
|
||||
"lodsl\n\t"
|
||||
"scasl\n\t"
|
||||
__asm__ __volatile__ ( "\n1:\n\t"
|
||||
"movl -4(%3, %1, 4), %k2\n\t"
|
||||
"cmpl -4(%4, %1, 4), %k2\n\t"
|
||||
"loope 1b\n\t"
|
||||
"setae %b0\n\t"
|
||||
"cld\n\t"
|
||||
: "=q" ( result ), "=&S" ( discard_S ),
|
||||
"=&D" ( discard_D ), "=&c" ( discard_c )
|
||||
: "0" ( 0 ), "1" ( &value->element[ size - 1 ] ),
|
||||
"2" ( &reference->element[ size - 1 ] ),
|
||||
"3" ( size )
|
||||
: "eax" );
|
||||
: "=q" ( result ), "=&c" ( discard_c ),
|
||||
"=&r" ( discard_tmp )
|
||||
: "r" ( value0 ), "r" ( reference0 ),
|
||||
"0" ( 0 ), "1" ( size ) );
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -132,4 +132,17 @@ PCIAPI_INLINE ( pcbios, pci_write_config_dword ) ( struct pci_device *pci,
|
||||
return pcibios_write ( pci, PCIBIOS_WRITE_CONFIG_DWORD | where, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Map PCI bus address as an I/O address
|
||||
*
|
||||
* @v bus_addr PCI bus address
|
||||
* @v len Length of region
|
||||
* @ret io_addr I/O address, or NULL on error
|
||||
*/
|
||||
static inline __always_inline void *
|
||||
PCIAPI_INLINE ( pcbios, pci_ioremap ) ( struct pci_device *pci __unused,
|
||||
unsigned long bus_addr, size_t len ) {
|
||||
return ioremap ( bus_addr, len );
|
||||
}
|
||||
|
||||
#endif /* _IPXE_PCIBIOS_H */
|
||||
|
||||
@@ -138,4 +138,17 @@ PCIAPI_INLINE ( direct, pci_write_config_dword ) ( struct pci_device *pci,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Map PCI bus address as an I/O address
|
||||
*
|
||||
* @v bus_addr PCI bus address
|
||||
* @v len Length of region
|
||||
* @ret io_addr I/O address, or NULL on error
|
||||
*/
|
||||
static inline __always_inline void *
|
||||
PCIAPI_INLINE ( direct, pci_ioremap ) ( struct pci_device *pci __unused,
|
||||
unsigned long bus_addr, size_t len ) {
|
||||
return ioremap ( bus_addr, len );
|
||||
}
|
||||
|
||||
#endif /* _PCIDIRECT_H */
|
||||
|
||||
@@ -190,14 +190,14 @@ static userptr_t memtop_urealloc ( userptr_t ptr, size_t new_size ) {
|
||||
/* Expand/shrink block if possible */
|
||||
if ( ptr == bottom ) {
|
||||
/* Update block */
|
||||
if ( new_size > ( heap_size - extmem.size ) ) {
|
||||
DBG ( "EXTMEM out of space\n" );
|
||||
return UNULL;
|
||||
}
|
||||
new = userptr_add ( ptr, - ( new_size - extmem.size ) );
|
||||
align = ( user_to_phys ( new, 0 ) & ( EM_ALIGN - 1 ) );
|
||||
new_size += align;
|
||||
new = userptr_add ( new, -align );
|
||||
if ( new_size > ( heap_size + extmem.size ) ) {
|
||||
DBG ( "EXTMEM out of space\n" );
|
||||
return UNULL;
|
||||
}
|
||||
DBG ( "EXTMEM expanding [%lx,%lx) to [%lx,%lx)\n",
|
||||
user_to_phys ( ptr, 0 ),
|
||||
user_to_phys ( ptr, extmem.size ),
|
||||
|
||||
@@ -121,3 +121,4 @@ PROVIDE_PCIAPI_INLINE ( pcbios, pci_read_config_dword );
|
||||
PROVIDE_PCIAPI_INLINE ( pcbios, pci_write_config_byte );
|
||||
PROVIDE_PCIAPI_INLINE ( pcbios, pci_write_config_word );
|
||||
PROVIDE_PCIAPI_INLINE ( pcbios, pci_write_config_dword );
|
||||
PROVIDE_PCIAPI_INLINE ( pcbios, pci_ioremap );
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||
|
||||
#include <config/console.h>
|
||||
|
||||
.text
|
||||
.arch i386
|
||||
.section ".prefix", "awx", @progbits
|
||||
@@ -9,26 +11,68 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||
#include "mbr.S"
|
||||
|
||||
/* Partition table: 64 heads, 32 sectors/track (ZIP-drive compatible) */
|
||||
#define HEADS 64
|
||||
#define SECTORS 32
|
||||
#define CYLADDR(cyl) ((((cyl) * HEADS + (((cyl) == 0) & 1)) * SECTORS) * 512)
|
||||
|
||||
#ifdef CONSOLE_INT13
|
||||
#define LOGPART 1
|
||||
#define LOGSTART 0
|
||||
#define LOGCOUNT 1
|
||||
#define BOOTSTART 1
|
||||
#define BOOTCOUNT 2
|
||||
#else /* CONSOLE_INT13 */
|
||||
#define LOGPART 0
|
||||
#define BOOTSTART 0
|
||||
#define BOOTCOUNT 2
|
||||
#endif /* CONSOLE_INT13 */
|
||||
|
||||
/* Construct a C/H/S address */
|
||||
.macro chs cylinder, head, sector
|
||||
.byte \head
|
||||
.byte (((\cylinder & 0x300) >> 2) | \sector)
|
||||
.byte (\cylinder & 0x0ff)
|
||||
.endm
|
||||
|
||||
/* Construct a linear address */
|
||||
.macro linear cylinders, heads, sectors
|
||||
.long ((((\cylinders * HEADS) + \heads) * SECTORS) + \sectors - 1)
|
||||
.endm
|
||||
|
||||
/* Construct a partition table entry */
|
||||
.macro partition bootflag, type, start, count
|
||||
.byte \bootflag
|
||||
chs \start, ((\start == 0) & 1), 1
|
||||
.byte \type
|
||||
chs (\start + \count - 1), (HEADS - 1), SECTORS
|
||||
linear \start, ((\start == 0) & 1), 1
|
||||
linear \count, 0, (1 - (((\start == 0) & 1) * SECTORS))
|
||||
.endm
|
||||
|
||||
/* Partition table */
|
||||
.org 446
|
||||
.space 16
|
||||
.space 16
|
||||
/* Partition 3: log partition (for CONSOLE_INT13) */
|
||||
.byte 0x00, 0x01, 0x01, 0x00
|
||||
.byte 0xe0, 0x3f, 0x20, 0x00
|
||||
.long 0x00000020
|
||||
.long 0x000007e0
|
||||
/* Partition 4: boot partition */
|
||||
.byte 0x80, 0x00, 0x01, 0x01
|
||||
.byte 0xeb, 0x3f, 0x20, 0x02
|
||||
.long 0x00000800
|
||||
.long 0x00001000
|
||||
|
||||
/* Partition 3: log partition (for CONSOLE_INT13) */
|
||||
.if LOGPART
|
||||
partition 0x00, 0xe0, LOGSTART, LOGCOUNT
|
||||
.else
|
||||
.space 16
|
||||
.endif
|
||||
|
||||
/* Partition 4: boot partition */
|
||||
partition 0x80, 0xeb, BOOTSTART, BOOTCOUNT
|
||||
|
||||
/* Disk signature */
|
||||
.org 510
|
||||
.byte 0x55, 0xaa
|
||||
|
||||
/* Skip to start of log partition */
|
||||
.org 32 * 512
|
||||
.if LOGPART
|
||||
.org CYLADDR(LOGSTART)
|
||||
.ascii "iPXE LOG\n\n"
|
||||
.endif
|
||||
|
||||
/* Skip to start of boot partition */
|
||||
.org 2048 * 512
|
||||
.org CYLADDR(BOOTSTART)
|
||||
|
||||
@@ -33,6 +33,56 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
|
||||
PROVIDE_REQUIRING_SYMBOL();
|
||||
|
||||
/* RSA */
|
||||
#if defined ( CRYPTO_PUBKEY_RSA )
|
||||
REQUIRE_OBJECT ( oid_rsa );
|
||||
#endif
|
||||
|
||||
/* MD4 */
|
||||
#if defined ( CRYPTO_DIGEST_MD4 )
|
||||
REQUIRE_OBJECT ( oid_md4 );
|
||||
#endif
|
||||
|
||||
/* MD5 */
|
||||
#if defined ( CRYPTO_DIGEST_MD5 )
|
||||
REQUIRE_OBJECT ( oid_md5 );
|
||||
#endif
|
||||
|
||||
/* SHA-1 */
|
||||
#if defined ( CRYPTO_DIGEST_SHA1 )
|
||||
REQUIRE_OBJECT ( oid_sha1 );
|
||||
#endif
|
||||
|
||||
/* SHA-224 */
|
||||
#if defined ( CRYPTO_DIGEST_SHA224 )
|
||||
REQUIRE_OBJECT ( oid_sha224 );
|
||||
#endif
|
||||
|
||||
/* SHA-256 */
|
||||
#if defined ( CRYPTO_DIGEST_SHA256 )
|
||||
REQUIRE_OBJECT ( oid_sha256 );
|
||||
#endif
|
||||
|
||||
/* SHA-384 */
|
||||
#if defined ( CRYPTO_DIGEST_SHA384 )
|
||||
REQUIRE_OBJECT ( oid_sha384 );
|
||||
#endif
|
||||
|
||||
/* SHA-512 */
|
||||
#if defined ( CRYPTO_DIGEST_SHA512 )
|
||||
REQUIRE_OBJECT ( oid_sha512 );
|
||||
#endif
|
||||
|
||||
/* SHA-512/224 */
|
||||
#if defined ( CRYPTO_DIGEST_SHA512_224 )
|
||||
REQUIRE_OBJECT ( oid_sha512_224 );
|
||||
#endif
|
||||
|
||||
/* SHA-512/256 */
|
||||
#if defined ( CRYPTO_DIGEST_SHA512_256 )
|
||||
REQUIRE_OBJECT ( oid_sha512_256 );
|
||||
#endif
|
||||
|
||||
/* RSA and MD5 */
|
||||
#if defined ( CRYPTO_PUBKEY_RSA ) && defined ( CRYPTO_DIGEST_MD5 )
|
||||
REQUIRE_OBJECT ( rsa_md5 );
|
||||
|
||||
@@ -53,6 +53,9 @@ REQUIRE_OBJECT ( usbio );
|
||||
#ifdef USB_KEYBOARD
|
||||
REQUIRE_OBJECT ( usbkbd );
|
||||
#endif
|
||||
#ifdef USB_BLOCK
|
||||
REQUIRE_OBJECT ( usbblk );
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Drag in USB external interfaces
|
||||
|
||||
+16
-13
@@ -9,31 +9,28 @@
|
||||
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
|
||||
/** Minimum TLS version */
|
||||
#define TLS_VERSION_MIN TLS_VERSION_TLS_1_1
|
||||
|
||||
/** RSA public-key algorithm */
|
||||
#define CRYPTO_PUBKEY_RSA
|
||||
|
||||
/** AES-CBC block cipher */
|
||||
#define CRYPTO_CIPHER_AES_CBC
|
||||
|
||||
/** MD5 digest algorithm
|
||||
*
|
||||
* Note that use of MD5 is implicit when using TLSv1.1 or earlier.
|
||||
*/
|
||||
#define CRYPTO_DIGEST_MD5
|
||||
/** MD4 digest algorithm */
|
||||
//#define CRYPTO_DIGEST_MD4
|
||||
|
||||
/** SHA-1 digest algorithm
|
||||
*
|
||||
* Note that use of SHA-1 is implicit when using TLSv1.1 or earlier.
|
||||
*/
|
||||
/** MD5 digest algorithm */
|
||||
//#define CRYPTO_DIGEST_MD5
|
||||
|
||||
/** SHA-1 digest algorithm */
|
||||
#define CRYPTO_DIGEST_SHA1
|
||||
|
||||
/** SHA-224 digest algorithm */
|
||||
#define CRYPTO_DIGEST_SHA224
|
||||
|
||||
/** SHA-256 digest algorithm
|
||||
*
|
||||
* Note that use of SHA-256 is implicit when using TLSv1.2.
|
||||
*/
|
||||
/** SHA-256 digest algorithm */
|
||||
#define CRYPTO_DIGEST_SHA256
|
||||
|
||||
/** SHA-384 digest algorithm */
|
||||
@@ -42,6 +39,12 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
/** SHA-512 digest algorithm */
|
||||
#define CRYPTO_DIGEST_SHA512
|
||||
|
||||
/** SHA-512/224 digest algorithm */
|
||||
//#define CRYPTO_DIGEST_SHA512_224
|
||||
|
||||
/** SHA-512/256 digest algorithm */
|
||||
//#define CRYPTO_DIGEST_SHA512_256
|
||||
|
||||
/** Margin of error (in seconds) allowed in signed timestamps
|
||||
*
|
||||
* We default to allowing a reasonable margin of error: 12 hours to
|
||||
|
||||
@@ -12,6 +12,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
#define UACCESS_EFI
|
||||
#define IOMAP_VIRT
|
||||
#define PCIAPI_EFI
|
||||
#define DMAAPI_OP
|
||||
#define CONSOLE_EFI
|
||||
#define TIMER_EFI
|
||||
#define UMALLOC_EFI
|
||||
@@ -24,6 +25,8 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
#define ACPI_EFI
|
||||
#define FDT_EFI
|
||||
|
||||
#define NET_PROTO_IPV6 /* IPv6 protocol */
|
||||
|
||||
#define DOWNLOAD_PROTO_FILE /* Local filesystem access */
|
||||
|
||||
#define IMAGE_EFI /* EFI image support */
|
||||
@@ -39,6 +42,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
#define USB_HCD_EHCI /* EHCI USB host controller */
|
||||
#define USB_HCD_UHCI /* UHCI USB host controller */
|
||||
#define USB_EFI /* Provide EFI_USB_IO_PROTOCOL interface */
|
||||
#define USB_BLOCK /* USB block devices */
|
||||
|
||||
#define REBOOT_CMD /* Reboot command */
|
||||
|
||||
@@ -46,6 +50,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
#define IOAPI_X86
|
||||
#define NAP_EFIX86
|
||||
#define CPUID_CMD /* x86 CPU feature detection command */
|
||||
#define UNSAFE_STD /* Avoid setting direction flag */
|
||||
#endif
|
||||
|
||||
#if defined ( __arm__ ) || defined ( __aarch64__ )
|
||||
|
||||
@@ -20,6 +20,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
||||
#define TIME_LINUX
|
||||
#define REBOOT_NULL
|
||||
#define PCIAPI_LINUX
|
||||
#define DMAAPI_FLAT
|
||||
|
||||
#define DRIVERS_LINUX
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
#define UACCESS_LIBRM
|
||||
#define IOAPI_X86
|
||||
#define PCIAPI_PCBIOS
|
||||
#define DMAAPI_FLAT
|
||||
#define TIMER_PCBIOS
|
||||
#define CONSOLE_PCBIOS
|
||||
#define NAP_PCBIOS
|
||||
@@ -48,6 +49,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
#define USB_HCD_EHCI /* EHCI USB host controller */
|
||||
#define USB_HCD_UHCI /* UHCI USB host controller */
|
||||
#define USB_KEYBOARD /* USB keyboards */
|
||||
#define USB_BLOCK /* USB block devices */
|
||||
|
||||
#define REBOOT_CMD /* Reboot command */
|
||||
#define CPUID_CMD /* x86 CPU feature detection command */
|
||||
|
||||
@@ -35,7 +35,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
*/
|
||||
|
||||
#define NET_PROTO_IPV4 /* IPv4 protocol */
|
||||
#undef NET_PROTO_IPV6 /* IPv6 protocol */
|
||||
//#define NET_PROTO_IPV6 /* IPv6 protocol */
|
||||
#undef NET_PROTO_FCOE /* Fibre Channel over Ethernet protocol */
|
||||
#define NET_PROTO_STP /* Spanning Tree protocol */
|
||||
#define NET_PROTO_LACP /* Link Aggregation control protocol */
|
||||
|
||||
@@ -25,6 +25,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
*
|
||||
*/
|
||||
//#undef USB_KEYBOARD /* USB keyboards */
|
||||
//#undef USB_BLOCK /* USB block devices */
|
||||
|
||||
/*
|
||||
* USB external interfaces
|
||||
|
||||
@@ -242,9 +242,7 @@ int block_translate ( struct interface *block, userptr_t buffer, size_t size ) {
|
||||
}
|
||||
|
||||
/* Attach to interfaces, mortalise self, and return */
|
||||
assert ( block->dest != &null_intf );
|
||||
intf_plug_plug ( &blktrans->xfer, block->dest );
|
||||
intf_plug_plug ( &blktrans->block, block );
|
||||
intf_insert ( block, &blktrans->block, &blktrans->xfer );
|
||||
ref_put ( &blktrans->refcnt );
|
||||
|
||||
DBGC2 ( blktrans, "BLKTRANS %p created", blktrans );
|
||||
|
||||
+179
@@ -0,0 +1,179 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Michael Brown <mbrown@fensystems.co.uk>.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*
|
||||
* You can also choose to distribute this program under the terms of
|
||||
* the Unmodified Binary Distribution Licence (as given in the file
|
||||
* COPYING.UBDL), provided that you have satisfied its requirements.
|
||||
*/
|
||||
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <ipxe/dma.h>
|
||||
|
||||
/** @file
|
||||
*
|
||||
* DMA mappings
|
||||
*
|
||||
*/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Flat address space DMA API
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
PROVIDE_DMAAPI_INLINE ( flat, dma_map );
|
||||
PROVIDE_DMAAPI_INLINE ( flat, dma_unmap );
|
||||
PROVIDE_DMAAPI_INLINE ( flat, dma_alloc );
|
||||
PROVIDE_DMAAPI_INLINE ( flat, dma_free );
|
||||
PROVIDE_DMAAPI_INLINE ( flat, dma_umalloc );
|
||||
PROVIDE_DMAAPI_INLINE ( flat, dma_ufree );
|
||||
PROVIDE_DMAAPI_INLINE ( flat, dma_set_mask );
|
||||
PROVIDE_DMAAPI_INLINE ( flat, dma_phys );
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Operations-based DMA API
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
* Map buffer for DMA
|
||||
*
|
||||
* @v dma DMA device
|
||||
* @v map DMA mapping to fill in
|
||||
* @v addr Buffer address
|
||||
* @v len Length of buffer
|
||||
* @v flags Mapping flags
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
static int dma_op_map ( struct dma_device *dma, struct dma_mapping *map,
|
||||
physaddr_t addr, size_t len, int flags ) {
|
||||
struct dma_operations *op = dma->op;
|
||||
|
||||
if ( ! op )
|
||||
return -ENODEV;
|
||||
return op->map ( dma, map, addr, len, flags );
|
||||
}
|
||||
|
||||
/**
|
||||
* Unmap buffer
|
||||
*
|
||||
* @v map DMA mapping
|
||||
*/
|
||||
static void dma_op_unmap ( struct dma_mapping *map ) {
|
||||
struct dma_device *dma = map->dma;
|
||||
|
||||
assert ( dma != NULL );
|
||||
assert ( dma->op != NULL );
|
||||
dma->op->unmap ( dma, map );
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocate and map DMA-coherent buffer
|
||||
*
|
||||
* @v dma DMA device
|
||||
* @v map DMA mapping to fill in
|
||||
* @v len Length of buffer
|
||||
* @v align Physical alignment
|
||||
* @ret addr Buffer address, or NULL on error
|
||||
*/
|
||||
static void * dma_op_alloc ( struct dma_device *dma, struct dma_mapping *map,
|
||||
size_t len, size_t align ) {
|
||||
struct dma_operations *op = dma->op;
|
||||
|
||||
if ( ! op )
|
||||
return NULL;
|
||||
return op->alloc ( dma, map, len, align );
|
||||
}
|
||||
|
||||
/**
|
||||
* Unmap and free DMA-coherent buffer
|
||||
*
|
||||
* @v map DMA mapping
|
||||
* @v addr Buffer address
|
||||
* @v len Length of buffer
|
||||
*/
|
||||
static void dma_op_free ( struct dma_mapping *map, void *addr, size_t len ) {
|
||||
struct dma_device *dma = map->dma;
|
||||
|
||||
assert ( dma != NULL );
|
||||
assert ( dma->op != NULL );
|
||||
dma->op->free ( dma, map, addr, len );
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocate and map DMA-coherent buffer from external (user) memory
|
||||
*
|
||||
* @v dma DMA device
|
||||
* @v map DMA mapping to fill in
|
||||
* @v len Length of buffer
|
||||
* @v align Physical alignment
|
||||
* @ret addr Buffer address, or NULL on error
|
||||
*/
|
||||
static userptr_t dma_op_umalloc ( struct dma_device *dma,
|
||||
struct dma_mapping *map,
|
||||
size_t len, size_t align ) {
|
||||
struct dma_operations *op = dma->op;
|
||||
|
||||
if ( ! op )
|
||||
return UNULL;
|
||||
return op->umalloc ( dma, map, len, align );
|
||||
}
|
||||
|
||||
/**
|
||||
* Unmap and free DMA-coherent buffer from external (user) memory
|
||||
*
|
||||
* @v map DMA mapping
|
||||
* @v addr Buffer address
|
||||
* @v len Length of buffer
|
||||
*/
|
||||
static void dma_op_ufree ( struct dma_mapping *map, userptr_t addr,
|
||||
size_t len ) {
|
||||
struct dma_device *dma = map->dma;
|
||||
|
||||
assert ( dma != NULL );
|
||||
assert ( dma->op != NULL );
|
||||
dma->op->ufree ( dma, map, addr, len );
|
||||
}
|
||||
|
||||
/**
|
||||
* Set addressable space mask
|
||||
*
|
||||
* @v dma DMA device
|
||||
* @v mask Addressable space mask
|
||||
*/
|
||||
static void dma_op_set_mask ( struct dma_device *dma, physaddr_t mask ) {
|
||||
struct dma_operations *op = dma->op;
|
||||
|
||||
if ( op )
|
||||
op->set_mask ( dma, mask );
|
||||
}
|
||||
|
||||
PROVIDE_DMAAPI ( op, dma_map, dma_op_map );
|
||||
PROVIDE_DMAAPI ( op, dma_unmap, dma_op_unmap );
|
||||
PROVIDE_DMAAPI ( op, dma_alloc, dma_op_alloc );
|
||||
PROVIDE_DMAAPI ( op, dma_free, dma_op_free );
|
||||
PROVIDE_DMAAPI ( op, dma_umalloc, dma_op_umalloc );
|
||||
PROVIDE_DMAAPI ( op, dma_ufree, dma_op_ufree );
|
||||
PROVIDE_DMAAPI ( op, dma_set_mask, dma_op_set_mask );
|
||||
PROVIDE_DMAAPI_INLINE ( op, dma_phys );
|
||||
@@ -81,9 +81,14 @@ struct interface null_intf = INTF_INIT ( null_intf_desc );
|
||||
* interface is updated to point to the new destination interface.
|
||||
*/
|
||||
void intf_plug ( struct interface *intf, struct interface *dest ) {
|
||||
|
||||
if ( intf == &null_intf )
|
||||
return;
|
||||
|
||||
DBGC ( INTF_COL ( intf ),
|
||||
"INTF " INTF_INTF_FMT " replug to " INTF_FMT "\n",
|
||||
INTF_INTF_DBG ( intf, intf->dest ), INTF_DBG ( dest ) );
|
||||
|
||||
intf_get ( dest );
|
||||
intf_put ( intf->dest );
|
||||
intf->dest = dest;
|
||||
@@ -385,6 +390,23 @@ void intfs_restart ( int rc, ... ) {
|
||||
va_end ( intfs );
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a filter interface
|
||||
*
|
||||
* @v intf Object interface
|
||||
* @v upper Upper end of filter
|
||||
* @v lower Lower end of filter
|
||||
*/
|
||||
void intf_insert ( struct interface *intf, struct interface *upper,
|
||||
struct interface *lower ) {
|
||||
struct interface *dest = intf->dest;
|
||||
|
||||
intf_get ( dest );
|
||||
intf_plug_plug ( intf, upper );
|
||||
intf_plug_plug ( lower, dest );
|
||||
intf_put ( dest );
|
||||
}
|
||||
|
||||
/**
|
||||
* Poke an object interface
|
||||
*
|
||||
|
||||
+51
-6
@@ -88,8 +88,8 @@ struct io_buffer * alloc_iob_raw ( size_t len, size_t align, size_t offset ) {
|
||||
len += ( ( - len - offset ) & ( __alignof__ ( *iobuf ) - 1 ) );
|
||||
|
||||
/* Allocate memory for buffer plus descriptor */
|
||||
data = malloc_dma_offset ( len + sizeof ( *iobuf ), align,
|
||||
offset );
|
||||
data = malloc_phys_offset ( len + sizeof ( *iobuf ), align,
|
||||
offset );
|
||||
if ( ! data )
|
||||
return NULL;
|
||||
iobuf = ( data + len );
|
||||
@@ -97,19 +97,20 @@ struct io_buffer * alloc_iob_raw ( size_t len, size_t align, size_t offset ) {
|
||||
} else {
|
||||
|
||||
/* Allocate memory for buffer */
|
||||
data = malloc_dma_offset ( len, align, offset );
|
||||
data = malloc_phys_offset ( len, align, offset );
|
||||
if ( ! data )
|
||||
return NULL;
|
||||
|
||||
/* Allocate memory for descriptor */
|
||||
iobuf = malloc ( sizeof ( *iobuf ) );
|
||||
if ( ! iobuf ) {
|
||||
free_dma ( data, len );
|
||||
free_phys ( data, len );
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Populate descriptor */
|
||||
memset ( &iobuf->map, 0, sizeof ( iobuf->map ) );
|
||||
iobuf->head = iobuf->data = iobuf->tail = data;
|
||||
iobuf->end = ( data + len );
|
||||
|
||||
@@ -153,22 +154,66 @@ void free_iob ( struct io_buffer *iobuf ) {
|
||||
assert ( iobuf->head <= iobuf->data );
|
||||
assert ( iobuf->data <= iobuf->tail );
|
||||
assert ( iobuf->tail <= iobuf->end );
|
||||
assert ( ! dma_mapped ( &iobuf->map ) );
|
||||
|
||||
/* Free buffer */
|
||||
len = ( iobuf->end - iobuf->head );
|
||||
if ( iobuf->end == iobuf ) {
|
||||
|
||||
/* Descriptor is inline */
|
||||
free_dma ( iobuf->head, ( len + sizeof ( *iobuf ) ) );
|
||||
free_phys ( iobuf->head, ( len + sizeof ( *iobuf ) ) );
|
||||
|
||||
} else {
|
||||
|
||||
/* Descriptor is detached */
|
||||
free_dma ( iobuf->head, len );
|
||||
free_phys ( iobuf->head, len );
|
||||
free ( iobuf );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocate and map I/O buffer for receive DMA
|
||||
*
|
||||
* @v len Length of I/O buffer
|
||||
* @v dma DMA device
|
||||
* @ret iobuf I/O buffer, or NULL on error
|
||||
*/
|
||||
struct io_buffer * alloc_rx_iob ( size_t len, struct dma_device *dma ) {
|
||||
struct io_buffer *iobuf;
|
||||
int rc;
|
||||
|
||||
/* Allocate I/O buffer */
|
||||
iobuf = alloc_iob ( len );
|
||||
if ( ! iobuf )
|
||||
goto err_alloc;
|
||||
|
||||
/* Map I/O buffer */
|
||||
if ( ( rc = iob_map_rx ( iobuf, dma ) ) != 0 )
|
||||
goto err_map;
|
||||
|
||||
return iobuf;
|
||||
|
||||
iob_unmap ( iobuf );
|
||||
err_map:
|
||||
free_iob ( iobuf );
|
||||
err_alloc:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unmap and free I/O buffer for receive DMA
|
||||
*
|
||||
* @v iobuf I/O buffer
|
||||
*/
|
||||
void free_rx_iob ( struct io_buffer *iobuf ) {
|
||||
|
||||
/* Unmap I/O buffer */
|
||||
iob_unmap ( iobuf );
|
||||
|
||||
/* Free I/O buffer */
|
||||
free_iob ( iobuf );
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure I/O buffer has sufficient headroom
|
||||
*
|
||||
|
||||
+2
-2
@@ -596,8 +596,8 @@ void * malloc ( size_t size ) {
|
||||
*
|
||||
* @v ptr Memory allocated by malloc(), or NULL
|
||||
*
|
||||
* Memory allocated with malloc_dma() cannot be freed with free(); it
|
||||
* must be freed with free_dma() instead.
|
||||
* Memory allocated with malloc_phys() cannot be freed with free(); it
|
||||
* must be freed with free_phys() instead.
|
||||
*
|
||||
* If @c ptr is NULL, no action is taken.
|
||||
*/
|
||||
|
||||
+1
-3
@@ -147,10 +147,8 @@ int xfer_open_socket ( struct interface *intf, int semantics,
|
||||
socket_family_name ( peer->sa_family ) );
|
||||
|
||||
for_each_table_entry ( opener, SOCKET_OPENERS ) {
|
||||
if ( ( opener->semantics == semantics ) &&
|
||||
( opener->family == peer->sa_family ) ) {
|
||||
if ( opener->semantics == semantics )
|
||||
return opener->open ( intf, peer, local );
|
||||
}
|
||||
}
|
||||
|
||||
DBGC ( INTF_COL ( intf ), "INTF " INTF_FMT " attempted to open "
|
||||
|
||||
+1
-1
@@ -93,7 +93,7 @@ int parse_integer ( char *text, unsigned int *value ) {
|
||||
|
||||
/* Parse integer */
|
||||
*value = strtoul ( text, &endp, 0 );
|
||||
if ( *endp ) {
|
||||
if ( *endp || ( ! *text ) ) {
|
||||
printf ( "\"%s\": invalid integer value\n", text );
|
||||
return -EINVAL_INTEGER;
|
||||
}
|
||||
|
||||
+7
-2
@@ -370,12 +370,14 @@ const char * settings_name ( struct settings *settings ) {
|
||||
static struct settings *
|
||||
parse_settings_name ( const char *name, get_child_settings_t get_child ) {
|
||||
struct settings *settings = &settings_root;
|
||||
char name_copy[ strlen ( name ) + 1 ];
|
||||
char *name_copy;
|
||||
char *subname;
|
||||
char *remainder;
|
||||
|
||||
/* Create modifiable copy of name */
|
||||
memcpy ( name_copy, name, sizeof ( name_copy ) );
|
||||
name_copy = strdup ( name );
|
||||
if ( ! name_copy )
|
||||
return NULL;
|
||||
remainder = name_copy;
|
||||
|
||||
/* Parse each name component in turn */
|
||||
@@ -389,6 +391,9 @@ parse_settings_name ( const char *name, get_child_settings_t get_child ) {
|
||||
break;
|
||||
}
|
||||
|
||||
/* Free modifiable copy of name */
|
||||
free ( name_copy );
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
|
||||
+23
-8
@@ -52,7 +52,7 @@ void * generic_memset ( void *dest, int character, size_t len ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy memory region
|
||||
* Copy memory region (forwards)
|
||||
*
|
||||
* @v dest Destination region
|
||||
* @v src Source region
|
||||
@@ -68,6 +68,23 @@ void * generic_memcpy ( void *dest, const void *src, size_t len ) {
|
||||
return dest;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy memory region (backwards)
|
||||
*
|
||||
* @v dest Destination region
|
||||
* @v src Source region
|
||||
* @v len Length
|
||||
* @ret dest Destination region
|
||||
*/
|
||||
void * generic_memcpy_reverse ( void *dest, const void *src, size_t len ) {
|
||||
const uint8_t *src_bytes = ( src + len );
|
||||
uint8_t *dest_bytes = ( dest + len );
|
||||
|
||||
while ( len-- )
|
||||
*(--dest_bytes) = *(--src_bytes);
|
||||
return dest;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy (possibly overlapping) memory region
|
||||
*
|
||||
@@ -77,14 +94,12 @@ void * generic_memcpy ( void *dest, const void *src, size_t len ) {
|
||||
* @ret dest Destination region
|
||||
*/
|
||||
void * generic_memmove ( void *dest, const void *src, size_t len ) {
|
||||
const uint8_t *src_bytes = ( src + len );
|
||||
uint8_t *dest_bytes = ( dest + len );
|
||||
|
||||
if ( dest < src )
|
||||
if ( dest < src ) {
|
||||
return generic_memcpy ( dest, src, len );
|
||||
while ( len-- )
|
||||
*(--dest_bytes) = *(--src_bytes);
|
||||
return dest;
|
||||
} else {
|
||||
return generic_memcpy_reverse ( dest, src, len );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -101,7 +116,7 @@ int memcmp ( const void *first, const void *second, size_t len ) {
|
||||
int diff;
|
||||
|
||||
while ( len-- ) {
|
||||
diff = ( *(second_bytes++) - *(first_bytes++) );
|
||||
diff = ( *(first_bytes++) - *(second_bytes++) );
|
||||
if ( diff )
|
||||
return diff;
|
||||
}
|
||||
|
||||
+2
-2
@@ -413,8 +413,8 @@ struct uri * parse_uri ( const char *uri_string ) {
|
||||
}
|
||||
|
||||
/* Split host into host[:port] */
|
||||
if ( ( uri->host[ strlen ( uri->host ) - 1 ] != ']' ) &&
|
||||
( tmp = strrchr ( uri->host, ':' ) ) ) {
|
||||
if ( ( tmp = strrchr ( uri->host, ':' ) ) &&
|
||||
( uri->host[ strlen ( uri->host ) - 1 ] != ']' ) ) {
|
||||
*(tmp++) = '\0';
|
||||
uri->port = tmp;
|
||||
}
|
||||
|
||||
@@ -116,13 +116,13 @@ struct x509_certificate * certstore_find ( struct asn1_cursor *raw ) {
|
||||
* @v key Private key
|
||||
* @ret cert X.509 certificate, or NULL if not found
|
||||
*/
|
||||
struct x509_certificate * certstore_find_key ( struct asn1_cursor *key ) {
|
||||
struct x509_certificate * certstore_find_key ( struct private_key *key ) {
|
||||
struct x509_certificate *cert;
|
||||
|
||||
/* Search for certificate within store */
|
||||
list_for_each_entry ( cert, &certstore.links, store.list ) {
|
||||
if ( pubkey_match ( cert->signature_algorithm->pubkey,
|
||||
key->data, key->len,
|
||||
key->builder.data, key->builder.len,
|
||||
cert->subject.public_key.raw.data,
|
||||
cert->subject.public_key.raw.len ) == 0 )
|
||||
return certstore_found ( cert );
|
||||
|
||||
+1
-1
@@ -76,7 +76,7 @@ static uint8_t oid_signeddata[] = { ASN1_OID_SIGNEDDATA };
|
||||
|
||||
/** "pkcs7-signedData" object identifier cursor */
|
||||
static struct asn1_cursor oid_signeddata_cursor =
|
||||
ASN1_OID_CURSOR ( oid_signeddata );
|
||||
ASN1_CURSOR ( oid_signeddata );
|
||||
|
||||
/**
|
||||
* Parse CMS signature content type
|
||||
|
||||
@@ -56,7 +56,7 @@ static uint8_t deflate_reverse[256];
|
||||
* does not fit the pattern (it represents a length of 258; following
|
||||
* the pattern from the earlier codes would give a length of 259), and
|
||||
* has no extra bits. Codes 286-287 are invalid, but can occur. We
|
||||
* treat any code greater than 284 as meaning "length 285, no extra
|
||||
* treat any code greater than 284 as meaning "length 258, no extra
|
||||
* bits".
|
||||
*/
|
||||
static uint8_t deflate_litlen_base[28];
|
||||
|
||||
@@ -35,7 +35,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
#include <assert.h>
|
||||
#include <ipxe/rotate.h>
|
||||
#include <ipxe/crypto.h>
|
||||
#include <ipxe/asn1.h>
|
||||
#include <ipxe/md4.h>
|
||||
|
||||
/** MD4 variables */
|
||||
@@ -268,13 +267,3 @@ struct digest_algorithm md4_algorithm = {
|
||||
.update = md4_update,
|
||||
.final = md4_final,
|
||||
};
|
||||
|
||||
/** "md4" object identifier */
|
||||
static uint8_t oid_md4[] = { ASN1_OID_MD4 };
|
||||
|
||||
/** "md4" OID-identified algorithm */
|
||||
struct asn1_algorithm oid_md4_algorithm __asn1_algorithm = {
|
||||
.name = "md4",
|
||||
.digest = &md4_algorithm,
|
||||
.oid = ASN1_OID_CURSOR ( oid_md4 ),
|
||||
};
|
||||
|
||||
@@ -35,7 +35,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
#include <assert.h>
|
||||
#include <ipxe/rotate.h>
|
||||
#include <ipxe/crypto.h>
|
||||
#include <ipxe/asn1.h>
|
||||
#include <ipxe/md5.h>
|
||||
|
||||
/** MD5 variables */
|
||||
@@ -293,13 +292,3 @@ struct digest_algorithm md5_algorithm = {
|
||||
.update = md5_update,
|
||||
.final = md5_final,
|
||||
};
|
||||
|
||||
/** "md5" object identifier */
|
||||
static uint8_t oid_md5[] = { ASN1_OID_MD5 };
|
||||
|
||||
/** "md5" OID-identified algorithm */
|
||||
struct asn1_algorithm oid_md5_algorithm __asn1_algorithm = {
|
||||
.name = "md5",
|
||||
.digest = &md5_algorithm,
|
||||
.oid = ASN1_OID_CURSOR ( oid_md5 ),
|
||||
};
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Michael Brown <mbrown@fensystems.co.uk>.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*
|
||||
* You can also choose to distribute this program under the terms of
|
||||
* the Unmodified Binary Distribution Licence (as given in the file
|
||||
* COPYING.UBDL), provided that you have satisfied its requirements.
|
||||
*/
|
||||
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
|
||||
#include <ipxe/md4.h>
|
||||
#include <ipxe/asn1.h>
|
||||
|
||||
/** "md4" object identifier */
|
||||
static uint8_t oid_md4[] = { ASN1_OID_MD4 };
|
||||
|
||||
/** "md4" OID-identified algorithm */
|
||||
struct asn1_algorithm oid_md4_algorithm __asn1_algorithm = {
|
||||
.name = "md4",
|
||||
.digest = &md4_algorithm,
|
||||
.oid = ASN1_CURSOR ( oid_md4 ),
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Michael Brown <mbrown@fensystems.co.uk>.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*
|
||||
* You can also choose to distribute this program under the terms of
|
||||
* the Unmodified Binary Distribution Licence (as given in the file
|
||||
* COPYING.UBDL), provided that you have satisfied its requirements.
|
||||
*/
|
||||
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
|
||||
#include <ipxe/md5.h>
|
||||
#include <ipxe/asn1.h>
|
||||
|
||||
/** "md5" object identifier */
|
||||
static uint8_t oid_md5[] = { ASN1_OID_MD5 };
|
||||
|
||||
/** "md5" OID-identified algorithm */
|
||||
struct asn1_algorithm oid_md5_algorithm __asn1_algorithm = {
|
||||
.name = "md5",
|
||||
.digest = &md5_algorithm,
|
||||
.oid = ASN1_CURSOR ( oid_md5 ),
|
||||
};
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Michael Brown <mbrown@fensystems.co.uk>.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*
|
||||
* You can also choose to distribute this program under the terms of
|
||||
* the Unmodified Binary Distribution Licence (as given in the file
|
||||
* COPYING.UBDL), provided that you have satisfied its requirements.
|
||||
*/
|
||||
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
|
||||
#include <ipxe/rsa.h>
|
||||
#include <ipxe/asn1.h>
|
||||
|
||||
/** "rsaEncryption" object identifier */
|
||||
static uint8_t oid_rsa_encryption[] = { ASN1_OID_RSAENCRYPTION };
|
||||
|
||||
/** "rsaEncryption" OID-identified algorithm */
|
||||
struct asn1_algorithm rsa_encryption_algorithm __asn1_algorithm = {
|
||||
.name = "rsaEncryption",
|
||||
.pubkey = &rsa_algorithm,
|
||||
.digest = NULL,
|
||||
.oid = ASN1_CURSOR ( oid_rsa_encryption ),
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Michael Brown <mbrown@fensystems.co.uk>.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*
|
||||
* You can also choose to distribute this program under the terms of
|
||||
* the Unmodified Binary Distribution Licence (as given in the file
|
||||
* COPYING.UBDL), provided that you have satisfied its requirements.
|
||||
*/
|
||||
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
|
||||
#include <ipxe/sha1.h>
|
||||
#include <ipxe/asn1.h>
|
||||
|
||||
/** "sha1" object identifier */
|
||||
static uint8_t oid_sha1[] = { ASN1_OID_SHA1 };
|
||||
|
||||
/** "sha1" OID-identified algorithm */
|
||||
struct asn1_algorithm oid_sha1_algorithm __asn1_algorithm = {
|
||||
.name = "sha1",
|
||||
.digest = &sha1_algorithm,
|
||||
.oid = ASN1_CURSOR ( oid_sha1 ),
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Michael Brown <mbrown@fensystems.co.uk>.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*
|
||||
* You can also choose to distribute this program under the terms of
|
||||
* the Unmodified Binary Distribution Licence (as given in the file
|
||||
* COPYING.UBDL), provided that you have satisfied its requirements.
|
||||
*/
|
||||
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
|
||||
#include <ipxe/sha256.h>
|
||||
#include <ipxe/asn1.h>
|
||||
|
||||
/** "sha224" object identifier */
|
||||
static uint8_t oid_sha224[] = { ASN1_OID_SHA224 };
|
||||
|
||||
/** "sha224" OID-identified algorithm */
|
||||
struct asn1_algorithm oid_sha224_algorithm __asn1_algorithm = {
|
||||
.name = "sha224",
|
||||
.digest = &sha224_algorithm,
|
||||
.oid = ASN1_CURSOR ( oid_sha224 ),
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Michael Brown <mbrown@fensystems.co.uk>.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*
|
||||
* You can also choose to distribute this program under the terms of
|
||||
* the Unmodified Binary Distribution Licence (as given in the file
|
||||
* COPYING.UBDL), provided that you have satisfied its requirements.
|
||||
*/
|
||||
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
|
||||
#include <ipxe/sha256.h>
|
||||
#include <ipxe/asn1.h>
|
||||
|
||||
/** "sha256" object identifier */
|
||||
static uint8_t oid_sha256[] = { ASN1_OID_SHA256 };
|
||||
|
||||
/** "sha256" OID-identified algorithm */
|
||||
struct asn1_algorithm oid_sha256_algorithm __asn1_algorithm = {
|
||||
.name = "sha256",
|
||||
.digest = &sha256_algorithm,
|
||||
.oid = ASN1_CURSOR ( oid_sha256 ),
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Michael Brown <mbrown@fensystems.co.uk>.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*
|
||||
* You can also choose to distribute this program under the terms of
|
||||
* the Unmodified Binary Distribution Licence (as given in the file
|
||||
* COPYING.UBDL), provided that you have satisfied its requirements.
|
||||
*/
|
||||
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
|
||||
#include <ipxe/sha512.h>
|
||||
#include <ipxe/asn1.h>
|
||||
|
||||
/** "sha384" object identifier */
|
||||
static uint8_t oid_sha384[] = { ASN1_OID_SHA384 };
|
||||
|
||||
/** "sha384" OID-identified algorithm */
|
||||
struct asn1_algorithm oid_sha384_algorithm __asn1_algorithm = {
|
||||
.name = "sha384",
|
||||
.digest = &sha384_algorithm,
|
||||
.oid = ASN1_CURSOR ( oid_sha384 ),
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Michael Brown <mbrown@fensystems.co.uk>.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*
|
||||
* You can also choose to distribute this program under the terms of
|
||||
* the Unmodified Binary Distribution Licence (as given in the file
|
||||
* COPYING.UBDL), provided that you have satisfied its requirements.
|
||||
*/
|
||||
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
|
||||
#include <ipxe/sha512.h>
|
||||
#include <ipxe/asn1.h>
|
||||
|
||||
/** "sha512" object identifier */
|
||||
static uint8_t oid_sha512[] = { ASN1_OID_SHA512 };
|
||||
|
||||
/** "sha512" OID-identified algorithm */
|
||||
struct asn1_algorithm oid_sha512_algorithm __asn1_algorithm = {
|
||||
.name = "sha512",
|
||||
.digest = &sha512_algorithm,
|
||||
.oid = ASN1_CURSOR ( oid_sha512 ),
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Michael Brown <mbrown@fensystems.co.uk>.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*
|
||||
* You can also choose to distribute this program under the terms of
|
||||
* the Unmodified Binary Distribution Licence (as given in the file
|
||||
* COPYING.UBDL), provided that you have satisfied its requirements.
|
||||
*/
|
||||
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
|
||||
#include <ipxe/sha512.h>
|
||||
#include <ipxe/asn1.h>
|
||||
|
||||
/** "sha512_224" object identifier */
|
||||
static uint8_t oid_sha512_224[] = { ASN1_OID_SHA512_224 };
|
||||
|
||||
/** "sha512_224" OID-identified algorithm */
|
||||
struct asn1_algorithm oid_sha512_224_algorithm __asn1_algorithm = {
|
||||
.name = "sha512/224",
|
||||
.digest = &sha512_224_algorithm,
|
||||
.oid = ASN1_CURSOR ( oid_sha512_224 ),
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Michael Brown <mbrown@fensystems.co.uk>.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*
|
||||
* You can also choose to distribute this program under the terms of
|
||||
* the Unmodified Binary Distribution Licence (as given in the file
|
||||
* COPYING.UBDL), provided that you have satisfied its requirements.
|
||||
*/
|
||||
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
|
||||
#include <ipxe/sha512.h>
|
||||
#include <ipxe/asn1.h>
|
||||
|
||||
/** "sha512_256" object identifier */
|
||||
static uint8_t oid_sha512_256[] = { ASN1_OID_SHA512_256 };
|
||||
|
||||
/** "sha512_256" OID-identified algorithm */
|
||||
struct asn1_algorithm oid_sha512_256_algorithm __asn1_algorithm = {
|
||||
.name = "sha512/256",
|
||||
.digest = &sha512_256_algorithm,
|
||||
.oid = ASN1_CURSOR ( oid_sha512_256 ),
|
||||
};
|
||||
@@ -36,7 +36,7 @@ struct asn1_algorithm md5_with_rsa_encryption_algorithm __asn1_algorithm = {
|
||||
.name = "md5WithRSAEncryption",
|
||||
.pubkey = &rsa_algorithm,
|
||||
.digest = &md5_algorithm,
|
||||
.oid = ASN1_OID_CURSOR ( oid_md5_with_rsa_encryption ),
|
||||
.oid = ASN1_CURSOR ( oid_md5_with_rsa_encryption ),
|
||||
};
|
||||
|
||||
/** MD5 digestInfo prefix */
|
||||
|
||||
@@ -37,7 +37,7 @@ struct asn1_algorithm sha1_with_rsa_encryption_algorithm __asn1_algorithm = {
|
||||
.name = "sha1WithRSAEncryption",
|
||||
.pubkey = &rsa_algorithm,
|
||||
.digest = &sha1_algorithm,
|
||||
.oid = ASN1_OID_CURSOR ( oid_sha1_with_rsa_encryption ),
|
||||
.oid = ASN1_CURSOR ( oid_sha1_with_rsa_encryption ),
|
||||
};
|
||||
|
||||
/** SHA-1 digestInfo prefix */
|
||||
|
||||
@@ -37,7 +37,7 @@ struct asn1_algorithm sha224_with_rsa_encryption_algorithm __asn1_algorithm = {
|
||||
.name = "sha224WithRSAEncryption",
|
||||
.pubkey = &rsa_algorithm,
|
||||
.digest = &sha224_algorithm,
|
||||
.oid = ASN1_OID_CURSOR ( oid_sha224_with_rsa_encryption ),
|
||||
.oid = ASN1_CURSOR ( oid_sha224_with_rsa_encryption ),
|
||||
};
|
||||
|
||||
/** SHA-224 digestInfo prefix */
|
||||
|
||||
@@ -37,7 +37,7 @@ struct asn1_algorithm sha256_with_rsa_encryption_algorithm __asn1_algorithm = {
|
||||
.name = "sha256WithRSAEncryption",
|
||||
.pubkey = &rsa_algorithm,
|
||||
.digest = &sha256_algorithm,
|
||||
.oid = ASN1_OID_CURSOR ( oid_sha256_with_rsa_encryption ),
|
||||
.oid = ASN1_CURSOR ( oid_sha256_with_rsa_encryption ),
|
||||
};
|
||||
|
||||
/** SHA-256 digestInfo prefix */
|
||||
|
||||
@@ -37,7 +37,7 @@ struct asn1_algorithm sha384_with_rsa_encryption_algorithm __asn1_algorithm = {
|
||||
.name = "sha384WithRSAEncryption",
|
||||
.pubkey = &rsa_algorithm,
|
||||
.digest = &sha384_algorithm,
|
||||
.oid = ASN1_OID_CURSOR ( oid_sha384_with_rsa_encryption ),
|
||||
.oid = ASN1_CURSOR ( oid_sha384_with_rsa_encryption ),
|
||||
};
|
||||
|
||||
/** SHA-384 digestInfo prefix */
|
||||
|
||||
@@ -37,7 +37,7 @@ struct asn1_algorithm sha512_with_rsa_encryption_algorithm __asn1_algorithm = {
|
||||
.name = "sha512WithRSAEncryption",
|
||||
.pubkey = &rsa_algorithm,
|
||||
.digest = &sha512_algorithm,
|
||||
.oid = ASN1_OID_CURSOR ( oid_sha512_with_rsa_encryption ),
|
||||
.oid = ASN1_CURSOR ( oid_sha512_with_rsa_encryption ),
|
||||
};
|
||||
|
||||
/** SHA-512 digestInfo prefix */
|
||||
|
||||
+29
-31
@@ -116,7 +116,7 @@ static const uint8_t oid_basic_response_type[] = { ASN1_OID_OCSP_BASIC };
|
||||
|
||||
/** OCSP basic response type cursor */
|
||||
static struct asn1_cursor oid_basic_response_type_cursor =
|
||||
ASN1_OID_CURSOR ( oid_basic_response_type );
|
||||
ASN1_CURSOR ( oid_basic_response_type );
|
||||
|
||||
/**
|
||||
* Free OCSP check
|
||||
@@ -284,7 +284,7 @@ int ocsp_check ( struct x509_certificate *cert,
|
||||
/* Sanity checks */
|
||||
assert ( cert != NULL );
|
||||
assert ( issuer != NULL );
|
||||
assert ( x509_is_valid ( issuer ) );
|
||||
assert ( issuer->root != NULL );
|
||||
|
||||
/* Allocate and initialise check */
|
||||
*ocsp = zalloc ( sizeof ( **ocsp ) );
|
||||
@@ -476,33 +476,43 @@ static int ocsp_parse_responder_id ( struct ocsp_check *ocsp,
|
||||
*/
|
||||
static int ocsp_parse_cert_id ( struct ocsp_check *ocsp,
|
||||
const struct asn1_cursor *raw ) {
|
||||
static struct asn1_cursor algorithm = {
|
||||
.data = ocsp_algorithm_id,
|
||||
.len = sizeof ( ocsp_algorithm_id ),
|
||||
};
|
||||
struct asn1_cursor cert_id;
|
||||
struct asn1_cursor cursor;
|
||||
struct asn1_algorithm *algorithm;
|
||||
int rc;
|
||||
|
||||
/* Check certID algorithm */
|
||||
memcpy ( &cursor, raw, sizeof ( cursor ) );
|
||||
asn1_enter ( &cursor, ASN1_SEQUENCE );
|
||||
if ( ( rc = asn1_digest_algorithm ( &cursor, &algorithm ) ) != 0 ) {
|
||||
DBGC ( ocsp, "OCSP %p \"%s\" certID unknown algorithm: %s\n",
|
||||
ocsp, x509_name ( ocsp->cert ), strerror ( rc ) );
|
||||
return rc;
|
||||
/* Enter cert ID */
|
||||
memcpy ( &cert_id, raw, sizeof ( cert_id ) );
|
||||
asn1_enter ( &cert_id, ASN1_SEQUENCE );
|
||||
|
||||
/* Check certID algorithm (but not parameters) */
|
||||
memcpy ( &cursor, &cert_id, sizeof ( cursor ) );
|
||||
if ( ( rc = ( asn1_enter ( &cursor, ASN1_SEQUENCE ),
|
||||
asn1_shrink ( &cursor, ASN1_OID ),
|
||||
asn1_shrink ( &algorithm, ASN1_OID ) ) ) != 0 ) {
|
||||
DBGC ( ocsp, "OCSP %p \"%s\" certID missing algorithm:\n",
|
||||
ocsp, x509_name ( ocsp->cert ) );
|
||||
DBGC_HDA ( ocsp, 0, cursor.data, cursor.len );
|
||||
return -EACCES_CERT_MISMATCH;
|
||||
}
|
||||
if ( algorithm->digest != &ocsp_digest_algorithm ) {
|
||||
DBGC ( ocsp, "OCSP %p \"%s\" certID wrong algorithm %s\n",
|
||||
ocsp, x509_name ( ocsp->cert ),
|
||||
algorithm->digest->name );
|
||||
if ( asn1_compare ( &cursor, &algorithm ) != 0 ) {
|
||||
DBGC ( ocsp, "OCSP %p \"%s\" certID wrong algorithm:\n",
|
||||
ocsp, x509_name ( ocsp->cert ) );
|
||||
DBGC_HDA ( ocsp, 0, cursor.data, cursor.len );
|
||||
return -EACCES_CERT_MISMATCH;
|
||||
}
|
||||
|
||||
/* Check remaining certID fields */
|
||||
asn1_skip ( &cursor, ASN1_SEQUENCE );
|
||||
if ( asn1_compare ( &cursor, &ocsp->request.cert_id_tail ) != 0 ) {
|
||||
asn1_skip ( &cert_id, ASN1_SEQUENCE );
|
||||
if ( asn1_compare ( &cert_id, &ocsp->request.cert_id_tail ) != 0 ) {
|
||||
DBGC ( ocsp, "OCSP %p \"%s\" certID mismatch:\n",
|
||||
ocsp, x509_name ( ocsp->cert ) );
|
||||
DBGC_HDA ( ocsp, 0, ocsp->request.cert_id_tail.data,
|
||||
ocsp->request.cert_id_tail.len );
|
||||
DBGC_HDA ( ocsp, 0, cursor.data, cursor.len );
|
||||
DBGC_HDA ( ocsp, 0, cert_id.data, cert_id.len );
|
||||
return -EACCES_CERT_MISMATCH;
|
||||
}
|
||||
|
||||
@@ -822,18 +832,6 @@ int ocsp_response ( struct ocsp_check *ocsp, const void *data, size_t len ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* OCSP dummy root certificate store
|
||||
*
|
||||
* OCSP validation uses no root certificates, since it takes place
|
||||
* only when there already exists a validated issuer certificate.
|
||||
*/
|
||||
static struct x509_root ocsp_root = {
|
||||
.digest = &ocsp_digest_algorithm,
|
||||
.count = 0,
|
||||
.fingerprints = NULL,
|
||||
};
|
||||
|
||||
/**
|
||||
* Check OCSP response signature
|
||||
*
|
||||
@@ -917,7 +915,7 @@ int ocsp_validate ( struct ocsp_check *ocsp, time_t time ) {
|
||||
*/
|
||||
x509_invalidate ( signer );
|
||||
if ( ( rc = x509_validate ( signer, ocsp->issuer, time,
|
||||
&ocsp_root ) ) != 0 ) {
|
||||
ocsp->issuer->root ) ) != 0 ) {
|
||||
DBGC ( ocsp, "OCSP %p \"%s\" could not validate ",
|
||||
ocsp, x509_name ( ocsp->cert ) );
|
||||
DBGC ( ocsp, "signer \"%s\": %s\n",
|
||||
@@ -963,7 +961,7 @@ int ocsp_validate ( struct ocsp_check *ocsp, time_t time ) {
|
||||
|
||||
/* Validate certificate against issuer */
|
||||
if ( ( rc = x509_validate ( ocsp->cert, ocsp->issuer, time,
|
||||
&ocsp_root ) ) != 0 ) {
|
||||
ocsp->issuer->root ) ) != 0 ) {
|
||||
DBGC ( ocsp, "OCSP %p \"%s\" could not validate certificate: "
|
||||
"%s\n", ocsp, x509_name ( ocsp->cert ), strerror ( rc ));
|
||||
return rc;
|
||||
|
||||
+26
-9
@@ -64,9 +64,12 @@ __asm__ ( ".section \".rodata\", \"a\", " PROGBITS "\n\t"
|
||||
".previous\n\t" );
|
||||
|
||||
/** Private key */
|
||||
struct asn1_cursor private_key = {
|
||||
.data = private_key_data,
|
||||
.len = ( ( size_t ) private_key_len ),
|
||||
struct private_key private_key = {
|
||||
.refcnt = REF_INIT ( ref_no_free ),
|
||||
.builder = {
|
||||
.data = private_key_data,
|
||||
.len = ( ( size_t ) private_key_len ),
|
||||
},
|
||||
};
|
||||
|
||||
/** Default private key */
|
||||
@@ -83,6 +86,19 @@ static struct setting privkey_setting __setting ( SETTING_CRYPTO, privkey ) = {
|
||||
.type = &setting_type_hex,
|
||||
};
|
||||
|
||||
/**
|
||||
* Free private key
|
||||
*
|
||||
* @v refcnt Reference counter
|
||||
*/
|
||||
void privkey_free ( struct refcnt *refcnt ) {
|
||||
struct private_key *key =
|
||||
container_of ( refcnt, struct private_key, refcnt );
|
||||
|
||||
free ( key->builder.data );
|
||||
free ( key );
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply private key configuration settings
|
||||
*
|
||||
@@ -98,23 +114,24 @@ static int privkey_apply_settings ( void ) {
|
||||
if ( ALLOW_KEY_OVERRIDE ) {
|
||||
|
||||
/* Restore default private key */
|
||||
memcpy ( &private_key, &default_private_key,
|
||||
sizeof ( private_key ) );
|
||||
memcpy ( &private_key.builder, &default_private_key,
|
||||
sizeof ( private_key.builder ) );
|
||||
|
||||
/* Fetch new private key, if any */
|
||||
free ( key_data );
|
||||
if ( ( len = fetch_raw_setting_copy ( NULL, &privkey_setting,
|
||||
&key_data ) ) >= 0 ) {
|
||||
private_key.data = key_data;
|
||||
private_key.len = len;
|
||||
private_key.builder.data = key_data;
|
||||
private_key.builder.len = len;
|
||||
}
|
||||
}
|
||||
|
||||
/* Debug */
|
||||
if ( private_key.len ) {
|
||||
if ( private_key.builder.len ) {
|
||||
DBGC ( &private_key, "PRIVKEY using %s private key:\n",
|
||||
( key_data ? "external" : "built-in" ) );
|
||||
DBGC_HDA ( &private_key, 0, private_key.data, private_key.len );
|
||||
DBGC_HDA ( &private_key, 0, private_key.builder.data,
|
||||
private_key.builder.len );
|
||||
} else {
|
||||
DBGC ( &private_key, "PRIVKEY has no private key\n" );
|
||||
}
|
||||
|
||||
@@ -71,6 +71,7 @@ static struct setting trust_setting __setting ( SETTING_CRYPTO, trust ) = {
|
||||
|
||||
/** Root certificates */
|
||||
struct x509_root root_certificates = {
|
||||
.refcnt = REF_INIT ( ref_no_free ),
|
||||
.digest = &sha256_algorithm,
|
||||
.count = ( sizeof ( fingerprints ) / FINGERPRINT_LEN ),
|
||||
.fingerprints = fingerprints,
|
||||
|
||||
@@ -47,17 +47,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
#define EINFO_EACCES_VERIFY \
|
||||
__einfo_uniqify ( EINFO_EACCES, 0x01, "RSA signature incorrect" )
|
||||
|
||||
/** "rsaEncryption" object identifier */
|
||||
static uint8_t oid_rsa_encryption[] = { ASN1_OID_RSAENCRYPTION };
|
||||
|
||||
/** "rsaEncryption" OID-identified algorithm */
|
||||
struct asn1_algorithm rsa_encryption_algorithm __asn1_algorithm = {
|
||||
.name = "rsaEncryption",
|
||||
.pubkey = &rsa_algorithm,
|
||||
.digest = NULL,
|
||||
.oid = ASN1_OID_CURSOR ( oid_rsa_encryption ),
|
||||
};
|
||||
|
||||
/**
|
||||
* Identify RSA prefix
|
||||
*
|
||||
|
||||
@@ -35,7 +35,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
#include <assert.h>
|
||||
#include <ipxe/rotate.h>
|
||||
#include <ipxe/crypto.h>
|
||||
#include <ipxe/asn1.h>
|
||||
#include <ipxe/sha1.h>
|
||||
|
||||
/** SHA-1 variables */
|
||||
@@ -264,13 +263,3 @@ struct digest_algorithm sha1_algorithm = {
|
||||
.update = sha1_update,
|
||||
.final = sha1_final,
|
||||
};
|
||||
|
||||
/** "sha1" object identifier */
|
||||
static uint8_t oid_sha1[] = { ASN1_OID_SHA1 };
|
||||
|
||||
/** "sha1" OID-identified algorithm */
|
||||
struct asn1_algorithm oid_sha1_algorithm __asn1_algorithm = {
|
||||
.name = "sha1",
|
||||
.digest = &sha1_algorithm,
|
||||
.oid = ASN1_OID_CURSOR ( oid_sha1 ),
|
||||
};
|
||||
|
||||
@@ -32,7 +32,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
#include <stdint.h>
|
||||
#include <byteswap.h>
|
||||
#include <ipxe/crypto.h>
|
||||
#include <ipxe/asn1.h>
|
||||
#include <ipxe/sha256.h>
|
||||
|
||||
/** SHA-224 initial digest values */
|
||||
@@ -70,13 +69,3 @@ struct digest_algorithm sha224_algorithm = {
|
||||
.update = sha256_update,
|
||||
.final = sha256_final,
|
||||
};
|
||||
|
||||
/** "sha224" object identifier */
|
||||
static uint8_t oid_sha224[] = { ASN1_OID_SHA224 };
|
||||
|
||||
/** "sha224" OID-identified algorithm */
|
||||
struct asn1_algorithm oid_sha224_algorithm __asn1_algorithm = {
|
||||
.name = "sha224",
|
||||
.digest = &sha224_algorithm,
|
||||
.oid = ASN1_OID_CURSOR ( oid_sha224 ),
|
||||
};
|
||||
|
||||
@@ -35,7 +35,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
#include <assert.h>
|
||||
#include <ipxe/rotate.h>
|
||||
#include <ipxe/crypto.h>
|
||||
#include <ipxe/asn1.h>
|
||||
#include <ipxe/sha256.h>
|
||||
|
||||
/** SHA-256 variables */
|
||||
@@ -271,13 +270,3 @@ struct digest_algorithm sha256_algorithm = {
|
||||
.update = sha256_update,
|
||||
.final = sha256_final,
|
||||
};
|
||||
|
||||
/** "sha256" object identifier */
|
||||
static uint8_t oid_sha256[] = { ASN1_OID_SHA256 };
|
||||
|
||||
/** "sha256" OID-identified algorithm */
|
||||
struct asn1_algorithm oid_sha256_algorithm __asn1_algorithm = {
|
||||
.name = "sha256",
|
||||
.digest = &sha256_algorithm,
|
||||
.oid = ASN1_OID_CURSOR ( oid_sha256 ),
|
||||
};
|
||||
|
||||
@@ -32,7 +32,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
#include <stdint.h>
|
||||
#include <byteswap.h>
|
||||
#include <ipxe/crypto.h>
|
||||
#include <ipxe/asn1.h>
|
||||
#include <ipxe/sha512.h>
|
||||
|
||||
/** SHA-384 initial digest values */
|
||||
@@ -70,13 +69,3 @@ struct digest_algorithm sha384_algorithm = {
|
||||
.update = sha512_update,
|
||||
.final = sha512_final,
|
||||
};
|
||||
|
||||
/** "sha384" object identifier */
|
||||
static uint8_t oid_sha384[] = { ASN1_OID_SHA384 };
|
||||
|
||||
/** "sha384" OID-identified algorithm */
|
||||
struct asn1_algorithm oid_sha384_algorithm __asn1_algorithm = {
|
||||
.name = "sha384",
|
||||
.digest = &sha384_algorithm,
|
||||
.oid = ASN1_OID_CURSOR ( oid_sha384 ),
|
||||
};
|
||||
|
||||
@@ -35,7 +35,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
#include <assert.h>
|
||||
#include <ipxe/rotate.h>
|
||||
#include <ipxe/crypto.h>
|
||||
#include <ipxe/asn1.h>
|
||||
#include <ipxe/sha512.h>
|
||||
|
||||
/** SHA-512 variables */
|
||||
@@ -291,13 +290,3 @@ struct digest_algorithm sha512_algorithm = {
|
||||
.update = sha512_update,
|
||||
.final = sha512_final,
|
||||
};
|
||||
|
||||
/** "sha512" object identifier */
|
||||
static uint8_t oid_sha512[] = { ASN1_OID_SHA512 };
|
||||
|
||||
/** "sha512" OID-identified algorithm */
|
||||
struct asn1_algorithm oid_sha512_algorithm __asn1_algorithm = {
|
||||
.name = "sha512",
|
||||
.digest = &sha512_algorithm,
|
||||
.oid = ASN1_OID_CURSOR ( oid_sha512 ),
|
||||
};
|
||||
|
||||
@@ -32,7 +32,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
#include <stdint.h>
|
||||
#include <byteswap.h>
|
||||
#include <ipxe/crypto.h>
|
||||
#include <ipxe/asn1.h>
|
||||
#include <ipxe/sha512.h>
|
||||
|
||||
/** SHA-512/224 initial digest values */
|
||||
@@ -71,13 +70,3 @@ struct digest_algorithm sha512_224_algorithm = {
|
||||
.update = sha512_update,
|
||||
.final = sha512_final,
|
||||
};
|
||||
|
||||
/** "sha512_224" object identifier */
|
||||
static uint8_t oid_sha512_224[] = { ASN1_OID_SHA512_224 };
|
||||
|
||||
/** "sha512_224" OID-identified algorithm */
|
||||
struct asn1_algorithm oid_sha512_224_algorithm __asn1_algorithm = {
|
||||
.name = "sha512/224",
|
||||
.digest = &sha512_224_algorithm,
|
||||
.oid = ASN1_OID_CURSOR ( oid_sha512_224 ),
|
||||
};
|
||||
|
||||
@@ -32,7 +32,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
#include <stdint.h>
|
||||
#include <byteswap.h>
|
||||
#include <ipxe/crypto.h>
|
||||
#include <ipxe/asn1.h>
|
||||
#include <ipxe/sha512.h>
|
||||
|
||||
/** SHA-512/256 initial digest values */
|
||||
@@ -71,13 +70,3 @@ struct digest_algorithm sha512_256_algorithm = {
|
||||
.update = sha512_update,
|
||||
.final = sha512_final,
|
||||
};
|
||||
|
||||
/** "sha512_256" object identifier */
|
||||
static uint8_t oid_sha512_256[] = { ASN1_OID_SHA512_256 };
|
||||
|
||||
/** "sha512_256" OID-identified algorithm */
|
||||
struct asn1_algorithm oid_sha512_256_algorithm __asn1_algorithm = {
|
||||
.name = "sha512/256",
|
||||
.digest = &sha512_256_algorithm,
|
||||
.oid = ASN1_OID_CURSOR ( oid_sha512_256 ),
|
||||
};
|
||||
|
||||
+72
-23
@@ -122,6 +122,19 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
#define EINFO_EACCES_USELESS \
|
||||
__einfo_uniqify ( EINFO_EACCES, 0x0b, "No usable certificates" )
|
||||
|
||||
/**
|
||||
* Free X.509 certificate
|
||||
*
|
||||
* @v refcnt Reference count
|
||||
*/
|
||||
static void x509_free ( struct refcnt *refcnt ) {
|
||||
struct x509_certificate *cert =
|
||||
container_of ( refcnt, struct x509_certificate, refcnt );
|
||||
|
||||
x509_root_put ( cert->root );
|
||||
free ( cert );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get X.509 certificate display name
|
||||
*
|
||||
@@ -156,7 +169,7 @@ static uint8_t oid_common_name[] = { ASN1_OID_COMMON_NAME };
|
||||
|
||||
/** "commonName" object identifier cursor */
|
||||
static struct asn1_cursor oid_common_name_cursor =
|
||||
ASN1_OID_CURSOR ( oid_common_name );
|
||||
ASN1_CURSOR ( oid_common_name );
|
||||
|
||||
/**
|
||||
* Parse X.509 certificate version
|
||||
@@ -523,12 +536,12 @@ static struct x509_key_purpose x509_key_purposes[] = {
|
||||
{
|
||||
.name = "codeSigning",
|
||||
.bits = X509_CODE_SIGNING,
|
||||
.oid = ASN1_OID_CURSOR ( oid_code_signing ),
|
||||
.oid = ASN1_CURSOR ( oid_code_signing ),
|
||||
},
|
||||
{
|
||||
.name = "ocspSigning",
|
||||
.bits = X509_OCSP_SIGNING,
|
||||
.oid = ASN1_OID_CURSOR ( oid_ocsp_signing ),
|
||||
.oid = ASN1_CURSOR ( oid_ocsp_signing ),
|
||||
},
|
||||
};
|
||||
|
||||
@@ -631,7 +644,7 @@ static uint8_t oid_ad_ocsp[] = { ASN1_OID_OCSP };
|
||||
static struct x509_access_method x509_access_methods[] = {
|
||||
{
|
||||
.name = "OCSP",
|
||||
.oid = ASN1_OID_CURSOR ( oid_ad_ocsp ),
|
||||
.oid = ASN1_CURSOR ( oid_ad_ocsp ),
|
||||
.parse = x509_parse_ocsp,
|
||||
},
|
||||
};
|
||||
@@ -768,27 +781,27 @@ static uint8_t oid_ce_subject_alt_name[] =
|
||||
static struct x509_extension x509_extensions[] = {
|
||||
{
|
||||
.name = "basicConstraints",
|
||||
.oid = ASN1_OID_CURSOR ( oid_ce_basic_constraints ),
|
||||
.oid = ASN1_CURSOR ( oid_ce_basic_constraints ),
|
||||
.parse = x509_parse_basic_constraints,
|
||||
},
|
||||
{
|
||||
.name = "keyUsage",
|
||||
.oid = ASN1_OID_CURSOR ( oid_ce_key_usage ),
|
||||
.oid = ASN1_CURSOR ( oid_ce_key_usage ),
|
||||
.parse = x509_parse_key_usage,
|
||||
},
|
||||
{
|
||||
.name = "extKeyUsage",
|
||||
.oid = ASN1_OID_CURSOR ( oid_ce_ext_key_usage ),
|
||||
.oid = ASN1_CURSOR ( oid_ce_ext_key_usage ),
|
||||
.parse = x509_parse_extended_key_usage,
|
||||
},
|
||||
{
|
||||
.name = "authorityInfoAccess",
|
||||
.oid = ASN1_OID_CURSOR ( oid_pe_authority_info_access ),
|
||||
.oid = ASN1_CURSOR ( oid_pe_authority_info_access ),
|
||||
.parse = x509_parse_authority_info_access,
|
||||
},
|
||||
{
|
||||
.name = "subjectAltName",
|
||||
.oid = ASN1_OID_CURSOR ( oid_ce_subject_alt_name ),
|
||||
.oid = ASN1_CURSOR ( oid_ce_subject_alt_name ),
|
||||
.parse = x509_parse_subject_alt_name,
|
||||
},
|
||||
};
|
||||
@@ -1075,7 +1088,7 @@ int x509_certificate ( const void *data, size_t len,
|
||||
*cert = zalloc ( sizeof ( **cert ) + cursor.len );
|
||||
if ( ! *cert )
|
||||
return -ENOMEM;
|
||||
ref_init ( &(*cert)->refcnt, NULL );
|
||||
ref_init ( &(*cert)->refcnt, x509_free );
|
||||
raw = ( *cert + 1 );
|
||||
|
||||
/* Copy raw data */
|
||||
@@ -1295,6 +1308,50 @@ int x509_check_time ( struct x509_certificate *cert, time_t time ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if X.509 certificate is valid
|
||||
*
|
||||
* @v cert X.509 certificate
|
||||
* @v root Root certificate list, or NULL to use default
|
||||
*/
|
||||
int x509_is_valid ( struct x509_certificate *cert, struct x509_root *root ) {
|
||||
|
||||
/* Use default root certificate store if none specified */
|
||||
if ( ! root )
|
||||
root = &root_certificates;
|
||||
|
||||
return ( cert->root == root );
|
||||
}
|
||||
|
||||
/**
|
||||
* Set X.509 certificate as validated
|
||||
*
|
||||
* @v cert X.509 certificate
|
||||
* @v issuer Issuing X.509 certificate (or NULL)
|
||||
* @v root Root certificate list
|
||||
*/
|
||||
static void x509_set_valid ( struct x509_certificate *cert,
|
||||
struct x509_certificate *issuer,
|
||||
struct x509_root *root ) {
|
||||
unsigned int max_path_remaining;
|
||||
|
||||
/* Sanity checks */
|
||||
assert ( root != NULL );
|
||||
assert ( ( issuer == NULL ) || ( issuer->path_remaining >= 1 ) );
|
||||
|
||||
/* Record validation root */
|
||||
x509_root_put ( cert->root );
|
||||
cert->root = x509_root_get ( root );
|
||||
|
||||
/* Calculate effective path length */
|
||||
cert->path_remaining = ( cert->extensions.basic.path_len + 1 );
|
||||
if ( issuer ) {
|
||||
max_path_remaining = ( issuer->path_remaining - 1 );
|
||||
if ( cert->path_remaining > max_path_remaining )
|
||||
cert->path_remaining = max_path_remaining;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate X.509 certificate
|
||||
*
|
||||
@@ -1313,7 +1370,6 @@ int x509_check_time ( struct x509_certificate *cert, time_t time ) {
|
||||
int x509_validate ( struct x509_certificate *cert,
|
||||
struct x509_certificate *issuer,
|
||||
time_t time, struct x509_root *root ) {
|
||||
unsigned int max_path_remaining;
|
||||
int rc;
|
||||
|
||||
/* Use default root certificate store if none specified */
|
||||
@@ -1321,7 +1377,7 @@ int x509_validate ( struct x509_certificate *cert,
|
||||
root = &root_certificates;
|
||||
|
||||
/* Return success if certificate has already been validated */
|
||||
if ( x509_is_valid ( cert ) )
|
||||
if ( x509_is_valid ( cert, root ) )
|
||||
return 0;
|
||||
|
||||
/* Fail if certificate is invalid at specified time */
|
||||
@@ -1330,20 +1386,19 @@ int x509_validate ( struct x509_certificate *cert,
|
||||
|
||||
/* Succeed if certificate is a trusted root certificate */
|
||||
if ( x509_check_root ( cert, root ) == 0 ) {
|
||||
cert->flags |= X509_FL_VALIDATED;
|
||||
cert->path_remaining = ( cert->extensions.basic.path_len + 1 );
|
||||
x509_set_valid ( cert, NULL, root );
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Fail unless we have an issuer */
|
||||
if ( ! issuer ) {
|
||||
DBGC2 ( cert, "X509 %p \"%s\" has no issuer\n",
|
||||
DBGC2 ( cert, "X509 %p \"%s\" has no trusted issuer\n",
|
||||
cert, x509_name ( cert ) );
|
||||
return -EACCES_UNTRUSTED;
|
||||
}
|
||||
|
||||
/* Fail unless issuer has already been validated */
|
||||
if ( ! x509_is_valid ( issuer ) ) {
|
||||
if ( ! x509_is_valid ( issuer, root ) ) {
|
||||
DBGC ( cert, "X509 %p \"%s\" ", cert, x509_name ( cert ) );
|
||||
DBGC ( cert, "issuer %p \"%s\" has not yet been validated\n",
|
||||
issuer, x509_name ( issuer ) );
|
||||
@@ -1369,14 +1424,8 @@ int x509_validate ( struct x509_certificate *cert,
|
||||
return -EACCES_OCSP_REQUIRED;
|
||||
}
|
||||
|
||||
/* Calculate effective path length */
|
||||
cert->path_remaining = ( issuer->path_remaining - 1 );
|
||||
max_path_remaining = ( cert->extensions.basic.path_len + 1 );
|
||||
if ( cert->path_remaining > max_path_remaining )
|
||||
cert->path_remaining = max_path_remaining;
|
||||
|
||||
/* Mark certificate as valid */
|
||||
cert->flags |= X509_FL_VALIDATED;
|
||||
x509_set_valid ( cert, issuer, root );
|
||||
|
||||
DBGC ( cert, "X509 %p \"%s\" successfully validated using ",
|
||||
cert, x509_name ( cert ) );
|
||||
|
||||
@@ -84,7 +84,7 @@ static void * pci_msix_ioremap ( struct pci_device *pci, struct pci_msix *msix,
|
||||
msix, pci_msix_name ( cfg ), base, bar, offset );
|
||||
|
||||
/* Map BAR portion */
|
||||
io = ioremap ( ( start + offset ), PCI_MSIX_LEN );
|
||||
io = pci_ioremap ( pci, ( start + offset ), PCI_MSIX_LEN );
|
||||
if ( ! io ) {
|
||||
DBGC ( msix, "MSI-X %p %s could not map %#08lx\n",
|
||||
msix, pci_msix_name ( cfg ), base );
|
||||
|
||||
+66
-38
@@ -362,6 +362,35 @@ static int usb_endpoint_clear_tt ( struct usb_endpoint *ep ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear endpoint halt (if applicable)
|
||||
*
|
||||
* @v ep USB endpoint
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
int usb_endpoint_clear_halt ( struct usb_endpoint *ep ) {
|
||||
struct usb_device *usb = ep->usb;
|
||||
unsigned int type;
|
||||
int rc;
|
||||
|
||||
/* Clear transaction translator, if applicable */
|
||||
if ( ( rc = usb_endpoint_clear_tt ( ep ) ) != 0 )
|
||||
return rc;
|
||||
|
||||
/* Clear endpoint halt (if applicable) */
|
||||
type = ( ep->attributes & USB_ENDPOINT_ATTR_TYPE_MASK );
|
||||
if ( ( type != USB_ENDPOINT_ATTR_CONTROL ) &&
|
||||
( ( rc = usb_clear_feature ( usb, USB_RECIP_ENDPOINT,
|
||||
USB_ENDPOINT_HALT,
|
||||
ep->address ) ) != 0 ) ) {
|
||||
DBGC ( usb, "USB %s %s could not clear endpoint halt: %s\n",
|
||||
usb->name, usb_endpoint_name ( ep ), strerror ( rc ) );
|
||||
return rc;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Close USB endpoint
|
||||
*
|
||||
@@ -399,12 +428,15 @@ void usb_endpoint_close ( struct usb_endpoint *ep ) {
|
||||
*/
|
||||
static int usb_endpoint_reset ( struct usb_endpoint *ep ) {
|
||||
struct usb_device *usb = ep->usb;
|
||||
unsigned int type;
|
||||
int rc;
|
||||
|
||||
/* Sanity check */
|
||||
assert ( ! list_empty ( &ep->halted ) );
|
||||
|
||||
/* Clear device halt, if applicable */
|
||||
if ( ( rc = usb_endpoint_clear_halt ( ep ) ) != 0 )
|
||||
return rc;
|
||||
|
||||
/* Reset endpoint */
|
||||
if ( ( rc = ep->host->reset ( ep ) ) != 0 ) {
|
||||
DBGC ( usb, "USB %s %s could not reset: %s\n",
|
||||
@@ -412,21 +444,6 @@ static int usb_endpoint_reset ( struct usb_endpoint *ep ) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Clear transaction translator, if applicable */
|
||||
if ( ( rc = usb_endpoint_clear_tt ( ep ) ) != 0 )
|
||||
return rc;
|
||||
|
||||
/* Clear endpoint halt, if applicable */
|
||||
type = ( ep->attributes & USB_ENDPOINT_ATTR_TYPE_MASK );
|
||||
if ( ( type != USB_ENDPOINT_ATTR_CONTROL ) &&
|
||||
( ( rc = usb_clear_feature ( usb, USB_RECIP_ENDPOINT,
|
||||
USB_ENDPOINT_HALT,
|
||||
ep->address ) ) != 0 ) ) {
|
||||
DBGC ( usb, "USB %s %s could not clear endpoint halt: %s\n",
|
||||
usb->name, usb_endpoint_name ( ep ), strerror ( rc ) );
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Remove from list of halted endpoints */
|
||||
list_del ( &ep->halted );
|
||||
INIT_LIST_HEAD ( &ep->halted );
|
||||
@@ -634,12 +651,13 @@ int usb_prefill ( struct usb_endpoint *ep ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Refill endpoint
|
||||
* Refill endpoint up to specified limit
|
||||
*
|
||||
* @v ep USB endpoint
|
||||
* @v max Fill limit
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
int usb_refill ( struct usb_endpoint *ep ) {
|
||||
int usb_refill_limit ( struct usb_endpoint *ep, unsigned int max ) {
|
||||
struct io_buffer *iobuf;
|
||||
size_t reserve = ep->reserve;
|
||||
size_t len = ( ep->len ? ep->len : ep->mtu );
|
||||
@@ -650,7 +668,9 @@ int usb_refill ( struct usb_endpoint *ep ) {
|
||||
assert ( ep->max > 0 );
|
||||
|
||||
/* Refill endpoint */
|
||||
while ( ep->fill < ep->max ) {
|
||||
if ( max > ep->max )
|
||||
max = ep->max;
|
||||
while ( ep->fill < max ) {
|
||||
|
||||
/* Get or allocate buffer */
|
||||
if ( list_empty ( &ep->recycled ) ) {
|
||||
@@ -681,6 +701,16 @@ int usb_refill ( struct usb_endpoint *ep ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Refill endpoint
|
||||
*
|
||||
* @v ep USB endpoint
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
int usb_refill ( struct usb_endpoint *ep ) {
|
||||
return usb_refill_limit ( ep, ep->max );
|
||||
}
|
||||
|
||||
/**
|
||||
* Discard endpoint recycled buffer list
|
||||
*
|
||||
@@ -818,6 +848,7 @@ int usb_control ( struct usb_device *usb, unsigned int request,
|
||||
"failed: %s\n", usb->name, request,
|
||||
value, index, strerror ( rc ) );
|
||||
free_iob ( cmplt );
|
||||
usb_endpoint_reset ( ep );
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -912,9 +943,15 @@ int usb_get_string_descriptor ( struct usb_device *usb, unsigned int index,
|
||||
sizeof ( *desc ) ) ) != 0 )
|
||||
goto err_get_descriptor;
|
||||
|
||||
/* Copy to buffer */
|
||||
/* Calculate string length */
|
||||
if ( desc->header.len < sizeof ( desc->header ) ) {
|
||||
rc = -EINVAL;
|
||||
goto err_len;
|
||||
}
|
||||
actual = ( ( desc->header.len - sizeof ( desc->header ) ) /
|
||||
sizeof ( desc->character[0] ) );
|
||||
|
||||
/* Copy to buffer */
|
||||
for ( i = 0 ; ( ( i < actual ) && ( i < max ) ) ; i++ )
|
||||
buf[i] = le16_to_cpu ( desc->character[i] );
|
||||
if ( len )
|
||||
@@ -925,6 +962,7 @@ int usb_get_string_descriptor ( struct usb_device *usb, unsigned int index,
|
||||
|
||||
return actual;
|
||||
|
||||
err_len:
|
||||
err_get_descriptor:
|
||||
free ( desc );
|
||||
err_alloc:
|
||||
@@ -1615,7 +1653,9 @@ static int register_usb ( struct usb_device *usb ) {
|
||||
usb->host->close ( usb );
|
||||
err_open:
|
||||
err_speed:
|
||||
hub->driver->disable ( hub, port );
|
||||
/* Leave port enabled on failure, to avoid an endless loop of
|
||||
* failed device registrations.
|
||||
*/
|
||||
err_enable:
|
||||
list_del ( &usb->list );
|
||||
port->usb = NULL;
|
||||
@@ -1634,6 +1674,11 @@ static void unregister_usb ( struct usb_device *usb ) {
|
||||
struct io_buffer *iobuf;
|
||||
struct io_buffer *tmp;
|
||||
|
||||
DBGC ( usb, "USB %s addr %d %04x:%04x class %d:%d:%d removed\n",
|
||||
usb->name, usb->address, le16_to_cpu ( usb->device.vendor ),
|
||||
le16_to_cpu ( usb->device.product ), usb->device.class.class,
|
||||
usb->device.class.subclass, usb->device.class.protocol );
|
||||
|
||||
/* Sanity checks */
|
||||
assert ( port->usb == usb );
|
||||
|
||||
@@ -2232,23 +2277,6 @@ unsigned int usb_route_string ( struct usb_device *usb ) {
|
||||
return route;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get USB depth
|
||||
*
|
||||
* @v usb USB device
|
||||
* @ret depth Hub depth
|
||||
*/
|
||||
unsigned int usb_depth ( struct usb_device *usb ) {
|
||||
struct usb_device *parent;
|
||||
unsigned int depth;
|
||||
|
||||
/* Navigate up to root hub, constructing depth as we go */
|
||||
for ( depth = 0 ; ( parent = usb->port->hub->usb ) ; usb = parent )
|
||||
depth++;
|
||||
|
||||
return depth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get USB root hub port
|
||||
*
|
||||
|
||||
@@ -321,7 +321,7 @@ int virtio_pci_map_capability(struct pci_device *pci, int cap, size_t minlen,
|
||||
region->flags = VIRTIO_PCI_REGION_PORT;
|
||||
} else {
|
||||
/* Region mapped into memory space */
|
||||
region->base = ioremap(base + offset, length);
|
||||
region->base = pci_ioremap(pci, base + offset, length);
|
||||
region->flags = VIRTIO_PCI_REGION_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -639,8 +639,8 @@ static int arbel_create_cq ( struct ib_device *ibdev,
|
||||
|
||||
/* Allocate completion queue itself */
|
||||
arbel_cq->cqe_size = ( cq->num_cqes * sizeof ( arbel_cq->cqe[0] ) );
|
||||
arbel_cq->cqe = malloc_dma ( arbel_cq->cqe_size,
|
||||
sizeof ( arbel_cq->cqe[0] ) );
|
||||
arbel_cq->cqe = malloc_phys ( arbel_cq->cqe_size,
|
||||
sizeof ( arbel_cq->cqe[0] ) );
|
||||
if ( ! arbel_cq->cqe ) {
|
||||
rc = -ENOMEM;
|
||||
goto err_cqe;
|
||||
@@ -697,7 +697,7 @@ static int arbel_create_cq ( struct ib_device *ibdev,
|
||||
err_sw2hw_cq:
|
||||
MLX_FILL_1 ( ci_db_rec, 1, res, ARBEL_UAR_RES_NONE );
|
||||
MLX_FILL_1 ( arm_db_rec, 1, res, ARBEL_UAR_RES_NONE );
|
||||
free_dma ( arbel_cq->cqe, arbel_cq->cqe_size );
|
||||
free_phys ( arbel_cq->cqe, arbel_cq->cqe_size );
|
||||
err_cqe:
|
||||
free ( arbel_cq );
|
||||
err_arbel_cq:
|
||||
@@ -737,7 +737,7 @@ static void arbel_destroy_cq ( struct ib_device *ibdev,
|
||||
MLX_FILL_1 ( arm_db_rec, 1, res, ARBEL_UAR_RES_NONE );
|
||||
|
||||
/* Free memory */
|
||||
free_dma ( arbel_cq->cqe, arbel_cq->cqe_size );
|
||||
free_phys ( arbel_cq->cqe, arbel_cq->cqe_size );
|
||||
free ( arbel_cq );
|
||||
|
||||
/* Mark queue number as free */
|
||||
@@ -873,8 +873,8 @@ static int arbel_create_send_wq ( struct arbel_send_work_queue *arbel_send_wq,
|
||||
/* Allocate work queue */
|
||||
arbel_send_wq->wqe_size = ( num_wqes *
|
||||
sizeof ( arbel_send_wq->wqe[0] ) );
|
||||
arbel_send_wq->wqe = malloc_dma ( arbel_send_wq->wqe_size,
|
||||
sizeof ( arbel_send_wq->wqe[0] ) );
|
||||
arbel_send_wq->wqe = malloc_phys ( arbel_send_wq->wqe_size,
|
||||
sizeof ( arbel_send_wq->wqe[0] ) );
|
||||
if ( ! arbel_send_wq->wqe )
|
||||
return -ENOMEM;
|
||||
memset ( arbel_send_wq->wqe, 0, arbel_send_wq->wqe_size );
|
||||
@@ -914,8 +914,8 @@ static int arbel_create_recv_wq ( struct arbel_recv_work_queue *arbel_recv_wq,
|
||||
/* Allocate work queue */
|
||||
arbel_recv_wq->wqe_size = ( num_wqes *
|
||||
sizeof ( arbel_recv_wq->wqe[0] ) );
|
||||
arbel_recv_wq->wqe = malloc_dma ( arbel_recv_wq->wqe_size,
|
||||
sizeof ( arbel_recv_wq->wqe[0] ) );
|
||||
arbel_recv_wq->wqe = malloc_phys ( arbel_recv_wq->wqe_size,
|
||||
sizeof ( arbel_recv_wq->wqe[0] ) );
|
||||
if ( ! arbel_recv_wq->wqe ) {
|
||||
rc = -ENOMEM;
|
||||
goto err_alloc_wqe;
|
||||
@@ -927,8 +927,8 @@ static int arbel_create_recv_wq ( struct arbel_recv_work_queue *arbel_recv_wq,
|
||||
( type == IB_QPT_UD ) ) {
|
||||
arbel_recv_wq->grh_size = ( num_wqes *
|
||||
sizeof ( arbel_recv_wq->grh[0] ) );
|
||||
arbel_recv_wq->grh = malloc_dma ( arbel_recv_wq->grh_size,
|
||||
sizeof ( void * ) );
|
||||
arbel_recv_wq->grh = malloc_phys ( arbel_recv_wq->grh_size,
|
||||
sizeof ( void * ) );
|
||||
if ( ! arbel_recv_wq->grh ) {
|
||||
rc = -ENOMEM;
|
||||
goto err_alloc_grh;
|
||||
@@ -954,9 +954,9 @@ static int arbel_create_recv_wq ( struct arbel_recv_work_queue *arbel_recv_wq,
|
||||
|
||||
return 0;
|
||||
|
||||
free_dma ( arbel_recv_wq->grh, arbel_recv_wq->grh_size );
|
||||
free_phys ( arbel_recv_wq->grh, arbel_recv_wq->grh_size );
|
||||
err_alloc_grh:
|
||||
free_dma ( arbel_recv_wq->wqe, arbel_recv_wq->wqe_size );
|
||||
free_phys ( arbel_recv_wq->wqe, arbel_recv_wq->wqe_size );
|
||||
err_alloc_wqe:
|
||||
return rc;
|
||||
}
|
||||
@@ -1102,10 +1102,10 @@ static int arbel_create_qp ( struct ib_device *ibdev,
|
||||
MLX_FILL_1 ( send_db_rec, 1, res, ARBEL_UAR_RES_NONE );
|
||||
MLX_FILL_1 ( recv_db_rec, 1, res, ARBEL_UAR_RES_NONE );
|
||||
err_unsupported_address_split:
|
||||
free_dma ( arbel_qp->recv.grh, arbel_qp->recv.grh_size );
|
||||
free_dma ( arbel_qp->recv.wqe, arbel_qp->recv.wqe_size );
|
||||
free_phys ( arbel_qp->recv.grh, arbel_qp->recv.grh_size );
|
||||
free_phys ( arbel_qp->recv.wqe, arbel_qp->recv.wqe_size );
|
||||
err_create_recv_wq:
|
||||
free_dma ( arbel_qp->send.wqe, arbel_qp->send.wqe_size );
|
||||
free_phys ( arbel_qp->send.wqe, arbel_qp->send.wqe_size );
|
||||
err_create_send_wq:
|
||||
free ( arbel_qp );
|
||||
err_arbel_qp:
|
||||
@@ -1231,9 +1231,9 @@ static void arbel_destroy_qp ( struct ib_device *ibdev,
|
||||
MLX_FILL_1 ( recv_db_rec, 1, res, ARBEL_UAR_RES_NONE );
|
||||
|
||||
/* Free memory */
|
||||
free_dma ( arbel_qp->recv.grh, arbel_qp->recv.grh_size );
|
||||
free_dma ( arbel_qp->recv.wqe, arbel_qp->recv.wqe_size );
|
||||
free_dma ( arbel_qp->send.wqe, arbel_qp->send.wqe_size );
|
||||
free_phys ( arbel_qp->recv.grh, arbel_qp->recv.grh_size );
|
||||
free_phys ( arbel_qp->recv.wqe, arbel_qp->recv.wqe_size );
|
||||
free_phys ( arbel_qp->send.wqe, arbel_qp->send.wqe_size );
|
||||
free ( arbel_qp );
|
||||
|
||||
/* Mark queue number as free */
|
||||
@@ -1758,8 +1758,8 @@ static int arbel_create_eq ( struct arbel *arbel ) {
|
||||
/* Allocate event queue itself */
|
||||
arbel_eq->eqe_size =
|
||||
( ARBEL_NUM_EQES * sizeof ( arbel_eq->eqe[0] ) );
|
||||
arbel_eq->eqe = malloc_dma ( arbel_eq->eqe_size,
|
||||
sizeof ( arbel_eq->eqe[0] ) );
|
||||
arbel_eq->eqe = malloc_phys ( arbel_eq->eqe_size,
|
||||
sizeof ( arbel_eq->eqe[0] ) );
|
||||
if ( ! arbel_eq->eqe ) {
|
||||
rc = -ENOMEM;
|
||||
goto err_eqe;
|
||||
@@ -1806,7 +1806,7 @@ static int arbel_create_eq ( struct arbel *arbel ) {
|
||||
err_map_eq:
|
||||
arbel_cmd_hw2sw_eq ( arbel, arbel_eq->eqn, &eqctx );
|
||||
err_sw2hw_eq:
|
||||
free_dma ( arbel_eq->eqe, arbel_eq->eqe_size );
|
||||
free_phys ( arbel_eq->eqe, arbel_eq->eqe_size );
|
||||
err_eqe:
|
||||
memset ( arbel_eq, 0, sizeof ( *arbel_eq ) );
|
||||
return rc;
|
||||
@@ -1844,7 +1844,7 @@ static void arbel_destroy_eq ( struct arbel *arbel ) {
|
||||
}
|
||||
|
||||
/* Free memory */
|
||||
free_dma ( arbel_eq->eqe, arbel_eq->eqe_size );
|
||||
free_phys ( arbel_eq->eqe, arbel_eq->eqe_size );
|
||||
memset ( arbel_eq, 0, sizeof ( *arbel_eq ) );
|
||||
}
|
||||
|
||||
@@ -2059,7 +2059,8 @@ static int arbel_start_firmware ( struct arbel *arbel ) {
|
||||
eq_set_ci_base_addr =
|
||||
( ( (uint64_t) MLX_GET ( &fw, eq_set_ci_base_addr_h ) << 32 ) |
|
||||
( (uint64_t) MLX_GET ( &fw, eq_set_ci_base_addr_l ) ) );
|
||||
arbel->eq_ci_doorbells = ioremap ( eq_set_ci_base_addr, 0x200 );
|
||||
arbel->eq_ci_doorbells = pci_ioremap ( arbel->pci, eq_set_ci_base_addr,
|
||||
0x200 );
|
||||
|
||||
/* Enable locally-attached memory. Ignore failure; there may
|
||||
* be no attached memory.
|
||||
@@ -2454,7 +2455,7 @@ static int arbel_alloc_icm ( struct arbel *arbel,
|
||||
icm_phys = user_to_phys ( arbel->icm, 0 );
|
||||
|
||||
/* Allocate doorbell UAR */
|
||||
arbel->db_rec = malloc_dma ( ARBEL_PAGE_SIZE, ARBEL_PAGE_SIZE );
|
||||
arbel->db_rec = malloc_phys ( ARBEL_PAGE_SIZE, ARBEL_PAGE_SIZE );
|
||||
if ( ! arbel->db_rec ) {
|
||||
rc = -ENOMEM;
|
||||
goto err_alloc_doorbell;
|
||||
@@ -2512,7 +2513,7 @@ static int arbel_alloc_icm ( struct arbel *arbel,
|
||||
err_map_icm:
|
||||
arbel_cmd_unmap_icm_aux ( arbel );
|
||||
err_map_icm_aux:
|
||||
free_dma ( arbel->db_rec, ARBEL_PAGE_SIZE );
|
||||
free_phys ( arbel->db_rec, ARBEL_PAGE_SIZE );
|
||||
arbel->db_rec= NULL;
|
||||
err_alloc_doorbell:
|
||||
err_alloc_icm:
|
||||
@@ -2535,7 +2536,7 @@ static void arbel_free_icm ( struct arbel *arbel ) {
|
||||
arbel_cmd_unmap_icm ( arbel, ( arbel->icm_len / ARBEL_PAGE_SIZE ),
|
||||
&unmap_icm );
|
||||
arbel_cmd_unmap_icm_aux ( arbel );
|
||||
free_dma ( arbel->db_rec, ARBEL_PAGE_SIZE );
|
||||
free_phys ( arbel->db_rec, ARBEL_PAGE_SIZE );
|
||||
arbel->db_rec = NULL;
|
||||
}
|
||||
|
||||
@@ -2983,18 +2984,18 @@ static struct arbel * arbel_alloc ( void ) {
|
||||
goto err_arbel;
|
||||
|
||||
/* Allocate space for mailboxes */
|
||||
arbel->mailbox_in = malloc_dma ( ARBEL_MBOX_SIZE, ARBEL_MBOX_ALIGN );
|
||||
arbel->mailbox_in = malloc_phys ( ARBEL_MBOX_SIZE, ARBEL_MBOX_ALIGN );
|
||||
if ( ! arbel->mailbox_in )
|
||||
goto err_mailbox_in;
|
||||
arbel->mailbox_out = malloc_dma ( ARBEL_MBOX_SIZE, ARBEL_MBOX_ALIGN );
|
||||
arbel->mailbox_out = malloc_phys ( ARBEL_MBOX_SIZE, ARBEL_MBOX_ALIGN );
|
||||
if ( ! arbel->mailbox_out )
|
||||
goto err_mailbox_out;
|
||||
|
||||
return arbel;
|
||||
|
||||
free_dma ( arbel->mailbox_out, ARBEL_MBOX_SIZE );
|
||||
free_phys ( arbel->mailbox_out, ARBEL_MBOX_SIZE );
|
||||
err_mailbox_out:
|
||||
free_dma ( arbel->mailbox_in, ARBEL_MBOX_SIZE );
|
||||
free_phys ( arbel->mailbox_in, ARBEL_MBOX_SIZE );
|
||||
err_mailbox_in:
|
||||
free ( arbel );
|
||||
err_arbel:
|
||||
@@ -3010,8 +3011,8 @@ static void arbel_free ( struct arbel *arbel ) {
|
||||
|
||||
ufree ( arbel->icm );
|
||||
ufree ( arbel->firmware_area );
|
||||
free_dma ( arbel->mailbox_out, ARBEL_MBOX_SIZE );
|
||||
free_dma ( arbel->mailbox_in, ARBEL_MBOX_SIZE );
|
||||
free_phys ( arbel->mailbox_out, ARBEL_MBOX_SIZE );
|
||||
free_phys ( arbel->mailbox_in, ARBEL_MBOX_SIZE );
|
||||
free ( arbel );
|
||||
}
|
||||
|
||||
@@ -3025,6 +3026,8 @@ static void arbel_free ( struct arbel *arbel ) {
|
||||
static int arbel_probe ( struct pci_device *pci ) {
|
||||
struct arbel *arbel;
|
||||
struct ib_device *ibdev;
|
||||
unsigned long config;
|
||||
unsigned long uar;
|
||||
int i;
|
||||
int rc;
|
||||
|
||||
@@ -3041,11 +3044,11 @@ static int arbel_probe ( struct pci_device *pci ) {
|
||||
adjust_pci_device ( pci );
|
||||
|
||||
/* Map PCI BARs */
|
||||
arbel->config = ioremap ( pci_bar_start ( pci, ARBEL_PCI_CONFIG_BAR ),
|
||||
ARBEL_PCI_CONFIG_BAR_SIZE );
|
||||
arbel->uar = ioremap ( ( pci_bar_start ( pci, ARBEL_PCI_UAR_BAR ) +
|
||||
ARBEL_PCI_UAR_IDX * ARBEL_PCI_UAR_SIZE ),
|
||||
ARBEL_PCI_UAR_SIZE );
|
||||
config = pci_bar_start ( pci, ARBEL_PCI_CONFIG_BAR );
|
||||
arbel->config = pci_ioremap ( pci, config, ARBEL_PCI_CONFIG_BAR_SIZE );
|
||||
uar = ( pci_bar_start ( pci, ARBEL_PCI_UAR_BAR ) +
|
||||
ARBEL_PCI_UAR_IDX * ARBEL_PCI_UAR_SIZE );
|
||||
arbel->uar = pci_ioremap ( pci, uar, ARBEL_PCI_UAR_SIZE );
|
||||
|
||||
/* Allocate Infiniband devices */
|
||||
for ( i = 0 ; i < ARBEL_NUM_PORTS ; i++ ) {
|
||||
|
||||
@@ -365,7 +365,8 @@ static int flexboot_nodnic_create_qp ( struct ib_device *ibdev,
|
||||
goto qp_alloc_err;
|
||||
}
|
||||
|
||||
status = nodnic_port_create_qp(&port->port_priv, qp->type,
|
||||
status = nodnic_port_create_qp(&port->port_priv,
|
||||
(nodnic_queue_pair_type) qp->type,
|
||||
qp->send.num_wqes * sizeof(struct nodnic_send_wqbb),
|
||||
qp->send.num_wqes,
|
||||
qp->recv.num_wqes * sizeof(struct nodnic_recv_wqe),
|
||||
@@ -406,7 +407,8 @@ static void flexboot_nodnic_destroy_qp ( struct ib_device *ibdev,
|
||||
struct flexboot_nodnic_port *port = &flexboot_nodnic->port[ibdev->port - 1];
|
||||
struct flexboot_nodnic_queue_pair *flexboot_nodnic_qp = ib_qp_get_drvdata ( qp );
|
||||
|
||||
nodnic_port_destroy_qp(&port->port_priv, qp->type,
|
||||
nodnic_port_destroy_qp(&port->port_priv,
|
||||
(nodnic_queue_pair_type) qp->type,
|
||||
flexboot_nodnic_qp->nodnic_queue_pair);
|
||||
|
||||
free(flexboot_nodnic_qp);
|
||||
@@ -1459,7 +1461,7 @@ static int flexboot_nodnic_alloc_uar ( struct flexboot_nodnic *flexboot_nodnic )
|
||||
return -EINVAL;
|
||||
}
|
||||
uar->phys = ( pci_bar_start ( pci, FLEXBOOT_NODNIC_HCA_BAR ) + (mlx_uint32)uar->offset );
|
||||
uar->virt = ( void * )( ioremap ( uar->phys, FLEXBOOT_NODNIC_PAGE_SIZE ) );
|
||||
uar->virt = ( void * )( pci_ioremap ( pci, uar->phys, FLEXBOOT_NODNIC_PAGE_SIZE ) );
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -585,9 +585,9 @@ static inline int golan_set_access_reg ( struct golan *golan __attribute__ (( un
|
||||
|
||||
static inline void golan_cmd_uninit ( struct golan *golan )
|
||||
{
|
||||
free_dma(golan->mboxes.outbox, GOLAN_PAGE_SIZE);
|
||||
free_dma(golan->mboxes.inbox, GOLAN_PAGE_SIZE);
|
||||
free_dma(golan->cmd.addr, GOLAN_PAGE_SIZE);
|
||||
free_phys(golan->mboxes.outbox, GOLAN_PAGE_SIZE);
|
||||
free_phys(golan->mboxes.inbox, GOLAN_PAGE_SIZE);
|
||||
free_phys(golan->cmd.addr, GOLAN_PAGE_SIZE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -602,17 +602,17 @@ static inline int golan_cmd_init ( struct golan *golan )
|
||||
int rc = 0;
|
||||
uint32_t addr_l_sz;
|
||||
|
||||
if (!(golan->cmd.addr = malloc_dma(GOLAN_PAGE_SIZE , GOLAN_PAGE_SIZE))) {
|
||||
if (!(golan->cmd.addr = malloc_phys(GOLAN_PAGE_SIZE , GOLAN_PAGE_SIZE))) {
|
||||
rc = -ENOMEM;
|
||||
goto malloc_dma_failed;
|
||||
goto malloc_phys_failed;
|
||||
}
|
||||
if (!(golan->mboxes.inbox = malloc_dma(GOLAN_PAGE_SIZE , GOLAN_PAGE_SIZE))) {
|
||||
if (!(golan->mboxes.inbox = malloc_phys(GOLAN_PAGE_SIZE , GOLAN_PAGE_SIZE))) {
|
||||
rc = -ENOMEM;
|
||||
goto malloc_dma_inbox_failed;
|
||||
goto malloc_phys_inbox_failed;
|
||||
}
|
||||
if (!(golan->mboxes.outbox = malloc_dma(GOLAN_PAGE_SIZE , GOLAN_PAGE_SIZE))) {
|
||||
if (!(golan->mboxes.outbox = malloc_phys(GOLAN_PAGE_SIZE , GOLAN_PAGE_SIZE))) {
|
||||
rc = -ENOMEM;
|
||||
goto malloc_dma_outbox_failed;
|
||||
goto malloc_phys_outbox_failed;
|
||||
}
|
||||
addr_l_sz = be32_to_cpu(readl(&golan->iseg->cmdq_addr_l_sz));
|
||||
|
||||
@@ -629,11 +629,11 @@ static inline int golan_cmd_init ( struct golan *golan )
|
||||
DBGC( golan , "%s Command interface was initialized\n", __FUNCTION__);
|
||||
return 0;
|
||||
|
||||
malloc_dma_outbox_failed:
|
||||
free_dma(golan->mboxes.inbox, GOLAN_PAGE_SIZE);
|
||||
malloc_dma_inbox_failed:
|
||||
free_dma(golan->cmd.addr, GOLAN_PAGE_SIZE);
|
||||
malloc_dma_failed:
|
||||
malloc_phys_outbox_failed:
|
||||
free_phys(golan->mboxes.inbox, GOLAN_PAGE_SIZE);
|
||||
malloc_phys_inbox_failed:
|
||||
free_phys(golan->cmd.addr, GOLAN_PAGE_SIZE);
|
||||
malloc_phys_failed:
|
||||
DBGC (golan ,"%s Failed to initialize command interface (rc = 0x%x)\n",
|
||||
__FUNCTION__, rc);
|
||||
return rc;
|
||||
@@ -693,7 +693,7 @@ static inline int golan_alloc_uar(struct golan *golan)
|
||||
uar->index = be32_to_cpu(out->uarn) & 0xffffff;
|
||||
|
||||
uar->phys = (pci_bar_start(golan->pci, GOLAN_HCA_BAR) + (uar->index << GOLAN_PAGE_SHIFT));
|
||||
uar->virt = (void *)(ioremap(uar->phys, GOLAN_PAGE_SIZE));
|
||||
uar->virt = (void *)(pci_ioremap(golan->pci, uar->phys, GOLAN_PAGE_SIZE));
|
||||
|
||||
DBGC( golan , "%s: UAR allocated with index 0x%x\n", __FUNCTION__, uar->index);
|
||||
return 0;
|
||||
@@ -743,7 +743,7 @@ static int golan_create_eq(struct golan *golan)
|
||||
|
||||
eq->cons_index = 0;
|
||||
eq->size = GOLAN_NUM_EQES * sizeof(eq->eqes[0]);
|
||||
eq->eqes = malloc_dma ( GOLAN_PAGE_SIZE, GOLAN_PAGE_SIZE );
|
||||
eq->eqes = malloc_phys ( GOLAN_PAGE_SIZE, GOLAN_PAGE_SIZE );
|
||||
if (!eq->eqes) {
|
||||
rc = -ENOMEM;
|
||||
goto err_create_eq_eqe_alloc;
|
||||
@@ -781,7 +781,7 @@ static int golan_create_eq(struct golan *golan)
|
||||
return 0;
|
||||
|
||||
err_create_eq_cmd:
|
||||
free_dma ( eq->eqes , GOLAN_PAGE_SIZE );
|
||||
free_phys ( eq->eqes , GOLAN_PAGE_SIZE );
|
||||
err_create_eq_eqe_alloc:
|
||||
DBGC (golan ,"%s [%d] out\n", __FUNCTION__, rc);
|
||||
return rc;
|
||||
@@ -806,7 +806,7 @@ static void golan_destory_eq(struct golan *golan)
|
||||
rc = send_command_and_wait(golan, DEF_CMD_IDX, NO_MBOX, NO_MBOX, __FUNCTION__);
|
||||
GOLAN_PRINT_RC_AND_CMD_STATUS;
|
||||
|
||||
free_dma ( golan->eq.eqes , GOLAN_PAGE_SIZE );
|
||||
free_phys ( golan->eq.eqes , GOLAN_PAGE_SIZE );
|
||||
golan->eq.eqn = 0;
|
||||
|
||||
DBGC( golan, "%s Event queue (0x%x) was destroyed\n", __FUNCTION__, eqn);
|
||||
@@ -922,8 +922,8 @@ static inline void golan_pci_init(struct golan *golan)
|
||||
adjust_pci_device ( pci );
|
||||
|
||||
/* Get HCA BAR */
|
||||
golan->iseg = ioremap ( pci_bar_start ( pci, GOLAN_HCA_BAR),
|
||||
GOLAN_PCI_CONFIG_BAR_SIZE );
|
||||
golan->iseg = pci_ioremap ( pci, pci_bar_start ( pci, GOLAN_HCA_BAR),
|
||||
GOLAN_PCI_CONFIG_BAR_SIZE );
|
||||
}
|
||||
|
||||
static inline struct golan *golan_alloc()
|
||||
@@ -962,14 +962,14 @@ static int golan_create_cq(struct ib_device *ibdev,
|
||||
goto err_create_cq;
|
||||
}
|
||||
golan_cq->size = sizeof(golan_cq->cqes[0]) * cq->num_cqes;
|
||||
golan_cq->doorbell_record = malloc_dma(GOLAN_CQ_DB_RECORD_SIZE,
|
||||
golan_cq->doorbell_record = malloc_phys(GOLAN_CQ_DB_RECORD_SIZE,
|
||||
GOLAN_CQ_DB_RECORD_SIZE);
|
||||
if (!golan_cq->doorbell_record) {
|
||||
rc = -ENOMEM;
|
||||
goto err_create_cq_db_alloc;
|
||||
}
|
||||
|
||||
golan_cq->cqes = malloc_dma ( GOLAN_PAGE_SIZE, GOLAN_PAGE_SIZE );
|
||||
golan_cq->cqes = malloc_phys ( GOLAN_PAGE_SIZE, GOLAN_PAGE_SIZE );
|
||||
if (!golan_cq->cqes) {
|
||||
rc = -ENOMEM;
|
||||
goto err_create_cq_cqe_alloc;
|
||||
@@ -1008,9 +1008,9 @@ static int golan_create_cq(struct ib_device *ibdev,
|
||||
return 0;
|
||||
|
||||
err_create_cq_cmd:
|
||||
free_dma( golan_cq->cqes , GOLAN_PAGE_SIZE );
|
||||
free_phys( golan_cq->cqes , GOLAN_PAGE_SIZE );
|
||||
err_create_cq_cqe_alloc:
|
||||
free_dma(golan_cq->doorbell_record, GOLAN_CQ_DB_RECORD_SIZE);
|
||||
free_phys(golan_cq->doorbell_record, GOLAN_CQ_DB_RECORD_SIZE);
|
||||
err_create_cq_db_alloc:
|
||||
free ( golan_cq );
|
||||
err_create_cq:
|
||||
@@ -1045,8 +1045,8 @@ static void golan_destroy_cq(struct ib_device *ibdev,
|
||||
cq->cqn = 0;
|
||||
|
||||
ib_cq_set_drvdata(cq, NULL);
|
||||
free_dma ( golan_cq->cqes , GOLAN_PAGE_SIZE );
|
||||
free_dma(golan_cq->doorbell_record, GOLAN_CQ_DB_RECORD_SIZE);
|
||||
free_phys ( golan_cq->cqes , GOLAN_PAGE_SIZE );
|
||||
free_phys(golan_cq->doorbell_record, GOLAN_CQ_DB_RECORD_SIZE);
|
||||
free(golan_cq);
|
||||
|
||||
DBGC (golan, "%s CQ number 0x%x was destroyed\n", __FUNCTION__, cqn);
|
||||
@@ -1138,7 +1138,7 @@ static int golan_create_qp_aux(struct ib_device *ibdev,
|
||||
golan_qp->size = golan_qp->sq.size + golan_qp->rq.size;
|
||||
|
||||
/* allocate dma memory for WQEs (1 page is enough) - should change it */
|
||||
golan_qp->wqes = malloc_dma ( GOLAN_PAGE_SIZE, GOLAN_PAGE_SIZE );
|
||||
golan_qp->wqes = malloc_phys ( GOLAN_PAGE_SIZE, GOLAN_PAGE_SIZE );
|
||||
if (!golan_qp->wqes) {
|
||||
rc = -ENOMEM;
|
||||
goto err_create_qp_wqe_alloc;
|
||||
@@ -1160,7 +1160,7 @@ static int golan_create_qp_aux(struct ib_device *ibdev,
|
||||
data++;
|
||||
}
|
||||
|
||||
golan_qp->doorbell_record = malloc_dma(sizeof(struct golan_qp_db),
|
||||
golan_qp->doorbell_record = malloc_phys(sizeof(struct golan_qp_db),
|
||||
sizeof(struct golan_qp_db));
|
||||
if (!golan_qp->doorbell_record) {
|
||||
rc = -ENOMEM;
|
||||
@@ -1213,9 +1213,9 @@ static int golan_create_qp_aux(struct ib_device *ibdev,
|
||||
return 0;
|
||||
|
||||
err_create_qp_cmd:
|
||||
free_dma(golan_qp->doorbell_record, sizeof(struct golan_qp_db));
|
||||
free_phys(golan_qp->doorbell_record, sizeof(struct golan_qp_db));
|
||||
err_create_qp_db_alloc:
|
||||
free_dma ( golan_qp->wqes, GOLAN_PAGE_SIZE );
|
||||
free_phys ( golan_qp->wqes, GOLAN_PAGE_SIZE );
|
||||
err_create_qp_wqe_alloc:
|
||||
err_create_qp_sq_size:
|
||||
err_create_qp_sq_wqe_size:
|
||||
@@ -1422,8 +1422,8 @@ static void golan_destroy_qp(struct ib_device *ibdev,
|
||||
qp->qpn = 0;
|
||||
|
||||
ib_qp_set_drvdata(qp, NULL);
|
||||
free_dma(golan_qp->doorbell_record, sizeof(struct golan_qp_db));
|
||||
free_dma ( golan_qp->wqes, GOLAN_PAGE_SIZE );
|
||||
free_phys(golan_qp->doorbell_record, sizeof(struct golan_qp_db));
|
||||
free_phys ( golan_qp->wqes, GOLAN_PAGE_SIZE );
|
||||
free(golan_qp);
|
||||
|
||||
DBGC( golan ,"%s QP 0x%lx was destroyed\n", __FUNCTION__, qpn);
|
||||
@@ -2642,7 +2642,10 @@ static struct pci_device_id golan_nics[] = {
|
||||
PCI_ROM ( 0x15b3, 0x1019, "ConnectX-5EX", "ConnectX-5EX HCA driver, DevID 4121", 0 ),
|
||||
PCI_ROM ( 0x15b3, 0x101b, "ConnectX-6", "ConnectX-6 HCA driver, DevID 4123", 0 ),
|
||||
PCI_ROM ( 0x15b3, 0x101d, "ConnectX-6DX", "ConnectX-6DX HCA driver, DevID 4125", 0 ),
|
||||
PCI_ROM ( 0x15b3, 0x101f, "ConnectX-6Lx", "ConnectX-6LX HCA driver, DevID 4127", 0 ),
|
||||
PCI_ROM ( 0x15b3, 0x1021, "ConnectX-7", "ConnectX-7 HCA driver, DevID 4129", 0 ),
|
||||
PCI_ROM ( 0x15b3, 0xa2d2, "BlueField", "BlueField integrated ConnectX-5 network controller HCA driver, DevID 41682", 0 ),
|
||||
PCI_ROM ( 0x15b3, 0xa2d6, "BlueField-2", "BlueField-2 network controller HCA driver, DevID 41686", 0 ),
|
||||
};
|
||||
|
||||
struct pci_driver golan_driver __pci_driver = {
|
||||
|
||||
@@ -864,8 +864,8 @@ static int hermon_create_cq ( struct ib_device *ibdev,
|
||||
}
|
||||
|
||||
/* Allocate doorbell */
|
||||
hermon_cq->doorbell = malloc_dma ( sizeof ( hermon_cq->doorbell[0] ),
|
||||
sizeof ( hermon_cq->doorbell[0] ) );
|
||||
hermon_cq->doorbell = malloc_phys ( sizeof ( hermon_cq->doorbell[0] ),
|
||||
sizeof ( hermon_cq->doorbell[0] ) );
|
||||
if ( ! hermon_cq->doorbell ) {
|
||||
rc = -ENOMEM;
|
||||
goto err_doorbell;
|
||||
@@ -874,8 +874,8 @@ static int hermon_create_cq ( struct ib_device *ibdev,
|
||||
|
||||
/* Allocate completion queue itself */
|
||||
hermon_cq->cqe_size = ( cq->num_cqes * sizeof ( hermon_cq->cqe[0] ) );
|
||||
hermon_cq->cqe = malloc_dma ( hermon_cq->cqe_size,
|
||||
sizeof ( hermon_cq->cqe[0] ) );
|
||||
hermon_cq->cqe = malloc_phys ( hermon_cq->cqe_size,
|
||||
sizeof ( hermon_cq->cqe[0] ) );
|
||||
if ( ! hermon_cq->cqe ) {
|
||||
rc = -ENOMEM;
|
||||
goto err_cqe;
|
||||
@@ -925,9 +925,9 @@ static int hermon_create_cq ( struct ib_device *ibdev,
|
||||
err_sw2hw_cq:
|
||||
hermon_free_mtt ( hermon, &hermon_cq->mtt );
|
||||
err_alloc_mtt:
|
||||
free_dma ( hermon_cq->cqe, hermon_cq->cqe_size );
|
||||
free_phys ( hermon_cq->cqe, hermon_cq->cqe_size );
|
||||
err_cqe:
|
||||
free_dma ( hermon_cq->doorbell, sizeof ( hermon_cq->doorbell[0] ) );
|
||||
free_phys ( hermon_cq->doorbell, sizeof ( hermon_cq->doorbell[0] ) );
|
||||
err_doorbell:
|
||||
free ( hermon_cq );
|
||||
err_hermon_cq:
|
||||
@@ -962,8 +962,8 @@ static void hermon_destroy_cq ( struct ib_device *ibdev,
|
||||
hermon_free_mtt ( hermon, &hermon_cq->mtt );
|
||||
|
||||
/* Free memory */
|
||||
free_dma ( hermon_cq->cqe, hermon_cq->cqe_size );
|
||||
free_dma ( hermon_cq->doorbell, sizeof ( hermon_cq->doorbell[0] ) );
|
||||
free_phys ( hermon_cq->cqe, hermon_cq->cqe_size );
|
||||
free_phys ( hermon_cq->doorbell, sizeof ( hermon_cq->doorbell[0] ) );
|
||||
free ( hermon_cq );
|
||||
|
||||
/* Mark queue number as free */
|
||||
@@ -1128,8 +1128,8 @@ static int hermon_create_qp ( struct ib_device *ibdev,
|
||||
|
||||
/* Allocate doorbells */
|
||||
hermon_qp->recv.doorbell =
|
||||
malloc_dma ( sizeof ( hermon_qp->recv.doorbell[0] ),
|
||||
sizeof ( hermon_qp->recv.doorbell[0] ) );
|
||||
malloc_phys ( sizeof ( hermon_qp->recv.doorbell[0] ),
|
||||
sizeof ( hermon_qp->recv.doorbell[0] ) );
|
||||
if ( ! hermon_qp->recv.doorbell ) {
|
||||
rc = -ENOMEM;
|
||||
goto err_recv_doorbell;
|
||||
@@ -1157,8 +1157,8 @@ static int hermon_create_qp ( struct ib_device *ibdev,
|
||||
hermon_qp->wqe_size = ( hermon_qp->send.wqe_size +
|
||||
hermon_qp->recv.wqe_size +
|
||||
hermon_qp->recv.grh_size );
|
||||
hermon_qp->wqe = malloc_dma ( hermon_qp->wqe_size,
|
||||
sizeof ( hermon_qp->send.wqe[0] ) );
|
||||
hermon_qp->wqe = malloc_phys ( hermon_qp->wqe_size,
|
||||
sizeof ( hermon_qp->send.wqe[0] ) );
|
||||
if ( ! hermon_qp->wqe ) {
|
||||
rc = -ENOMEM;
|
||||
goto err_alloc_wqe;
|
||||
@@ -1248,10 +1248,10 @@ static int hermon_create_qp ( struct ib_device *ibdev,
|
||||
err_rst2init_qp:
|
||||
hermon_free_mtt ( hermon, &hermon_qp->mtt );
|
||||
err_alloc_mtt:
|
||||
free_dma ( hermon_qp->wqe, hermon_qp->wqe_size );
|
||||
free_phys ( hermon_qp->wqe, hermon_qp->wqe_size );
|
||||
err_alloc_wqe:
|
||||
free_dma ( hermon_qp->recv.doorbell,
|
||||
sizeof ( hermon_qp->recv.doorbell[0] ) );
|
||||
free_phys ( hermon_qp->recv.doorbell,
|
||||
sizeof ( hermon_qp->recv.doorbell[0] ) );
|
||||
err_recv_doorbell:
|
||||
free ( hermon_qp );
|
||||
err_hermon_qp:
|
||||
@@ -1363,9 +1363,9 @@ static void hermon_destroy_qp ( struct ib_device *ibdev,
|
||||
hermon_free_mtt ( hermon, &hermon_qp->mtt );
|
||||
|
||||
/* Free memory */
|
||||
free_dma ( hermon_qp->wqe, hermon_qp->wqe_size );
|
||||
free_dma ( hermon_qp->recv.doorbell,
|
||||
sizeof ( hermon_qp->recv.doorbell[0] ) );
|
||||
free_phys ( hermon_qp->wqe, hermon_qp->wqe_size );
|
||||
free_phys ( hermon_qp->recv.doorbell,
|
||||
sizeof ( hermon_qp->recv.doorbell[0] ) );
|
||||
free ( hermon_qp );
|
||||
|
||||
/* Mark queue number as free */
|
||||
@@ -1887,8 +1887,8 @@ static int hermon_create_eq ( struct hermon *hermon ) {
|
||||
/* Allocate event queue itself */
|
||||
hermon_eq->eqe_size =
|
||||
( HERMON_NUM_EQES * sizeof ( hermon_eq->eqe[0] ) );
|
||||
hermon_eq->eqe = malloc_dma ( hermon_eq->eqe_size,
|
||||
sizeof ( hermon_eq->eqe[0] ) );
|
||||
hermon_eq->eqe = malloc_phys ( hermon_eq->eqe_size,
|
||||
sizeof ( hermon_eq->eqe[0] ) );
|
||||
if ( ! hermon_eq->eqe ) {
|
||||
rc = -ENOMEM;
|
||||
goto err_eqe;
|
||||
@@ -1946,7 +1946,7 @@ static int hermon_create_eq ( struct hermon *hermon ) {
|
||||
err_sw2hw_eq:
|
||||
hermon_free_mtt ( hermon, &hermon_eq->mtt );
|
||||
err_alloc_mtt:
|
||||
free_dma ( hermon_eq->eqe, hermon_eq->eqe_size );
|
||||
free_phys ( hermon_eq->eqe, hermon_eq->eqe_size );
|
||||
err_eqe:
|
||||
memset ( hermon_eq, 0, sizeof ( *hermon_eq ) );
|
||||
return rc;
|
||||
@@ -1986,7 +1986,7 @@ static void hermon_destroy_eq ( struct hermon *hermon ) {
|
||||
hermon_free_mtt ( hermon, &hermon_eq->mtt );
|
||||
|
||||
/* Free memory */
|
||||
free_dma ( hermon_eq->eqe, hermon_eq->eqe_size );
|
||||
free_phys ( hermon_eq->eqe, hermon_eq->eqe_size );
|
||||
memset ( hermon_eq, 0, sizeof ( *hermon_eq ) );
|
||||
}
|
||||
|
||||
@@ -3736,20 +3736,20 @@ static struct hermon * hermon_alloc ( void ) {
|
||||
goto err_hermon;
|
||||
|
||||
/* Allocate space for mailboxes */
|
||||
hermon->mailbox_in = malloc_dma ( HERMON_MBOX_SIZE,
|
||||
HERMON_MBOX_ALIGN );
|
||||
hermon->mailbox_in = malloc_phys ( HERMON_MBOX_SIZE,
|
||||
HERMON_MBOX_ALIGN );
|
||||
if ( ! hermon->mailbox_in )
|
||||
goto err_mailbox_in;
|
||||
hermon->mailbox_out = malloc_dma ( HERMON_MBOX_SIZE,
|
||||
HERMON_MBOX_ALIGN );
|
||||
hermon->mailbox_out = malloc_phys ( HERMON_MBOX_SIZE,
|
||||
HERMON_MBOX_ALIGN );
|
||||
if ( ! hermon->mailbox_out )
|
||||
goto err_mailbox_out;
|
||||
|
||||
return hermon;
|
||||
|
||||
free_dma ( hermon->mailbox_out, HERMON_MBOX_SIZE );
|
||||
free_phys ( hermon->mailbox_out, HERMON_MBOX_SIZE );
|
||||
err_mailbox_out:
|
||||
free_dma ( hermon->mailbox_in, HERMON_MBOX_SIZE );
|
||||
free_phys ( hermon->mailbox_in, HERMON_MBOX_SIZE );
|
||||
err_mailbox_in:
|
||||
free ( hermon );
|
||||
err_hermon:
|
||||
@@ -3765,8 +3765,8 @@ static void hermon_free ( struct hermon *hermon ) {
|
||||
|
||||
ufree ( hermon->icm );
|
||||
ufree ( hermon->firmware_area );
|
||||
free_dma ( hermon->mailbox_out, HERMON_MBOX_SIZE );
|
||||
free_dma ( hermon->mailbox_in, HERMON_MBOX_SIZE );
|
||||
free_phys ( hermon->mailbox_out, HERMON_MBOX_SIZE );
|
||||
free_phys ( hermon->mailbox_in, HERMON_MBOX_SIZE );
|
||||
free ( hermon );
|
||||
}
|
||||
|
||||
@@ -3782,6 +3782,8 @@ static int hermon_probe ( struct pci_device *pci ) {
|
||||
struct ib_device *ibdev;
|
||||
struct net_device *netdev;
|
||||
struct hermon_port *port;
|
||||
unsigned long config;
|
||||
unsigned long uar;
|
||||
unsigned int i;
|
||||
int rc;
|
||||
|
||||
@@ -3798,10 +3800,12 @@ static int hermon_probe ( struct pci_device *pci ) {
|
||||
adjust_pci_device ( pci );
|
||||
|
||||
/* Map PCI BARs */
|
||||
hermon->config = ioremap ( pci_bar_start ( pci, HERMON_PCI_CONFIG_BAR ),
|
||||
HERMON_PCI_CONFIG_BAR_SIZE );
|
||||
hermon->uar = ioremap ( pci_bar_start ( pci, HERMON_PCI_UAR_BAR ),
|
||||
HERMON_UAR_NON_EQ_PAGE * HERMON_PAGE_SIZE );
|
||||
config = pci_bar_start ( pci, HERMON_PCI_CONFIG_BAR );
|
||||
hermon->config = pci_ioremap ( pci, config,
|
||||
HERMON_PCI_CONFIG_BAR_SIZE );
|
||||
uar = pci_bar_start ( pci, HERMON_PCI_UAR_BAR );
|
||||
hermon->uar = pci_ioremap ( pci, uar,
|
||||
HERMON_UAR_NON_EQ_PAGE * HERMON_PAGE_SIZE );
|
||||
|
||||
/* Reset device */
|
||||
hermon_reset ( hermon );
|
||||
@@ -3937,6 +3941,7 @@ static void hermon_remove ( struct pci_device *pci ) {
|
||||
*/
|
||||
static int hermon_bofm_probe ( struct pci_device *pci ) {
|
||||
struct hermon *hermon;
|
||||
unsigned long config;
|
||||
int rc;
|
||||
|
||||
/* Allocate Hermon device */
|
||||
@@ -3952,8 +3957,9 @@ static int hermon_bofm_probe ( struct pci_device *pci ) {
|
||||
adjust_pci_device ( pci );
|
||||
|
||||
/* Map PCI BAR */
|
||||
hermon->config = ioremap ( pci_bar_start ( pci, HERMON_PCI_CONFIG_BAR ),
|
||||
HERMON_PCI_CONFIG_BAR_SIZE );
|
||||
config = pci_bar_start ( pci, HERMON_PCI_CONFIG_BAR );
|
||||
hermon->config = pci_ioremap ( pci, config,
|
||||
HERMON_PCI_CONFIG_BAR_SIZE );
|
||||
|
||||
/* Initialise BOFM device */
|
||||
bofm_init ( &hermon->bofm, pci, &hermon_bofm_operations );
|
||||
|
||||
@@ -531,8 +531,8 @@ static int linda_init_send ( struct linda *linda ) {
|
||||
linda->send_buf[i] = i;
|
||||
|
||||
/* Allocate space for the SendBufAvail array */
|
||||
linda->sendbufavail = malloc_dma ( sizeof ( *linda->sendbufavail ),
|
||||
LINDA_SENDBUFAVAIL_ALIGN );
|
||||
linda->sendbufavail = malloc_phys ( sizeof ( *linda->sendbufavail ),
|
||||
LINDA_SENDBUFAVAIL_ALIGN );
|
||||
if ( ! linda->sendbufavail ) {
|
||||
rc = -ENOMEM;
|
||||
goto err_alloc_sendbufavail;
|
||||
@@ -555,7 +555,7 @@ static int linda_init_send ( struct linda *linda ) {
|
||||
|
||||
return 0;
|
||||
|
||||
free_dma ( linda->sendbufavail, sizeof ( *linda->sendbufavail ) );
|
||||
free_phys ( linda->sendbufavail, sizeof ( *linda->sendbufavail ) );
|
||||
err_alloc_sendbufavail:
|
||||
return rc;
|
||||
}
|
||||
@@ -576,7 +576,7 @@ static void linda_fini_send ( struct linda *linda ) {
|
||||
/* Ensure hardware has seen this disable */
|
||||
linda_readq ( linda, &sendctrl, QIB_7220_SendCtrl_offset );
|
||||
|
||||
free_dma ( linda->sendbufavail, sizeof ( *linda->sendbufavail ) );
|
||||
free_phys ( linda->sendbufavail, sizeof ( *linda->sendbufavail ) );
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
@@ -613,8 +613,8 @@ static int linda_create_recv_wq ( struct linda *linda,
|
||||
linda_wq->eager_cons = 0;
|
||||
|
||||
/* Allocate receive header buffer */
|
||||
linda_wq->header = malloc_dma ( LINDA_RECV_HEADERS_SIZE,
|
||||
LINDA_RECV_HEADERS_ALIGN );
|
||||
linda_wq->header = malloc_phys ( LINDA_RECV_HEADERS_SIZE,
|
||||
LINDA_RECV_HEADERS_ALIGN );
|
||||
if ( ! linda_wq->header ) {
|
||||
rc = -ENOMEM;
|
||||
goto err_alloc_header;
|
||||
@@ -650,7 +650,7 @@ static int linda_create_recv_wq ( struct linda *linda,
|
||||
virt_to_bus ( &linda_wq->header_prod ) );
|
||||
return 0;
|
||||
|
||||
free_dma ( linda_wq->header, LINDA_RECV_HEADERS_SIZE );
|
||||
free_phys ( linda_wq->header, LINDA_RECV_HEADERS_SIZE );
|
||||
err_alloc_header:
|
||||
return rc;
|
||||
}
|
||||
@@ -679,7 +679,7 @@ static void linda_destroy_recv_wq ( struct linda *linda,
|
||||
mb();
|
||||
|
||||
/* Free headers ring */
|
||||
free_dma ( linda_wq->header, LINDA_RECV_HEADERS_SIZE );
|
||||
free_phys ( linda_wq->header, LINDA_RECV_HEADERS_SIZE );
|
||||
|
||||
/* Free context */
|
||||
linda_free_ctx ( linda, ctx );
|
||||
@@ -2335,7 +2335,7 @@ static int linda_probe ( struct pci_device *pci ) {
|
||||
adjust_pci_device ( pci );
|
||||
|
||||
/* Map PCI BARs */
|
||||
linda->regs = ioremap ( pci->membase, LINDA_BAR0_SIZE );
|
||||
linda->regs = pci_ioremap ( pci, pci->membase, LINDA_BAR0_SIZE );
|
||||
DBGC2 ( linda, "Linda %p has BAR at %08lx\n", linda, pci->membase );
|
||||
|
||||
/* Print some general data */
|
||||
|
||||
@@ -61,7 +61,7 @@ mlx_memory_alloc_dma_priv(
|
||||
)
|
||||
{
|
||||
mlx_status status = MLX_SUCCESS;
|
||||
*ptr = malloc_dma(size, align);
|
||||
*ptr = malloc_phys(size, align);
|
||||
if (*ptr == NULL) {
|
||||
status = MLX_OUT_OF_RESOURCES;
|
||||
} else {
|
||||
@@ -78,7 +78,7 @@ mlx_memory_free_dma_priv(
|
||||
)
|
||||
{
|
||||
mlx_status status = MLX_SUCCESS;
|
||||
free_dma(ptr, size);
|
||||
free_phys(ptr, size);
|
||||
return status;
|
||||
}
|
||||
mlx_status
|
||||
|
||||
@@ -115,7 +115,7 @@ mlx_pci_init_priv(
|
||||
mlx_status status = MLX_SUCCESS;
|
||||
adjust_pci_device ( utils->pci );
|
||||
#ifdef DEVICE_CX3
|
||||
utils->config = ioremap ( pci_bar_start ( utils->pci, PCI_BASE_ADDRESS_0),
|
||||
utils->config = pci_ioremap ( utils->pci, pci_bar_start ( utils->pci, PCI_BASE_ADDRESS_0),
|
||||
0x100000 );
|
||||
#endif
|
||||
return status;
|
||||
|
||||
@@ -669,8 +669,8 @@ static int qib7322_init_send ( struct qib7322 *qib7322 ) {
|
||||
}
|
||||
|
||||
/* Allocate space for the SendBufAvail array */
|
||||
qib7322->sendbufavail = malloc_dma ( sizeof ( *qib7322->sendbufavail ),
|
||||
QIB7322_SENDBUFAVAIL_ALIGN );
|
||||
qib7322->sendbufavail = malloc_phys ( sizeof ( *qib7322->sendbufavail ),
|
||||
QIB7322_SENDBUFAVAIL_ALIGN );
|
||||
if ( ! qib7322->sendbufavail ) {
|
||||
rc = -ENOMEM;
|
||||
goto err_alloc_sendbufavail;
|
||||
@@ -697,7 +697,7 @@ static int qib7322_init_send ( struct qib7322 *qib7322 ) {
|
||||
|
||||
return 0;
|
||||
|
||||
free_dma ( qib7322->sendbufavail, sizeof ( *qib7322->sendbufavail ) );
|
||||
free_phys ( qib7322->sendbufavail, sizeof ( *qib7322->sendbufavail ) );
|
||||
err_alloc_sendbufavail:
|
||||
qib7322_destroy_send_bufs ( qib7322, qib7322->send_bufs_vl15_port1 );
|
||||
err_create_send_bufs_vl15_port1:
|
||||
@@ -724,7 +724,7 @@ static void qib7322_fini_send ( struct qib7322 *qib7322 ) {
|
||||
/* Ensure hardware has seen this disable */
|
||||
qib7322_readq ( qib7322, &sendctrl, QIB_7322_SendCtrl_offset );
|
||||
|
||||
free_dma ( qib7322->sendbufavail, sizeof ( *qib7322->sendbufavail ) );
|
||||
free_phys ( qib7322->sendbufavail, sizeof ( *qib7322->sendbufavail ) );
|
||||
qib7322_destroy_send_bufs ( qib7322, qib7322->send_bufs_vl15_port1 );
|
||||
qib7322_destroy_send_bufs ( qib7322, qib7322->send_bufs_vl15_port0 );
|
||||
qib7322_destroy_send_bufs ( qib7322, qib7322->send_bufs_small );
|
||||
@@ -767,8 +767,8 @@ static int qib7322_create_recv_wq ( struct ib_device *ibdev,
|
||||
qib7322_wq->eager_cons = 0;
|
||||
|
||||
/* Allocate receive header buffer */
|
||||
qib7322_wq->header = malloc_dma ( QIB7322_RECV_HEADERS_SIZE,
|
||||
QIB7322_RECV_HEADERS_ALIGN );
|
||||
qib7322_wq->header = malloc_phys ( QIB7322_RECV_HEADERS_SIZE,
|
||||
QIB7322_RECV_HEADERS_ALIGN );
|
||||
if ( ! qib7322_wq->header ) {
|
||||
rc = -ENOMEM;
|
||||
goto err_alloc_header;
|
||||
@@ -810,7 +810,7 @@ static int qib7322_create_recv_wq ( struct ib_device *ibdev,
|
||||
virt_to_bus ( &qib7322_wq->header_prod ) );
|
||||
return 0;
|
||||
|
||||
free_dma ( qib7322_wq->header, QIB7322_RECV_HEADERS_SIZE );
|
||||
free_phys ( qib7322_wq->header, QIB7322_RECV_HEADERS_SIZE );
|
||||
err_alloc_header:
|
||||
return rc;
|
||||
}
|
||||
@@ -846,7 +846,7 @@ static void qib7322_destroy_recv_wq ( struct ib_device *ibdev,
|
||||
mb();
|
||||
|
||||
/* Free headers ring */
|
||||
free_dma ( qib7322_wq->header, QIB7322_RECV_HEADERS_SIZE );
|
||||
free_phys ( qib7322_wq->header, QIB7322_RECV_HEADERS_SIZE );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2297,7 +2297,7 @@ static int qib7322_probe ( struct pci_device *pci ) {
|
||||
adjust_pci_device ( pci );
|
||||
|
||||
/* Map PCI BARs */
|
||||
qib7322->regs = ioremap ( pci->membase, QIB7322_BAR0_SIZE );
|
||||
qib7322->regs = pci_ioremap ( pci, pci->membase, QIB7322_BAR0_SIZE );
|
||||
DBGC2 ( qib7322, "QIB7322 %p has BAR at %08lx\n",
|
||||
qib7322, pci->membase );
|
||||
|
||||
|
||||
@@ -249,7 +249,7 @@ static int a3c90x_setup_tx_ring(struct INF_3C90X *p)
|
||||
{
|
||||
DBGP("a3c90x_setup_tx_ring\n");
|
||||
p->tx_ring =
|
||||
malloc_dma(TX_RING_SIZE * sizeof(struct TXD), TX_RING_ALIGN);
|
||||
malloc_phys(TX_RING_SIZE * sizeof(struct TXD), TX_RING_ALIGN);
|
||||
|
||||
if (!p->tx_ring) {
|
||||
DBG("Could not allocate TX-ring\n");
|
||||
@@ -304,7 +304,7 @@ static void a3c90x_free_tx_ring(struct INF_3C90X *p)
|
||||
{
|
||||
DBGP("a3c90x_free_tx_ring\n");
|
||||
|
||||
free_dma(p->tx_ring, TX_RING_SIZE * sizeof(struct TXD));
|
||||
free_phys(p->tx_ring, TX_RING_SIZE * sizeof(struct TXD));
|
||||
p->tx_ring = NULL;
|
||||
/* io_buffers are free()ed by netdev_tx_complete[,_err]() */
|
||||
}
|
||||
@@ -461,7 +461,7 @@ static int a3c90x_setup_rx_ring(struct INF_3C90X *p)
|
||||
DBGP("a3c90x_setup_rx_ring\n");
|
||||
|
||||
p->rx_ring =
|
||||
malloc_dma(RX_RING_SIZE * sizeof(struct RXD), RX_RING_ALIGN);
|
||||
malloc_phys(RX_RING_SIZE * sizeof(struct RXD), RX_RING_ALIGN);
|
||||
|
||||
if (!p->rx_ring) {
|
||||
DBG("Could not allocate RX-ring\n");
|
||||
@@ -491,7 +491,7 @@ static void a3c90x_free_rx_ring(struct INF_3C90X *p)
|
||||
{
|
||||
DBGP("a3c90x_free_rx_ring\n");
|
||||
|
||||
free_dma(p->rx_ring, RX_RING_SIZE * sizeof(struct RXD));
|
||||
free_phys(p->rx_ring, RX_RING_SIZE * sizeof(struct RXD));
|
||||
p->rx_ring = NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -664,7 +664,7 @@ static int amd8111e_probe(struct nic *nic, struct pci_device *pdev)
|
||||
memset(lp, 0, sizeof(*lp));
|
||||
lp->pdev = pdev;
|
||||
lp->nic = nic;
|
||||
lp->mmio = ioremap(mmio_start, mmio_len);
|
||||
lp->mmio = pci_ioremap(pdev, mmio_start, mmio_len);
|
||||
lp->opened = 1;
|
||||
adjust_pci_device(pdev);
|
||||
|
||||
|
||||
@@ -280,7 +280,7 @@ static int ath5k_probe(struct pci_device *pdev)
|
||||
*/
|
||||
pci_write_config_byte(pdev, 0x41, 0);
|
||||
|
||||
mem = ioremap(pdev->membase, 0x10000);
|
||||
mem = pci_ioremap(pdev, pdev->membase, 0x10000);
|
||||
if (!mem) {
|
||||
DBG("ath5k: cannot remap PCI memory region\n");
|
||||
ret = -EIO;
|
||||
@@ -877,7 +877,7 @@ ath5k_desc_alloc(struct ath5k_softc *sc)
|
||||
|
||||
/* allocate descriptors */
|
||||
sc->desc_len = sizeof(struct ath5k_desc) * (ATH_TXBUF + ATH_RXBUF + 1);
|
||||
sc->desc = malloc_dma(sc->desc_len, ATH5K_DESC_ALIGN);
|
||||
sc->desc = malloc_phys(sc->desc_len, ATH5K_DESC_ALIGN);
|
||||
if (sc->desc == NULL) {
|
||||
DBG("ath5k: can't allocate descriptors\n");
|
||||
ret = -ENOMEM;
|
||||
@@ -915,7 +915,7 @@ ath5k_desc_alloc(struct ath5k_softc *sc)
|
||||
return 0;
|
||||
|
||||
err_free:
|
||||
free_dma(sc->desc, sc->desc_len);
|
||||
free_phys(sc->desc, sc->desc_len);
|
||||
err:
|
||||
sc->desc = NULL;
|
||||
return ret;
|
||||
@@ -932,7 +932,7 @@ ath5k_desc_free(struct ath5k_softc *sc)
|
||||
ath5k_rxbuf_free(sc, bf);
|
||||
|
||||
/* Free memory associated with all descriptors */
|
||||
free_dma(sc->desc, sc->desc_len);
|
||||
free_phys(sc->desc, sc->desc_len);
|
||||
|
||||
free(sc->bufptr);
|
||||
sc->bufptr = NULL;
|
||||
|
||||
@@ -138,7 +138,7 @@ static int ath_pci_probe(struct pci_device *pdev)
|
||||
if ((val & 0x0000ff00) != 0)
|
||||
pci_write_config_dword(pdev, 0x40, val & 0xffff00ff);
|
||||
|
||||
mem = ioremap(pdev->membase, 0x10000);
|
||||
mem = pci_ioremap(pdev, pdev->membase, 0x10000);
|
||||
if (!mem) {
|
||||
DBG("ath9K: PCI memory map error\n") ;
|
||||
ret = -EIO;
|
||||
|
||||
@@ -223,7 +223,7 @@ int ath_descdma_setup(struct ath_softc *sc, struct ath_descdma *dd,
|
||||
}
|
||||
|
||||
/* allocate descriptors */
|
||||
dd->dd_desc = malloc_dma(dd->dd_desc_len, 16);
|
||||
dd->dd_desc = malloc_phys(dd->dd_desc_len, 16);
|
||||
if (dd->dd_desc == NULL) {
|
||||
error = -ENOMEM;
|
||||
goto fail;
|
||||
@@ -264,7 +264,7 @@ int ath_descdma_setup(struct ath_softc *sc, struct ath_descdma *dd,
|
||||
}
|
||||
return 0;
|
||||
fail2:
|
||||
free_dma(dd->dd_desc, dd->dd_desc_len);
|
||||
free_phys(dd->dd_desc, dd->dd_desc_len);
|
||||
fail:
|
||||
memset(dd, 0, sizeof(*dd));
|
||||
return error;
|
||||
@@ -588,7 +588,7 @@ void ath_descdma_cleanup(struct ath_softc *sc __unused,
|
||||
struct ath_descdma *dd,
|
||||
struct list_head *head)
|
||||
{
|
||||
free_dma(dd->dd_desc, dd->dd_desc_len);
|
||||
free_phys(dd->dd_desc, dd->dd_desc_len);
|
||||
|
||||
INIT_LIST_HEAD(head);
|
||||
free(dd->dd_bufptr);
|
||||
|
||||
@@ -370,7 +370,7 @@ static void atl1e_free_ring_resources(struct atl1e_adapter *adapter)
|
||||
atl1e_clean_rx_ring(adapter);
|
||||
|
||||
if (adapter->ring_vir_addr) {
|
||||
free_dma(adapter->ring_vir_addr, adapter->ring_size);
|
||||
free_phys(adapter->ring_vir_addr, adapter->ring_size);
|
||||
adapter->ring_vir_addr = NULL;
|
||||
adapter->ring_dma = 0;
|
||||
}
|
||||
@@ -405,7 +405,7 @@ static int atl1e_setup_ring_resources(struct atl1e_adapter *adapter)
|
||||
/* real ring DMA buffer */
|
||||
|
||||
size = adapter->ring_size;
|
||||
adapter->ring_vir_addr = malloc_dma(adapter->ring_size, 32);
|
||||
adapter->ring_vir_addr = malloc_phys(adapter->ring_size, 32);
|
||||
|
||||
if (adapter->ring_vir_addr == NULL) {
|
||||
DBG("atl1e: out of memory allocating %d bytes for %s ring\n",
|
||||
|
||||
+45
-22
@@ -213,6 +213,7 @@ static inline int axge_write_dword ( struct axge_device *axge,
|
||||
static int axge_check_link ( struct axge_device *axge ) {
|
||||
struct net_device *netdev = axge->netdev;
|
||||
uint8_t plsr;
|
||||
uint16_t msr;
|
||||
int rc;
|
||||
|
||||
/* Read physical link status register */
|
||||
@@ -222,12 +223,28 @@ static int axge_check_link ( struct axge_device *axge ) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Write medium status register */
|
||||
msr = cpu_to_le16 ( AXGE_MSR_FD | AXGE_MSR_RFC | AXGE_MSR_TFC |
|
||||
AXGE_MSR_RE );
|
||||
if ( plsr & AXGE_PLSR_EPHY_1000 ) {
|
||||
msr |= cpu_to_le16 ( AXGE_MSR_GM );
|
||||
} else if ( plsr & AXGE_PLSR_EPHY_100 ) {
|
||||
msr |= cpu_to_le16 ( AXGE_MSR_PS );
|
||||
}
|
||||
if ( ( rc = axge_write_word ( axge, AXGE_MSR, msr ) ) != 0 ) {
|
||||
DBGC ( axge, "AXGE %p could not write MSR: %s\n",
|
||||
axge, strerror ( rc ) );
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Update link status */
|
||||
if ( plsr & AXGE_PLSR_EPHY_ANY ) {
|
||||
DBGC ( axge, "AXGE %p link up (PLSR %02x)\n", axge, plsr );
|
||||
DBGC ( axge, "AXGE %p link up (PLSR %02x MSR %04x)\n",
|
||||
axge, plsr, msr );
|
||||
netdev_link_up ( netdev );
|
||||
} else {
|
||||
DBGC ( axge, "AXGE %p link down (PLSR %02x)\n", axge, plsr );
|
||||
DBGC ( axge, "AXGE %p link down (PLSR %02x MSR %04x)\n",
|
||||
axge, plsr, msr );
|
||||
netdev_link_down ( netdev );
|
||||
}
|
||||
|
||||
@@ -291,13 +308,8 @@ static void axge_intr_complete ( struct usb_endpoint *ep,
|
||||
|
||||
/* Extract link status */
|
||||
link_ok = ( intr->link & cpu_to_le16 ( AXGE_INTR_LINK_PPLS ) );
|
||||
if ( link_ok && ! netdev_link_ok ( netdev ) ) {
|
||||
DBGC ( axge, "AXGE %p link up\n", axge );
|
||||
netdev_link_up ( netdev );
|
||||
} else if ( netdev_link_ok ( netdev ) && ! link_ok ) {
|
||||
DBGC ( axge, "AXGE %p link down\n", axge );
|
||||
netdev_link_down ( netdev );
|
||||
}
|
||||
if ( ( !! link_ok ) ^ ( !! netdev_link_ok ( netdev ) ) )
|
||||
axge->check_link = 1;
|
||||
|
||||
/* Free I/O buffer */
|
||||
free_iob ( iobuf );
|
||||
@@ -519,6 +531,13 @@ static int axge_open ( struct net_device *netdev ) {
|
||||
uint16_t rcr;
|
||||
int rc;
|
||||
|
||||
/* Reapply device configuration to avoid transaction errors */
|
||||
if ( ( rc = usb_set_configuration ( axge->usb, axge->config ) ) != 0 ) {
|
||||
DBGC ( axge, "AXGE %p could not set configuration: %s\n",
|
||||
axge, strerror ( rc ) );
|
||||
goto err_set_configuration;
|
||||
}
|
||||
|
||||
/* Open USB network device */
|
||||
if ( ( rc = usbnet_open ( &axge->usbnet ) ) != 0 ) {
|
||||
DBGC ( axge, "AXGE %p could not open: %s\n",
|
||||
@@ -544,15 +563,18 @@ static int axge_open ( struct net_device *netdev ) {
|
||||
}
|
||||
|
||||
/* Update link status */
|
||||
axge_check_link ( axge );
|
||||
if ( ( rc = axge_check_link ( axge ) ) != 0 )
|
||||
goto err_check_link;
|
||||
|
||||
return 0;
|
||||
|
||||
err_check_link:
|
||||
axge_write_word ( axge, AXGE_RCR, 0 );
|
||||
err_write_rcr:
|
||||
err_write_mac:
|
||||
usbnet_close ( &axge->usbnet );
|
||||
err_open:
|
||||
err_set_configuration:
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -605,6 +627,15 @@ static void axge_poll ( struct net_device *netdev ) {
|
||||
/* Refill endpoints */
|
||||
if ( ( rc = usbnet_refill ( &axge->usbnet ) ) != 0 )
|
||||
netdev_rx_err ( netdev, NULL, rc );
|
||||
|
||||
/* Update link state, if applicable */
|
||||
if ( axge->check_link ) {
|
||||
if ( ( rc = axge_check_link ( axge ) ) == 0 ) {
|
||||
axge->check_link = 0;
|
||||
} else {
|
||||
netdev_rx_err ( netdev, NULL, rc );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** AXGE network device operations */
|
||||
@@ -635,7 +666,6 @@ static int axge_probe ( struct usb_function *func,
|
||||
struct net_device *netdev;
|
||||
struct axge_device *axge;
|
||||
uint16_t epprcr;
|
||||
uint16_t msr;
|
||||
uint8_t csr;
|
||||
int rc;
|
||||
|
||||
@@ -652,6 +682,7 @@ static int axge_probe ( struct usb_function *func,
|
||||
axge->usb = usb;
|
||||
axge->bus = usb->port->hub->bus;
|
||||
axge->netdev = netdev;
|
||||
axge->config = config->config;
|
||||
usbnet_init ( &axge->usbnet, func, &axge_intr_operations,
|
||||
&axge_in_operations, &axge_out_operations );
|
||||
usb_refill_init ( &axge->usbnet.intr, 0, 0, AXGE_INTR_MAX_FILL );
|
||||
@@ -705,28 +736,20 @@ static int axge_probe ( struct usb_function *func,
|
||||
goto err_write_bicr;
|
||||
}
|
||||
|
||||
/* Set medium status */
|
||||
msr = cpu_to_le16 ( AXGE_MSR_GM | AXGE_MSR_FD | AXGE_MSR_RFC |
|
||||
AXGE_MSR_TFC | AXGE_MSR_RE );
|
||||
if ( ( rc = axge_write_word ( axge, AXGE_MSR, msr ) ) != 0 ) {
|
||||
DBGC ( axge, "AXGE %p could not write MSR: %s\n",
|
||||
axge, strerror ( rc ) );
|
||||
goto err_write_msr;
|
||||
}
|
||||
|
||||
/* Register network device */
|
||||
if ( ( rc = register_netdev ( netdev ) ) != 0 )
|
||||
goto err_register;
|
||||
|
||||
/* Update link status */
|
||||
axge_check_link ( axge );
|
||||
if ( ( rc = axge_check_link ( axge ) ) != 0 )
|
||||
goto err_check_link;
|
||||
|
||||
usb_func_set_drvdata ( func, axge );
|
||||
return 0;
|
||||
|
||||
err_check_link:
|
||||
unregister_netdev ( netdev );
|
||||
err_register:
|
||||
err_write_msr:
|
||||
err_write_bicr:
|
||||
err_write_csr:
|
||||
err_write_epprcr_on:
|
||||
|
||||
@@ -49,6 +49,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
#define AXGE_MSR_RFC 0x0010 /**< RX flow control enable */
|
||||
#define AXGE_MSR_TFC 0x0020 /**< TX flow control enable */
|
||||
#define AXGE_MSR_RE 0x0100 /**< Receive enable */
|
||||
#define AXGE_MSR_PS 0x0200 /**< 100Mbps port speed */
|
||||
|
||||
/** Ethernet PHY Power and Reset Control Register */
|
||||
#define AXGE_EPPRCR 0x26
|
||||
@@ -144,6 +145,10 @@ struct axge_device {
|
||||
struct net_device *netdev;
|
||||
/** USB network device */
|
||||
struct usbnet_device usbnet;
|
||||
/** Device configuration */
|
||||
unsigned int config;
|
||||
/** Link state has changed */
|
||||
int check_link;
|
||||
};
|
||||
|
||||
/** Interrupt maximum fill level
|
||||
|
||||
@@ -436,7 +436,7 @@ static void b44_free_rx_ring(struct b44_private *bp)
|
||||
free_iob(bp->rx_iobuf[i]);
|
||||
bp->rx_iobuf[i] = NULL;
|
||||
}
|
||||
free_dma(bp->rx, B44_RX_RING_LEN_BYTES);
|
||||
free_phys(bp->rx, B44_RX_RING_LEN_BYTES);
|
||||
bp->rx = NULL;
|
||||
}
|
||||
}
|
||||
@@ -446,11 +446,11 @@ static int b44_init_rx_ring(struct b44_private *bp)
|
||||
{
|
||||
b44_free_rx_ring(bp);
|
||||
|
||||
bp->rx = malloc_dma(B44_RX_RING_LEN_BYTES, B44_DMA_ALIGNMENT);
|
||||
bp->rx = malloc_phys(B44_RX_RING_LEN_BYTES, B44_DMA_ALIGNMENT);
|
||||
if (!bp->rx)
|
||||
return -ENOMEM;
|
||||
if (!b44_address_ok(bp->rx)) {
|
||||
free_dma(bp->rx, B44_RX_RING_LEN_BYTES);
|
||||
free_phys(bp->rx, B44_RX_RING_LEN_BYTES);
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
@@ -468,7 +468,7 @@ static int b44_init_rx_ring(struct b44_private *bp)
|
||||
static void b44_free_tx_ring(struct b44_private *bp)
|
||||
{
|
||||
if (bp->tx) {
|
||||
free_dma(bp->tx, B44_TX_RING_LEN_BYTES);
|
||||
free_phys(bp->tx, B44_TX_RING_LEN_BYTES);
|
||||
bp->tx = NULL;
|
||||
}
|
||||
}
|
||||
@@ -478,11 +478,11 @@ static int b44_init_tx_ring(struct b44_private *bp)
|
||||
{
|
||||
b44_free_tx_ring(bp);
|
||||
|
||||
bp->tx = malloc_dma(B44_TX_RING_LEN_BYTES, B44_DMA_ALIGNMENT);
|
||||
bp->tx = malloc_phys(B44_TX_RING_LEN_BYTES, B44_DMA_ALIGNMENT);
|
||||
if (!bp->tx)
|
||||
return -ENOMEM;
|
||||
if (!b44_address_ok(bp->tx)) {
|
||||
free_dma(bp->tx, B44_TX_RING_LEN_BYTES);
|
||||
free_phys(bp->tx, B44_TX_RING_LEN_BYTES);
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
@@ -673,7 +673,7 @@ static int b44_probe(struct pci_device *pci)
|
||||
bp->pci = pci;
|
||||
|
||||
/* Map device registers */
|
||||
bp->regs = ioremap(pci->membase, B44_REGS_SIZE);
|
||||
bp->regs = pci_ioremap(pci, pci->membase, B44_REGS_SIZE);
|
||||
if (!bp->regs) {
|
||||
netdev_put(netdev);
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -2152,7 +2152,7 @@ bnx2_init_board(struct pci_device *pdev, struct nic *nic)
|
||||
bnx2reg_base = pci_bar_start(pdev, PCI_BASE_ADDRESS_0);
|
||||
bnx2reg_len = MB_GET_CID_ADDR(17);
|
||||
|
||||
bp->regview = ioremap(bnx2reg_base, bnx2reg_len);
|
||||
bp->regview = pci_ioremap(pdev, bnx2reg_base, bnx2reg_len);
|
||||
|
||||
if (!bp->regview) {
|
||||
printf("Cannot map register space, aborting.\n");
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,677 @@
|
||||
/*
|
||||
* Copyright © 2018 Broadcom. All Rights Reserved.
|
||||
* The term Broadcom refers to Broadcom Inc. and/or its subsidiaries.
|
||||
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of version 2 of the GNU General Public License as published by the
|
||||
* Free Software Foundation.
|
||||
|
||||
* This program is distributed in the hope that it will be useful.
|
||||
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
|
||||
* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
* NON-INFRINGEMENT, ARE DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS
|
||||
* ARE HELD TO BE LEGALLY INVALID. See the GNU General Public License for more
|
||||
* details, a copy of which can be found in the file COPYING included with this
|
||||
* package.
|
||||
*/
|
||||
|
||||
//#define DEBUG_DRV
|
||||
//#define DEBUG_KEY
|
||||
//#define DEBUG_PCI
|
||||
//#define DEBUG_MEMORY
|
||||
//#define DEBUG_LINK
|
||||
//#define DEBUG_CHIP
|
||||
//#define DEBUG_FAIL
|
||||
//#define DEBUG_HWRM_CMDS
|
||||
//#define DEBUG_HWRM_DUMP
|
||||
//#define DEBUG_CQ
|
||||
//#define DEBUG_CQ_DUMP
|
||||
//#define DEBUG_TX
|
||||
//#define DEBUG_TX_DUMP
|
||||
//#define DEBUG_RX
|
||||
//#define DEBUG_RX_DUMP
|
||||
|
||||
#if \
|
||||
defined(DEBUG_DRV) || \
|
||||
defined(DEBUG_PCI) || \
|
||||
defined(DEBUG_CHIP) || \
|
||||
defined(DEBUG_MEMORY) || \
|
||||
defined(DEBUG_LINK) || \
|
||||
defined(DEBUG_FAIL) || \
|
||||
defined(DEBUG_HWRM_CMDS) || \
|
||||
defined(DEBUG_HWRM_DUMP) || \
|
||||
defined(DEBUG_CQ) || \
|
||||
defined(DEBUG_CQ_DUMP) || \
|
||||
defined(DEBUG_TX) || \
|
||||
defined(DEBUG_TX_DUMP) || \
|
||||
defined(DEBUG_RX) || \
|
||||
defined(DEBUG_RX_DUMP)
|
||||
#define DEBUG_DEFAULT
|
||||
#endif
|
||||
#if defined(DEBUG_DEFAULT)
|
||||
#define dbg_prn printf
|
||||
|
||||
void pause_drv(void)
|
||||
{
|
||||
#if defined(DEBUG_KEY)
|
||||
dbg_prn(" Press a key...");
|
||||
getchar();
|
||||
#endif
|
||||
dbg_prn("\n");
|
||||
}
|
||||
|
||||
#define MAX_CHAR_SIZE(a) (u32)((1 << (a)) - 1)
|
||||
#define DISP_U8 0x00
|
||||
#define DISP_U16 0x01
|
||||
#define DISP_U32 0x02
|
||||
#define DISP_U64 0x03
|
||||
|
||||
void dumpmemory1(u8 *buffer, u32 length, u8 flag)
|
||||
{
|
||||
u32 jj = 0;
|
||||
u8 i, c;
|
||||
|
||||
dbg_prn("\n %p:", buffer);
|
||||
for (jj = 0; jj < 16; jj++) {
|
||||
if (!(jj & MAX_CHAR_SIZE(flag)))
|
||||
dbg_prn(" ");
|
||||
if (jj < length)
|
||||
dbg_prn("%02x", buffer[jj]);
|
||||
else
|
||||
dbg_prn(" ");
|
||||
if ((jj & 0xF) == 0xF) {
|
||||
dbg_prn(" ");
|
||||
for (i = 0; i < 16; i++) {
|
||||
if (i < length) {
|
||||
c = buffer[jj + i - 15];
|
||||
if (c >= 0x20 && c < 0x7F)
|
||||
;
|
||||
else
|
||||
c = '.';
|
||||
dbg_prn("%c", c);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void dump_mem(u8 *buffer, u32 length, u8 flag)
|
||||
{
|
||||
u32 length16, remlen, jj;
|
||||
|
||||
length16 = length & 0xFFFFFFF0;
|
||||
remlen = length & 0xF;
|
||||
for (jj = 0; jj < length16; jj += 16)
|
||||
dumpmemory1((u8 *)&buffer[jj], 16, flag);
|
||||
if (remlen)
|
||||
dumpmemory1((u8 *)&buffer[length16], remlen, flag);
|
||||
if (length16 || remlen)
|
||||
dbg_prn("\n");
|
||||
}
|
||||
#else
|
||||
#define dbg_prn(func)
|
||||
#endif
|
||||
|
||||
#if defined(DEBUG_PCI)
|
||||
void dbg_pci(struct bnxt *bp, const char *func, u16 cmd_reg)
|
||||
{
|
||||
struct pci_device *pdev = bp->pdev;
|
||||
|
||||
dbg_prn("- %s()\n", func);
|
||||
dbg_prn(" Bus:Dev:Func : %04X\n", pdev->busdevfn);
|
||||
dbg_prn(" Vendor id : %04X\n", pdev->vendor);
|
||||
dbg_prn(" Device id : %04X (%cF)\n",
|
||||
pdev->device, (bp->vf) ? 'V' : 'P');
|
||||
dbg_prn(" Irq : %d\n", pdev->irq);
|
||||
dbg_prn(" PCI Command Reg : %04X\n", cmd_reg);
|
||||
dbg_prn(" Sub Vendor id : %04X\n", bp->subsystem_vendor);
|
||||
dbg_prn(" Sub Device id : %04X\n", bp->subsystem_device);
|
||||
dbg_prn(" PF Number : %X\n", bp->pf_num);
|
||||
dbg_prn(" BAR (0) : %p %lx\n",
|
||||
bp->bar0, pci_bar_start(pdev, PCI_BASE_ADDRESS_0));
|
||||
dbg_prn(" BAR (1) : %p %lx\n",
|
||||
bp->bar1, pci_bar_start(pdev, PCI_BASE_ADDRESS_2));
|
||||
dbg_prn(" BAR (2) : %p %lx\n",
|
||||
bp->bar2, pci_bar_start(pdev, PCI_BASE_ADDRESS_4));
|
||||
dbg_prn(" ");
|
||||
pause_drv();
|
||||
}
|
||||
#else
|
||||
#define dbg_pci(bp, func, creg)
|
||||
#endif
|
||||
|
||||
#if defined(DEBUG_MEMORY)
|
||||
void dbg_mem(struct bnxt *bp, const char *func)
|
||||
{
|
||||
dbg_prn("- %s()\n", func);
|
||||
dbg_prn(" bp Addr : %p", bp);
|
||||
dbg_prn(" Len %4d", (u16)sizeof(struct bnxt));
|
||||
dbg_prn(" phy %lx\n", virt_to_bus(bp));
|
||||
dbg_prn(" bp->hwrm_req_addr : %p", bp->hwrm_addr_req);
|
||||
dbg_prn(" Len %4d", (u16)REQ_BUFFER_SIZE);
|
||||
dbg_prn(" phy %lx\n", bp->req_addr_mapping);
|
||||
dbg_prn(" bp->hwrm_resp_addr : %p", bp->hwrm_addr_resp);
|
||||
dbg_prn(" Len %4d", (u16)RESP_BUFFER_SIZE);
|
||||
dbg_prn(" phy %lx\n", bp->resp_addr_mapping);
|
||||
dbg_prn(" bp->dma_addr : %p", bp->hwrm_addr_dma);
|
||||
dbg_prn(" Len %4d", (u16)DMA_BUFFER_SIZE);
|
||||
dbg_prn(" phy %lx\n", bp->dma_addr_mapping);
|
||||
dbg_prn(" bp->tx.bd_virt : %p", bp->tx.bd_virt);
|
||||
dbg_prn(" Len %4d", (u16)TX_RING_BUFFER_SIZE);
|
||||
dbg_prn(" phy %lx\n", virt_to_bus(bp->tx.bd_virt));
|
||||
dbg_prn(" bp->rx.bd_virt : %p", bp->rx.bd_virt);
|
||||
dbg_prn(" Len %4d", (u16)RX_RING_BUFFER_SIZE);
|
||||
dbg_prn(" phy %lx\n", virt_to_bus(bp->rx.bd_virt));
|
||||
dbg_prn(" bp->cq.bd_virt : %p", bp->cq.bd_virt);
|
||||
dbg_prn(" Len %4d", (u16)CQ_RING_BUFFER_SIZE);
|
||||
dbg_prn(" phy %lx\n", virt_to_bus(bp->cq.bd_virt));
|
||||
dbg_prn(" bp->nq.bd_virt : %p", bp->nq.bd_virt);
|
||||
dbg_prn(" Len %4d", (u16)NQ_RING_BUFFER_SIZE);
|
||||
dbg_prn(" phy %lx\n", virt_to_bus(bp->nq.bd_virt));
|
||||
dbg_prn(" ");
|
||||
pause_drv();
|
||||
}
|
||||
#else
|
||||
#define dbg_mem(bp, func) (func = func)
|
||||
#endif
|
||||
|
||||
#if defined(DEBUG_CHIP)
|
||||
void dbg_fw_ver(struct hwrm_ver_get_output *resp, u32 tmo)
|
||||
{
|
||||
if (resp->hwrm_intf_maj_8b < 1) {
|
||||
dbg_prn(" HWRM interface %d.%d.%d is older than 1.0.0.\n",
|
||||
resp->hwrm_intf_maj_8b, resp->hwrm_intf_min_8b,
|
||||
resp->hwrm_intf_upd_8b);
|
||||
dbg_prn(" Update FW with HWRM interface 1.0.0 or newer.\n");
|
||||
}
|
||||
dbg_prn(" FW Version : %d.%d.%d.%d\n",
|
||||
resp->hwrm_fw_maj_8b, resp->hwrm_fw_min_8b,
|
||||
resp->hwrm_fw_bld_8b, resp->hwrm_fw_rsvd_8b);
|
||||
dbg_prn(" cmd timeout : %d\n", tmo);
|
||||
if (resp->hwrm_intf_maj_8b >= 1)
|
||||
dbg_prn(" hwrm_max_req_len : %d\n", resp->max_req_win_len);
|
||||
dbg_prn(" hwrm_max_ext_req : %d\n", resp->max_ext_req_len);
|
||||
dbg_prn(" chip_num : %x\n", resp->chip_num);
|
||||
dbg_prn(" chip_id : %x\n",
|
||||
(u32)(resp->chip_rev << 24) |
|
||||
(u32)(resp->chip_metal << 16) |
|
||||
(u32)(resp->chip_bond_id << 8) |
|
||||
(u32)resp->chip_platform_type);
|
||||
test_if((resp->dev_caps_cfg & SHORT_CMD_SUPPORTED) &&
|
||||
(resp->dev_caps_cfg & SHORT_CMD_REQUIRED))
|
||||
dbg_prn(" SHORT_CMD_SUPPORTED\n");
|
||||
}
|
||||
|
||||
void dbg_func_resource_qcaps(struct bnxt *bp)
|
||||
{
|
||||
// Ring Groups
|
||||
dbg_prn(" min_hw_ring_grps : %d\n", bp->min_hw_ring_grps);
|
||||
dbg_prn(" max_hw_ring_grps : %d\n", bp->max_hw_ring_grps);
|
||||
// TX Rings
|
||||
dbg_prn(" min_tx_rings : %d\n", bp->min_tx_rings);
|
||||
dbg_prn(" max_tx_rings : %d\n", bp->max_tx_rings);
|
||||
// RX Rings
|
||||
dbg_prn(" min_rx_rings : %d\n", bp->min_rx_rings);
|
||||
dbg_prn(" max_rx_rings : %d\n", bp->max_rx_rings);
|
||||
// Completion Rings
|
||||
dbg_prn(" min_cq_rings : %d\n", bp->min_cp_rings);
|
||||
dbg_prn(" max_cq_rings : %d\n", bp->max_cp_rings);
|
||||
// Statistic Contexts
|
||||
dbg_prn(" min_stat_ctxs : %d\n", bp->min_stat_ctxs);
|
||||
dbg_prn(" max_stat_ctxs : %d\n", bp->max_stat_ctxs);
|
||||
}
|
||||
|
||||
void dbg_func_qcaps(struct bnxt *bp)
|
||||
{
|
||||
dbg_prn(" Port Number : %d\n", bp->port_idx);
|
||||
dbg_prn(" fid : 0x%04x\n", bp->fid);
|
||||
dbg_prn(" PF MAC : %02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
bp->mac_addr[0],
|
||||
bp->mac_addr[1],
|
||||
bp->mac_addr[2],
|
||||
bp->mac_addr[3],
|
||||
bp->mac_addr[4],
|
||||
bp->mac_addr[5]);
|
||||
}
|
||||
|
||||
void dbg_func_qcfg(struct bnxt *bp)
|
||||
{
|
||||
dbg_prn(" ordinal_value : %d\n", bp->ordinal_value);
|
||||
dbg_prn(" stat_ctx_id : %x\n", bp->stat_ctx_id);
|
||||
if (bp->vf) {
|
||||
dbg_func_qcaps(bp);
|
||||
dbg_prn(" vlan_id : %d\n", bp->vlan_id);
|
||||
}
|
||||
}
|
||||
|
||||
void prn_set_speed(u32 speed)
|
||||
{
|
||||
u32 speed1 = ((speed & LINK_SPEED_DRV_MASK) >> LINK_SPEED_DRV_SHIFT);
|
||||
|
||||
dbg_prn(" Set Link Speed : ");
|
||||
switch (speed & LINK_SPEED_DRV_MASK) {
|
||||
case LINK_SPEED_DRV_1G:
|
||||
dbg_prn("1 GBPS");
|
||||
break;
|
||||
case LINK_SPEED_DRV_10G:
|
||||
dbg_prn("10 GBPS");
|
||||
break;
|
||||
case LINK_SPEED_DRV_25G:
|
||||
dbg_prn("25 GBPS");
|
||||
break;
|
||||
case LINK_SPEED_DRV_40G:
|
||||
dbg_prn("40 GBPS");
|
||||
break;
|
||||
case LINK_SPEED_DRV_50G:
|
||||
dbg_prn("50 GBPS");
|
||||
break;
|
||||
case LINK_SPEED_DRV_100G:
|
||||
dbg_prn("100 GBPS");
|
||||
break;
|
||||
case LINK_SPEED_DRV_200G:
|
||||
dbg_prn("200 GBPS");
|
||||
break;
|
||||
case LINK_SPEED_DRV_AUTONEG:
|
||||
dbg_prn("AUTONEG");
|
||||
break;
|
||||
default:
|
||||
dbg_prn("%x", speed1);
|
||||
break;
|
||||
}
|
||||
dbg_prn("\n");
|
||||
}
|
||||
|
||||
void dbg_chip_info(struct bnxt *bp)
|
||||
{
|
||||
if (bp->thor)
|
||||
dbg_prn(" NQ Ring Id : %d\n", bp->nq_ring_id);
|
||||
else
|
||||
dbg_prn(" Grp ID : %d\n", bp->ring_grp_id);
|
||||
dbg_prn(" Stat Ctx ID : %d\n", bp->stat_ctx_id);
|
||||
dbg_prn(" CQ Ring Id : %d\n", bp->cq_ring_id);
|
||||
dbg_prn(" Tx Ring Id : %d\n", bp->tx_ring_id);
|
||||
dbg_prn(" Rx ring Id : %d\n", bp->rx_ring_id);
|
||||
dbg_prn(" ");
|
||||
pause_drv();
|
||||
}
|
||||
|
||||
void dbg_num_rings(struct bnxt *bp)
|
||||
{
|
||||
dbg_prn(" num_cmpl_rings : %d\n", bp->num_cmpl_rings);
|
||||
dbg_prn(" num_tx_rings : %d\n", bp->num_tx_rings);
|
||||
dbg_prn(" num_rx_rings : %d\n", bp->num_rx_rings);
|
||||
dbg_prn(" num_ring_grps : %d\n", bp->num_hw_ring_grps);
|
||||
dbg_prn(" num_stat_ctxs : %d\n", bp->num_stat_ctxs);
|
||||
}
|
||||
|
||||
void dbg_flags(const char *func, u32 flags)
|
||||
{
|
||||
dbg_prn("- %s()\n", func);
|
||||
dbg_prn(" bp->flags : 0x%04x\n", flags);
|
||||
}
|
||||
|
||||
void dbg_bnxt_pause(void)
|
||||
{
|
||||
dbg_prn(" ");
|
||||
pause_drv();
|
||||
}
|
||||
#else
|
||||
#define dbg_fw_ver(resp, tmo)
|
||||
#define dbg_func_resource_qcaps(bp)
|
||||
#define dbg_func_qcaps(bp)
|
||||
#define dbg_func_qcfg(bp)
|
||||
#define prn_set_speed(speed)
|
||||
#define dbg_chip_info(bp)
|
||||
#define dbg_num_rings(bp)
|
||||
#define dbg_flags(func, flags)
|
||||
#define dbg_bnxt_pause()
|
||||
#endif
|
||||
|
||||
#if defined(DEBUG_HWRM_CMDS) || defined(DEBUG_FAIL)
|
||||
void dump_hwrm_req(struct bnxt *bp, const char *func, u32 len, u32 tmo)
|
||||
{
|
||||
dbg_prn("- %s(0x%04x) cmd_len %d cmd_tmo %d",
|
||||
func, (u16)((struct input *)bp->hwrm_addr_req)->req_type,
|
||||
len, tmo);
|
||||
#if defined(DEBUG_HWRM_DUMP)
|
||||
dump_mem((u8 *)bp->hwrm_addr_req, len, DISP_U8);
|
||||
#else
|
||||
dbg_prn("\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
void debug_resp(struct bnxt *bp, const char *func, u32 resp_len, u16 err)
|
||||
{
|
||||
dbg_prn("- %s(0x%04x) - ",
|
||||
func, (u16)((struct input *)bp->hwrm_addr_req)->req_type);
|
||||
if (err == STATUS_SUCCESS)
|
||||
dbg_prn("Done");
|
||||
else if (err != STATUS_TIMEOUT)
|
||||
dbg_prn("Fail err 0x%04x", err);
|
||||
else
|
||||
dbg_prn("timedout");
|
||||
#if defined(DEBUG_HWRM_DUMP)
|
||||
if (err != STATUS_TIMEOUT) {
|
||||
dump_mem((u8 *)bp->hwrm_addr_resp, resp_len, DISP_U8);
|
||||
sleep(1);
|
||||
} else
|
||||
dbg_prn("\n");
|
||||
#else
|
||||
resp_len = resp_len;
|
||||
dbg_prn("\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
void dbg_hw_cmd(struct bnxt *bp,
|
||||
const char *func, u16 cmd_len,
|
||||
u16 resp_len, u32 cmd_tmo, u16 err)
|
||||
{
|
||||
#if !defined(DEBUG_HWRM_CMDS)
|
||||
if (err)
|
||||
#endif
|
||||
{
|
||||
dump_hwrm_req(bp, func, cmd_len, cmd_tmo);
|
||||
debug_resp(bp, func, resp_len, err);
|
||||
}
|
||||
}
|
||||
#else
|
||||
#define dbg_hw_cmd(bp, func, cmd_len, resp_len, cmd_tmo, err) (func = func)
|
||||
#endif
|
||||
|
||||
#if defined(DEBUG_HWRM_CMDS)
|
||||
void dbg_short_cmd(u8 *req, const char *func, u32 len)
|
||||
{
|
||||
struct hwrm_short_input *sreq;
|
||||
|
||||
sreq = (struct hwrm_short_input *)req;
|
||||
dbg_prn("- %s(0x%04x) short_cmd_len %d",
|
||||
func,
|
||||
sreq->req_type,
|
||||
(int)len);
|
||||
#if defined(DEBUG_HWRM_DUMP)
|
||||
dump_mem((u8 *)sreq, len, DISP_U8);
|
||||
#else
|
||||
dbg_prn("\n");
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
#define dbg_short_cmd(sreq, func, len)
|
||||
#endif
|
||||
|
||||
#if defined(DEBUG_RX)
|
||||
void dump_rx_bd(struct rx_pkt_cmpl *rx_cmp,
|
||||
struct rx_pkt_cmpl_hi *rx_cmp_hi,
|
||||
u32 desc_idx)
|
||||
{
|
||||
dbg_prn(" RX desc_idx %d PktLen %d\n", desc_idx, rx_cmp->len);
|
||||
dbg_prn("- rx_cmp %lx", virt_to_bus(rx_cmp));
|
||||
#if defined(DEBUG_RX_DUMP)
|
||||
dump_mem((u8 *)rx_cmp, (u32)sizeof(struct rx_pkt_cmpl), DISP_U8);
|
||||
#else
|
||||
dbg_prn("\n");
|
||||
#endif
|
||||
dbg_prn("- rx_cmp_hi %lx", virt_to_bus(rx_cmp_hi));
|
||||
#if defined(DEBUG_RX_DUMP)
|
||||
dump_mem((u8 *)rx_cmp_hi, (u32)sizeof(struct rx_pkt_cmpl_hi), DISP_U8);
|
||||
#else
|
||||
dbg_prn("\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
void dbg_rx_vlan(struct bnxt *bp, u32 meta, u16 f2, u16 rx_vid)
|
||||
{
|
||||
dbg_prn(" Rx VLAN metadata %x flags2 %x\n", meta, f2);
|
||||
dbg_prn(" Rx VLAN MBA %d TX %d RX %d\n",
|
||||
bp->vlan_id, bp->vlan_tx, rx_vid);
|
||||
}
|
||||
|
||||
void dbg_alloc_rx_iob(struct io_buffer *iob, u16 id, u16 cid)
|
||||
{
|
||||
dbg_prn(" Rx alloc_iob (%d) %p bd_virt (%d)\n",
|
||||
id, iob->data, cid);
|
||||
}
|
||||
|
||||
void dbg_rx_cid(u16 idx, u16 cid)
|
||||
{
|
||||
dbg_prn("- RX old cid %d new cid %d\n", idx, cid);
|
||||
}
|
||||
|
||||
void dbg_alloc_rx_iob_fail(u16 iob_idx, u16 cons_id)
|
||||
{
|
||||
dbg_prn(" Rx alloc_iob (%d) ", iob_idx);
|
||||
dbg_prn("failed for cons_id %d\n", cons_id);
|
||||
}
|
||||
|
||||
void dbg_rxp(u8 *iob, u16 rx_len, u8 drop)
|
||||
{
|
||||
dbg_prn("- RX iob %lx Len %d ", virt_to_bus(iob), rx_len);
|
||||
if (drop == 1)
|
||||
dbg_prn("drop ErrPkt ");
|
||||
else if (drop == 2)
|
||||
dbg_prn("drop LoopBack ");
|
||||
else if (drop == 3)
|
||||
dbg_prn("drop VLAN");
|
||||
#if defined(DEBUG_RX_DUMP)
|
||||
dump_mem(iob, (u32)rx_len, DISP_U8);
|
||||
#else
|
||||
dbg_prn("\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
void dbg_rx_stat(struct bnxt *bp)
|
||||
{
|
||||
dbg_prn("- RX Stat Total %d Good %d Drop err %d LB %d VLAN %d\n",
|
||||
bp->rx.cnt, bp->rx.good,
|
||||
bp->rx.drop_err, bp->rx.drop_lb, bp->rx.drop_vlan);
|
||||
}
|
||||
#else
|
||||
#define dump_rx_bd(rx_cmp, rx_cmp_hi, desc_idx)
|
||||
#define dbg_rx_vlan(bp, metadata, flags2, rx_vid)
|
||||
#define dbg_alloc_rx_iob(iob, id, cid)
|
||||
#define dbg_rx_cid(idx, cid)
|
||||
#define dbg_alloc_rx_iob_fail(iob_idx, cons_id)
|
||||
#define dbg_rxp(iob, rx_len, drop)
|
||||
#define dbg_rx_stat(bp)
|
||||
#endif
|
||||
|
||||
#if defined(DEBUG_CQ)
|
||||
static void dump_cq(struct cmpl_base *cmp, u16 cid)
|
||||
{
|
||||
dbg_prn("- CQ Type ");
|
||||
switch (cmp->type & CMPL_BASE_TYPE_MASK) {
|
||||
case CMPL_BASE_TYPE_HWRM_ASYNC_EVENT:
|
||||
dbg_prn("(ae)");
|
||||
break;
|
||||
case CMPL_BASE_TYPE_STAT_EJECT:
|
||||
dbg_prn("(se)");
|
||||
break;
|
||||
case CMPL_BASE_TYPE_TX_L2:
|
||||
dbg_prn("(tx)");
|
||||
break;
|
||||
case CMPL_BASE_TYPE_RX_L2:
|
||||
dbg_prn("(rx)");
|
||||
break;
|
||||
default:
|
||||
dbg_prn("%04x", (u16)(cmp->type & CMPL_BASE_TYPE_MASK));
|
||||
break;
|
||||
}
|
||||
dbg_prn(" cid %d", cid);
|
||||
#if defined(DEBUG_CQ_DUMP)
|
||||
dump_mem((u8 *)cmp, (u32)sizeof(struct cmpl_base), DISP_U8);
|
||||
#else
|
||||
dbg_prn("\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
static void dump_nq(struct nq_base *nqp, u16 cid)
|
||||
{
|
||||
dbg_prn("- NQ Type %lx cid %d", (nqp->type & NQ_CN_TYPE_MASK), cid);
|
||||
#if defined(DEBUG_CQ_DUMP)
|
||||
dump_mem((u8 *)nqp, (u32)sizeof(struct nq_base), DISP_U8);
|
||||
#else
|
||||
dbg_prn("\n");
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
#define dump_cq(cq, id)
|
||||
#define dump_nq(nq, id)
|
||||
#endif
|
||||
|
||||
#if defined(DEBUG_TX)
|
||||
void dbg_tx_avail(struct bnxt *bp, u32 avail, u16 use)
|
||||
{
|
||||
dbg_prn("- Tx BD %d Avail %d Use %d pid %d cid %d\n",
|
||||
bp->tx.ring_cnt,
|
||||
avail, use,
|
||||
bp->tx.prod_id,
|
||||
bp->tx.cons_id);
|
||||
}
|
||||
|
||||
void dbg_tx_vlan(struct bnxt *bp, char *src, u16 plen, u16 len)
|
||||
{
|
||||
dbg_prn("- Tx VLAN PKT %d MBA %d", bp->vlan_tx, bp->vlan_id);
|
||||
dbg_prn(" PKT %d",
|
||||
BYTE_SWAP_S(*(u16 *)(&src[MAC_HDR_SIZE + 2])));
|
||||
dbg_prn(" Pro %x",
|
||||
BYTE_SWAP_S(*(u16 *)(&src[MAC_HDR_SIZE])));
|
||||
dbg_prn(" old len %d new len %d\n", plen, len);
|
||||
}
|
||||
|
||||
void dbg_tx_pad(u16 plen, u16 len)
|
||||
{
|
||||
if (len != plen)
|
||||
dbg_prn("- Tx padded(0) old len %d new len %d\n", plen, len);
|
||||
}
|
||||
|
||||
void dump_tx_stat(struct bnxt *bp)
|
||||
{
|
||||
dbg_prn(" TX stats cnt %d req_cnt %d", bp->tx.cnt, bp->tx.cnt_req);
|
||||
dbg_prn(" prod_id %d cons_id %d\n", bp->tx.prod_id, bp->tx.cons_id);
|
||||
}
|
||||
|
||||
void dump_tx_pkt(u8 *pkt, u16 len, u16 idx)
|
||||
{
|
||||
dbg_prn(" TX(%d) Addr %lx Size %d", idx, virt_to_bus(pkt), len);
|
||||
#if defined(DEBUG_TX_DUMP)
|
||||
dump_mem(pkt, (u32)len, DISP_U8);
|
||||
#else
|
||||
dbg_prn("\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
void dump_tx_bd(struct tx_bd_short *tx_bd, u16 len, int idx)
|
||||
{
|
||||
dbg_prn(" Tx(%d) BD Addr %lx Size %d", idx, virt_to_bus(tx_bd), len);
|
||||
#if defined(DEBUG_TX_DUMP)
|
||||
dump_mem((u8 *)tx_bd, (u32)len, DISP_U8);
|
||||
#else
|
||||
dbg_prn("\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
void dbg_tx_done(u8 *pkt, u16 len, u16 idx)
|
||||
{
|
||||
dbg_prn(" Tx(%d) Done pkt %lx Size %d\n", idx, virt_to_bus(pkt), len);
|
||||
}
|
||||
#else
|
||||
#define dbg_tx_avail(bp, a, u)
|
||||
#define dbg_tx_vlan(bp, src, plen, len)
|
||||
#define dbg_tx_pad(plen, len)
|
||||
#define dump_tx_stat(bp)
|
||||
#define dump_tx_pkt(pkt, len, idx)
|
||||
#define dump_tx_bd(prod_bd, len, idx)
|
||||
#define dbg_tx_done(pkt, len, idx)
|
||||
#endif
|
||||
|
||||
#if defined(DEBUG_LINK)
|
||||
static void dump_evt(u8 *cmp, u32 type, u16 cid, u8 ring)
|
||||
{
|
||||
u32 size;
|
||||
u8 c;
|
||||
|
||||
if (ring) {
|
||||
c = 'N';
|
||||
size = sizeof(struct nq_base);
|
||||
} else {
|
||||
c = 'C';
|
||||
size = sizeof(struct cmpl_base);
|
||||
}
|
||||
switch (type) {
|
||||
case CMPL_BASE_TYPE_HWRM_ASYNC_EVENT:
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
dbg_prn("- %cQ Type (ae) cid %d", c, cid);
|
||||
dump_mem(cmp, size, DISP_U8);
|
||||
}
|
||||
|
||||
void dbg_link_info(struct bnxt *bp)
|
||||
{
|
||||
dbg_prn(" Current Speed : ");
|
||||
switch (bp->current_link_speed) {
|
||||
case PORT_PHY_QCFG_RESP_LINK_SPEED_200GB:
|
||||
dbg_prn("200 %s", str_gbps);
|
||||
break;
|
||||
case PORT_PHY_QCFG_RESP_LINK_SPEED_100GB:
|
||||
dbg_prn("100 %s", str_gbps);
|
||||
break;
|
||||
case PORT_PHY_QCFG_RESP_LINK_SPEED_50GB:
|
||||
dbg_prn("50 %s", str_gbps);
|
||||
break;
|
||||
case PORT_PHY_QCFG_RESP_LINK_SPEED_40GB:
|
||||
dbg_prn("40 %s", str_gbps);
|
||||
break;
|
||||
case PORT_PHY_QCFG_RESP_LINK_SPEED_25GB:
|
||||
dbg_prn("25 %s", str_gbps);
|
||||
break;
|
||||
case PORT_PHY_QCFG_RESP_LINK_SPEED_20GB:
|
||||
dbg_prn("20 %s", str_gbps);
|
||||
break;
|
||||
case PORT_PHY_QCFG_RESP_LINK_SPEED_10GB:
|
||||
dbg_prn("10 %s", str_gbps);
|
||||
break;
|
||||
case PORT_PHY_QCFG_RESP_LINK_SPEED_2_5GB:
|
||||
dbg_prn("2.5 %s", str_gbps);
|
||||
break;
|
||||
case PORT_PHY_QCFG_RESP_LINK_SPEED_2GB:
|
||||
dbg_prn("2 %s", str_gbps);
|
||||
break;
|
||||
case PORT_PHY_QCFG_RESP_LINK_SPEED_1GB:
|
||||
dbg_prn("1 %s", str_gbps);
|
||||
break;
|
||||
case PORT_PHY_QCFG_RESP_LINK_SPEED_100MB:
|
||||
dbg_prn("100 %s", str_mbps);
|
||||
break;
|
||||
case PORT_PHY_QCFG_RESP_LINK_SPEED_10MB:
|
||||
dbg_prn("10 %s", str_mbps);
|
||||
break;
|
||||
default:
|
||||
dbg_prn("%x", bp->current_link_speed);
|
||||
}
|
||||
dbg_prn("\n");
|
||||
dbg_prn(" media_detect : %x\n", bp->media_detect);
|
||||
}
|
||||
|
||||
void dbg_link_status(struct bnxt *bp)
|
||||
{
|
||||
dbg_prn(" Port(%d) : Link", bp->port_idx);
|
||||
if (bp->link_status == STATUS_LINK_ACTIVE)
|
||||
dbg_prn("Up");
|
||||
else
|
||||
dbg_prn("Down");
|
||||
dbg_prn("\n");
|
||||
}
|
||||
|
||||
void dbg_link_state(struct bnxt *bp, u32 tmo)
|
||||
{
|
||||
dbg_link_status(bp);
|
||||
dbg_link_info(bp);
|
||||
dbg_prn(" Link wait time : %d ms", tmo);
|
||||
pause_drv();
|
||||
}
|
||||
#else
|
||||
#define dump_evt(cq, ty, id, ring)
|
||||
#define dbg_link_status(bp)
|
||||
#define dbg_link_state(bp, tmo)
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -93,7 +93,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
||||
|
||||
/*
|
||||
* Debugging levels:
|
||||
* - DBG() is for any errors, i.e. failed alloc_iob(), malloc_dma(),
|
||||
* - DBG() is for any errors, i.e. failed alloc_iob(), malloc_phys(),
|
||||
* TX overflow, corrupted packets, ...
|
||||
* - DBG2() is for successful events, like packet received,
|
||||
* packet transmitted, and other general notifications.
|
||||
@@ -335,7 +335,7 @@ static int ifec_net_open ( struct net_device *netdev )
|
||||
ifec_mdio_setup ( netdev, options );
|
||||
|
||||
/* Prepare MAC address w/ Individual Address Setup (ias) command.*/
|
||||
ias = malloc_dma ( sizeof ( *ias ), CB_ALIGN );
|
||||
ias = malloc_phys ( sizeof ( *ias ), CB_ALIGN );
|
||||
if ( !ias ) {
|
||||
rc = -ENOMEM;
|
||||
goto error;
|
||||
@@ -345,7 +345,7 @@ static int ifec_net_open ( struct net_device *netdev )
|
||||
memcpy ( ias->ia, netdev->ll_addr, ETH_ALEN );
|
||||
|
||||
/* Prepare operating parameters w/ a configure command. */
|
||||
cfg = malloc_dma ( sizeof ( *cfg ), CB_ALIGN );
|
||||
cfg = malloc_phys ( sizeof ( *cfg ), CB_ALIGN );
|
||||
if ( !cfg ) {
|
||||
rc = -ENOMEM;
|
||||
goto error;
|
||||
@@ -367,8 +367,8 @@ static int ifec_net_open ( struct net_device *netdev )
|
||||
DBG ( "Failed to initiate!\n" );
|
||||
goto error;
|
||||
}
|
||||
free_dma ( ias, sizeof ( *ias ) );
|
||||
free_dma ( cfg, sizeof ( *cfg ) );
|
||||
free_phys ( ias, sizeof ( *ias ) );
|
||||
free_phys ( cfg, sizeof ( *cfg ) );
|
||||
DBG2 ( "cfg " );
|
||||
|
||||
/* Enable rx by sending ring address to card */
|
||||
@@ -381,8 +381,8 @@ static int ifec_net_open ( struct net_device *netdev )
|
||||
return 0;
|
||||
|
||||
error:
|
||||
free_dma ( cfg, sizeof ( *cfg ) );
|
||||
free_dma ( ias, sizeof ( *ias ) );
|
||||
free_phys ( cfg, sizeof ( *cfg ) );
|
||||
free_phys ( ias, sizeof ( *ias ) );
|
||||
ifec_free ( netdev );
|
||||
ifec_reset ( netdev );
|
||||
return rc;
|
||||
@@ -703,7 +703,7 @@ static void ifec_free ( struct net_device *netdev )
|
||||
}
|
||||
|
||||
/* free TX ring buffer */
|
||||
free_dma ( priv->tcbs, TX_RING_BYTES );
|
||||
free_phys ( priv->tcbs, TX_RING_BYTES );
|
||||
|
||||
priv->tcbs = NULL;
|
||||
}
|
||||
@@ -1025,7 +1025,7 @@ static int ifec_tx_setup ( struct net_device *netdev )
|
||||
DBGP ( "ifec_tx_setup\n" );
|
||||
|
||||
/* allocate tx ring */
|
||||
priv->tcbs = malloc_dma ( TX_RING_BYTES, CB_ALIGN );
|
||||
priv->tcbs = malloc_phys ( TX_RING_BYTES, CB_ALIGN );
|
||||
if ( !priv->tcbs ) {
|
||||
DBG ( "TX-ring allocation failed\n" );
|
||||
return -ENOMEM;
|
||||
|
||||
+30
-12
@@ -788,6 +788,20 @@ static int nii_initialise_flags ( struct nii_nic *nii, unsigned int flags ) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise UNDI with cable detection
|
||||
*
|
||||
* @v nii NII NIC
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
static int nii_initialise_cable ( struct nii_nic *nii ) {
|
||||
unsigned int flags;
|
||||
|
||||
/* Initialise UNDI */
|
||||
flags = PXE_OPFLAGS_INITIALIZE_DETECT_CABLE;
|
||||
return nii_initialise_flags ( nii, flags );
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise UNDI
|
||||
*
|
||||
@@ -961,9 +975,8 @@ static int nii_transmit ( struct net_device *netdev,
|
||||
|
||||
/* Construct parameter block */
|
||||
memset ( &cpb, 0, sizeof ( cpb ) );
|
||||
cpb.FrameAddr = virt_to_bus ( iobuf->data );
|
||||
cpb.FrameAddr = ( ( intptr_t ) iobuf->data );
|
||||
cpb.DataLen = iob_len ( iobuf );
|
||||
cpb.MediaheaderLen = netdev->ll_protocol->ll_header_len;
|
||||
|
||||
/* Transmit packet */
|
||||
op = NII_OP ( PXE_OPCODE_TRANSMIT,
|
||||
@@ -1030,7 +1043,7 @@ static void nii_poll_rx ( struct net_device *netdev ) {
|
||||
|
||||
/* Construct parameter block */
|
||||
memset ( &cpb, 0, sizeof ( cpb ) );
|
||||
cpb.BufferAddr = virt_to_bus ( nii->rxbuf->data );
|
||||
cpb.BufferAddr = ( ( intptr_t ) nii->rxbuf->data );
|
||||
cpb.BufferLen = iob_tailroom ( nii->rxbuf );
|
||||
|
||||
/* Issue command */
|
||||
@@ -1122,7 +1135,6 @@ static void nii_poll ( struct net_device *netdev ) {
|
||||
*/
|
||||
static int nii_open ( struct net_device *netdev ) {
|
||||
struct nii_nic *nii = netdev->priv;
|
||||
unsigned int flags;
|
||||
int rc;
|
||||
|
||||
/* Initialise NIC
|
||||
@@ -1140,15 +1152,21 @@ static int nii_open ( struct net_device *netdev ) {
|
||||
* presence during initialisation on links that are physically
|
||||
* slow to reach link-up.
|
||||
*
|
||||
* Attempt to work around both of these problems by requesting
|
||||
* cable detection at this point if any only if the driver is
|
||||
* not capable of reporting link status changes at runtime via
|
||||
* PXE_OPCODE_GET_STATUS.
|
||||
* Attempt to work around both of these problems by first
|
||||
* attempting to initialise with cable presence detection,
|
||||
* then falling back to initialising without cable presence
|
||||
* detection.
|
||||
*/
|
||||
flags = ( nii->media ? PXE_OPFLAGS_INITIALIZE_DO_NOT_DETECT_CABLE
|
||||
: PXE_OPFLAGS_INITIALIZE_DETECT_CABLE );
|
||||
if ( ( rc = nii_initialise_flags ( nii, flags ) ) != 0 )
|
||||
goto err_initialise;
|
||||
if ( ( rc = nii_initialise_cable ( nii ) ) != 0 ) {
|
||||
DBGC ( nii, "NII %s could not initialise with cable "
|
||||
"detection: %s\n", nii->dev.name, strerror ( rc ) );
|
||||
if ( ( rc = nii_initialise ( nii ) ) != 0 ) {
|
||||
DBGC ( nii, "NII %s could not initialise without "
|
||||
"cable detection: %s\n",
|
||||
nii->dev.name, strerror ( rc ) );
|
||||
goto err_initialise;
|
||||
}
|
||||
}
|
||||
|
||||
/* Attempt to set station address */
|
||||
if ( ( rc = nii_set_station_address ( nii, netdev ) ) != 0 ) {
|
||||
|
||||
@@ -27,6 +27,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
||||
#include <ipxe/netdevice.h>
|
||||
#include <ipxe/ethernet.h>
|
||||
#include <ipxe/vsprintf.h>
|
||||
#include <ipxe/timer.h>
|
||||
#include <ipxe/efi/efi.h>
|
||||
#include <ipxe/efi/Protocol/SimpleNetwork.h>
|
||||
#include <ipxe/efi/efi_driver.h>
|
||||
@@ -64,6 +65,12 @@ struct snp_nic {
|
||||
/** Maximum number of received packets per poll */
|
||||
#define SNP_RX_QUOTA 4
|
||||
|
||||
/** Maximum initialisation retry count */
|
||||
#define SNP_INITIALIZE_RETRY_MAX 10
|
||||
|
||||
/** Delay between each initialisation retry */
|
||||
#define SNP_INITIALIZE_RETRY_DELAY_MS 10
|
||||
|
||||
/**
|
||||
* Format SNP MAC address (for debugging)
|
||||
*
|
||||
@@ -335,7 +342,9 @@ static int snpnet_rx_filters ( struct net_device *netdev ) {
|
||||
static int snpnet_open ( struct net_device *netdev ) {
|
||||
struct snp_nic *snp = netdev->priv;
|
||||
EFI_MAC_ADDRESS *mac = ( ( void * ) netdev->ll_addr );
|
||||
EFI_SIMPLE_NETWORK_MODE *mode = snp->snp->Mode;
|
||||
EFI_STATUS efirc;
|
||||
unsigned int retry;
|
||||
int rc;
|
||||
|
||||
/* Try setting MAC address (before initialising) */
|
||||
@@ -346,13 +355,46 @@ static int snpnet_open ( struct net_device *netdev ) {
|
||||
/* Ignore error */
|
||||
}
|
||||
|
||||
/* Initialise NIC */
|
||||
if ( ( efirc = snp->snp->Initialize ( snp->snp, 0, 0 ) ) != 0 ) {
|
||||
rc = -EEFI ( efirc );
|
||||
snpnet_dump_mode ( netdev );
|
||||
DBGC ( snp, "SNP %s could not initialise: %s\n",
|
||||
netdev->name, strerror ( rc ) );
|
||||
return rc;
|
||||
/* Initialise NIC, retrying multiple times if link stays down */
|
||||
for ( retry = 0 ; ; ) {
|
||||
|
||||
/* Initialise NIC */
|
||||
if ( ( efirc = snp->snp->Initialize ( snp->snp,
|
||||
0, 0 ) ) != 0 ) {
|
||||
rc = -EEFI ( efirc );
|
||||
snpnet_dump_mode ( netdev );
|
||||
DBGC ( snp, "SNP %s could not initialise: %s\n",
|
||||
netdev->name, strerror ( rc ) );
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Stop if we have link up (or no link detection capability) */
|
||||
if ( ( ! mode->MediaPresentSupported ) || mode->MediaPresent )
|
||||
break;
|
||||
|
||||
/* Stop if we have exceeded our retry count. This is
|
||||
* not a failure; it is plausible that we genuinely do
|
||||
* not have link up.
|
||||
*/
|
||||
if ( ++retry >= SNP_INITIALIZE_RETRY_MAX )
|
||||
break;
|
||||
DBGC ( snp, "SNP %s retrying initialisation (retry %d)\n",
|
||||
netdev->name, retry );
|
||||
|
||||
/* Delay to allow time for link to establish */
|
||||
mdelay ( SNP_INITIALIZE_RETRY_DELAY_MS );
|
||||
|
||||
/* Shut down and retry; this is sometimes necessary in
|
||||
* order to persuade the underlying SNP driver to
|
||||
* actually update the link state.
|
||||
*/
|
||||
if ( ( efirc = snp->snp->Shutdown ( snp->snp ) ) != 0 ) {
|
||||
rc = -EEFI ( efirc );
|
||||
snpnet_dump_mode ( netdev );
|
||||
DBGC ( snp, "SNP %s could not shut down: %s\n",
|
||||
netdev->name, strerror ( rc ) );
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
|
||||
/* Try setting MAC address (after initialising) */
|
||||
|
||||
+13
-13
@@ -164,7 +164,7 @@ static int ena_create_admin ( struct ena_nic *ena ) {
|
||||
int rc;
|
||||
|
||||
/* Allocate admin completion queue */
|
||||
ena->acq.rsp = malloc_dma ( acq_len, acq_len );
|
||||
ena->acq.rsp = malloc_phys ( acq_len, acq_len );
|
||||
if ( ! ena->acq.rsp ) {
|
||||
rc = -ENOMEM;
|
||||
goto err_alloc_acq;
|
||||
@@ -172,7 +172,7 @@ static int ena_create_admin ( struct ena_nic *ena ) {
|
||||
memset ( ena->acq.rsp, 0, acq_len );
|
||||
|
||||
/* Allocate admin queue */
|
||||
ena->aq.req = malloc_dma ( aq_len, aq_len );
|
||||
ena->aq.req = malloc_phys ( aq_len, aq_len );
|
||||
if ( ! ena->aq.req ) {
|
||||
rc = -ENOMEM;
|
||||
goto err_alloc_aq;
|
||||
@@ -196,9 +196,9 @@ static int ena_create_admin ( struct ena_nic *ena ) {
|
||||
|
||||
ena_clear_caps ( ena, ENA_AQ_CAPS );
|
||||
ena_clear_caps ( ena, ENA_ACQ_CAPS );
|
||||
free_dma ( ena->aq.req, aq_len );
|
||||
free_phys ( ena->aq.req, aq_len );
|
||||
err_alloc_aq:
|
||||
free_dma ( ena->acq.rsp, acq_len );
|
||||
free_phys ( ena->acq.rsp, acq_len );
|
||||
err_alloc_acq:
|
||||
return rc;
|
||||
}
|
||||
@@ -218,8 +218,8 @@ static void ena_destroy_admin ( struct ena_nic *ena ) {
|
||||
wmb();
|
||||
|
||||
/* Free queues */
|
||||
free_dma ( ena->aq.req, aq_len );
|
||||
free_dma ( ena->acq.rsp, acq_len );
|
||||
free_phys ( ena->aq.req, aq_len );
|
||||
free_phys ( ena->acq.rsp, acq_len );
|
||||
DBGC ( ena, "ENA %p AQ and ACQ destroyed\n", ena );
|
||||
}
|
||||
|
||||
@@ -338,7 +338,7 @@ static int ena_create_sq ( struct ena_nic *ena, struct ena_sq *sq,
|
||||
int rc;
|
||||
|
||||
/* Allocate submission queue entries */
|
||||
sq->sqe.raw = malloc_dma ( sq->len, ENA_ALIGN );
|
||||
sq->sqe.raw = malloc_phys ( sq->len, ENA_ALIGN );
|
||||
if ( ! sq->sqe.raw ) {
|
||||
rc = -ENOMEM;
|
||||
goto err_alloc;
|
||||
@@ -375,7 +375,7 @@ static int ena_create_sq ( struct ena_nic *ena, struct ena_sq *sq,
|
||||
return 0;
|
||||
|
||||
err_admin:
|
||||
free_dma ( sq->sqe.raw, sq->len );
|
||||
free_phys ( sq->sqe.raw, sq->len );
|
||||
err_alloc:
|
||||
return rc;
|
||||
}
|
||||
@@ -403,7 +403,7 @@ static int ena_destroy_sq ( struct ena_nic *ena, struct ena_sq *sq ) {
|
||||
return rc;
|
||||
|
||||
/* Free submission queue entries */
|
||||
free_dma ( sq->sqe.raw, sq->len );
|
||||
free_phys ( sq->sqe.raw, sq->len );
|
||||
|
||||
DBGC ( ena, "ENA %p %s SQ%d destroyed\n",
|
||||
ena, ena_direction ( sq->direction ), sq->id );
|
||||
@@ -423,7 +423,7 @@ static int ena_create_cq ( struct ena_nic *ena, struct ena_cq *cq ) {
|
||||
int rc;
|
||||
|
||||
/* Allocate completion queue entries */
|
||||
cq->cqe.raw = malloc_dma ( cq->len, ENA_ALIGN );
|
||||
cq->cqe.raw = malloc_phys ( cq->len, ENA_ALIGN );
|
||||
if ( ! cq->cqe.raw ) {
|
||||
rc = -ENOMEM;
|
||||
goto err_alloc;
|
||||
@@ -461,7 +461,7 @@ static int ena_create_cq ( struct ena_nic *ena, struct ena_cq *cq ) {
|
||||
return 0;
|
||||
|
||||
err_admin:
|
||||
free_dma ( cq->cqe.raw, cq->len );
|
||||
free_phys ( cq->cqe.raw, cq->len );
|
||||
err_alloc:
|
||||
return rc;
|
||||
}
|
||||
@@ -488,7 +488,7 @@ static int ena_destroy_cq ( struct ena_nic *ena, struct ena_cq *cq ) {
|
||||
return rc;
|
||||
|
||||
/* Free completion queue entries */
|
||||
free_dma ( cq->cqe.raw, cq->len );
|
||||
free_phys ( cq->cqe.raw, cq->len );
|
||||
|
||||
DBGC ( ena, "ENA %p CQ%d destroyed\n", ena, cq->id );
|
||||
return 0;
|
||||
@@ -933,7 +933,7 @@ static int ena_probe ( struct pci_device *pci ) {
|
||||
adjust_pci_device ( pci );
|
||||
|
||||
/* Map registers */
|
||||
ena->regs = ioremap ( pci->membase, ENA_BAR_SIZE );
|
||||
ena->regs = pci_ioremap ( pci, pci->membase, ENA_BAR_SIZE );
|
||||
if ( ! ena->regs ) {
|
||||
rc = -ENODEV;
|
||||
goto err_ioremap;
|
||||
|
||||
@@ -3025,7 +3025,7 @@ falcon_free_special_buffer ( void *p )
|
||||
{
|
||||
/* We don't bother cleaning up the buffer table entries -
|
||||
* we're hardly limited */
|
||||
free_dma ( p, EFAB_BUF_ALIGN );
|
||||
free_phys ( p, EFAB_BUF_ALIGN );
|
||||
}
|
||||
|
||||
static void*
|
||||
@@ -3038,7 +3038,7 @@ falcon_alloc_special_buffer ( struct efab_nic *efab, int bytes,
|
||||
unsigned long dma_addr;
|
||||
|
||||
/* Allocate the buffer, aligned on a buffer address boundary */
|
||||
buffer = malloc_dma ( bytes, EFAB_BUF_ALIGN );
|
||||
buffer = malloc_phys ( bytes, EFAB_BUF_ALIGN );
|
||||
if ( ! buffer )
|
||||
return NULL;
|
||||
|
||||
@@ -4150,7 +4150,7 @@ efab_probe ( struct pci_device *pci )
|
||||
/* Get iobase/membase */
|
||||
mmio_start = pci_bar_start ( pci, PCI_BASE_ADDRESS_2 );
|
||||
mmio_len = pci_bar_size ( pci, PCI_BASE_ADDRESS_2 );
|
||||
efab->membase = ioremap ( mmio_start, mmio_len );
|
||||
efab->membase = pci_ioremap ( pci, mmio_start, mmio_len );
|
||||
EFAB_TRACE ( "BAR of %lx bytes at phys %lx mapped at %p\n",
|
||||
mmio_len, mmio_start, efab->membase );
|
||||
|
||||
|
||||
@@ -800,7 +800,7 @@ static int exanic_probe ( struct pci_device *pci ) {
|
||||
|
||||
/* Map registers */
|
||||
regs_bar_start = pci_bar_start ( pci, EXANIC_REGS_BAR );
|
||||
exanic->regs = ioremap ( regs_bar_start, EXANIC_REGS_LEN );
|
||||
exanic->regs = pci_ioremap ( pci, regs_bar_start, EXANIC_REGS_LEN );
|
||||
if ( ! exanic->regs ) {
|
||||
rc = -ENODEV;
|
||||
goto err_ioremap_regs;
|
||||
@@ -824,14 +824,14 @@ static int exanic_probe ( struct pci_device *pci ) {
|
||||
/* Map transmit region */
|
||||
tx_bar_start = pci_bar_start ( pci, EXANIC_TX_BAR );
|
||||
tx_bar_len = pci_bar_size ( pci, EXANIC_TX_BAR );
|
||||
exanic->tx = ioremap ( tx_bar_start, tx_bar_len );
|
||||
exanic->tx = pci_ioremap ( pci, tx_bar_start, tx_bar_len );
|
||||
if ( ! exanic->tx ) {
|
||||
rc = -ENODEV;
|
||||
goto err_ioremap_tx;
|
||||
}
|
||||
|
||||
/* Allocate transmit feedback region (shared between all ports) */
|
||||
exanic->txf = malloc_dma ( EXANIC_TXF_LEN, EXANIC_ALIGN );
|
||||
exanic->txf = malloc_phys ( EXANIC_TXF_LEN, EXANIC_ALIGN );
|
||||
if ( ! exanic->txf ) {
|
||||
rc = -ENOMEM;
|
||||
goto err_alloc_txf;
|
||||
@@ -853,7 +853,7 @@ static int exanic_probe ( struct pci_device *pci ) {
|
||||
for ( i-- ; i >= 0 ; i-- )
|
||||
exanic_remove_port ( exanic, i );
|
||||
exanic_reset ( exanic );
|
||||
free_dma ( exanic->txf, EXANIC_TXF_LEN );
|
||||
free_phys ( exanic->txf, EXANIC_TXF_LEN );
|
||||
err_alloc_txf:
|
||||
iounmap ( exanic->tx );
|
||||
err_ioremap_tx:
|
||||
@@ -882,7 +882,7 @@ static void exanic_remove ( struct pci_device *pci ) {
|
||||
exanic_reset ( exanic );
|
||||
|
||||
/* Free transmit feedback region */
|
||||
free_dma ( exanic->txf, EXANIC_TXF_LEN );
|
||||
free_phys ( exanic->txf, EXANIC_TXF_LEN );
|
||||
|
||||
/* Unmap transmit region */
|
||||
iounmap ( exanic->tx );
|
||||
|
||||
@@ -267,7 +267,7 @@ nv_init_rings ( struct forcedeth_private *priv )
|
||||
|
||||
/* Allocate ring for both TX and RX */
|
||||
priv->rx_ring =
|
||||
malloc_dma ( sizeof(struct ring_desc) * RXTX_RING_SIZE, 32 );
|
||||
malloc_phys ( sizeof(struct ring_desc) * RXTX_RING_SIZE, 32 );
|
||||
if ( ! priv->rx_ring )
|
||||
goto err_malloc;
|
||||
priv->tx_ring = &priv->rx_ring[RX_RING_SIZE];
|
||||
@@ -308,7 +308,7 @@ nv_free_rxtx_resources ( struct forcedeth_private *priv )
|
||||
|
||||
DBGP ( "nv_free_rxtx_resources\n" );
|
||||
|
||||
free_dma ( priv->rx_ring, sizeof(struct ring_desc) * RXTX_RING_SIZE );
|
||||
free_phys ( priv->rx_ring, sizeof(struct ring_desc) * RXTX_RING_SIZE );
|
||||
|
||||
for ( i = 0; i < RX_RING_SIZE; i++ ) {
|
||||
free_iob ( priv->rx_iobuf[i] );
|
||||
@@ -1762,7 +1762,7 @@ forcedeth_map_regs ( struct forcedeth_private *priv )
|
||||
}
|
||||
|
||||
rc = -ENOMEM;
|
||||
ioaddr = ioremap ( addr, register_size );
|
||||
ioaddr = pci_ioremap ( priv->pci_dev, addr, register_size );
|
||||
if ( ! ioaddr ) {
|
||||
DBG ( "Cannot remap MMIO\n" );
|
||||
goto err_ioremap;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user