FreeBSD/sys/dev/nxge/xgehal/xgehal-device.c
/*
 * __hal_spdm_entry_add - Add a new entry to the SPDM table.
 *
 * Add a new entry to the SPDM table
 *
 * This function add a new entry to the SPDM table.
 *
 * Note:
 *   This function should be called with spdm_lock.
 *
 * See also: xge_hal_spdm_entry_add , xge_hal_spdm_entry_remove.
 */
Add a new entry to the SPDM table.
Add a new entry to the SPDM table

This function add a new entry to the SPDM table.

This function should be called with spdm_lock.


Add a new entry to the SPDM table . Add a new entry to the SPDM table This function add a new entry to the SPDM table . This function should be called with spdm_lock .
static xge_hal_status_e
__hal_spdm_entry_add(xge_hal_device_t *hldev, xge_hal_ipaddr_t *src_ip,
	    xge_hal_ipaddr_t *dst_ip, u16 l4_sp, u16 l4_dp, u8 is_tcp,
	    u8 is_ipv4, u8 tgt_queue, u32 jhash_value, u16 spdm_entry)
{
	xge_hal_pci_bar0_t *bar0 = (xge_hal_pci_bar0_t *)(void *)hldev->bar0;
	u64 val64;
	u64 spdm_line_arr[8];
	u8 line_no;
	val64 = XGE_HAL_RX_PIC_INT_REG_SPDM_READY;
	xge_os_pio_mem_write64(hldev->pdev, hldev->regh0, val64,
	               &bar0->rxpic_int_reg);
	xge_debug_device(XGE_TRACE,
	        "L4 SP %x:DP %x: hash %x tgt_queue %d ",
	        l4_sp, l4_dp, jhash_value, tgt_queue);
	xge_os_memzero(&spdm_line_arr, sizeof(spdm_line_arr));
	spdm_line_arr[0] = vBIT(l4_sp,0,16) |
	           vBIT(l4_dp,16,32) |
	           vBIT(tgt_queue,53,3) |
	           vBIT(is_tcp,59,1) |
	           vBIT(is_ipv4,63,1);
	if (is_ipv4) {
	    spdm_line_arr[1] = vBIT(src_ip->ipv4.addr,0,32) |
	               vBIT(dst_ip->ipv4.addr,32,32);
	} else {
	    xge_os_memcpy(&spdm_line_arr[1], &src_ip->ipv6.addr[0], 8);
	    xge_os_memcpy(&spdm_line_arr[2], &src_ip->ipv6.addr[1], 8);
	    xge_os_memcpy(&spdm_line_arr[3], &dst_ip->ipv6.addr[0], 8);
	    xge_os_memcpy(&spdm_line_arr[4], &dst_ip->ipv6.addr[1], 8);
	}
	spdm_line_arr[7] = vBIT(jhash_value,0,32) |
	            BIT(63);  
	for(line_no = 0; line_no < 8; line_no++) {
	    xge_os_pio_mem_write64(hldev->pdev, hldev->regh0,
	            spdm_line_arr[line_no],
	            (void *)((char *)hldev->spdm_mem_base +
	                    (spdm_entry * 64) +
	                    (line_no * 8)));
	}
	if (__hal_device_register_poll(hldev, &bar0->rxpic_int_reg, 1,
	        XGE_HAL_RX_PIC_INT_REG_SPDM_READY,
	        XGE_HAL_DEVICE_CMDMEM_WAIT_MAX_MILLIS) != XGE_HAL_OK) {
	    return XGE_HAL_INF_MEM_STROBE_CMD_EXECUTING;
	}
	hldev->spdm_table[spdm_entry]->in_use = 1;
	xge_os_memcpy(&hldev->spdm_table[spdm_entry]->src_ip, src_ip,
	        sizeof(xge_hal_ipaddr_t));
	xge_os_memcpy(&hldev->spdm_table[spdm_entry]->dst_ip, dst_ip,
	        sizeof(xge_hal_ipaddr_t));
	hldev->spdm_table[spdm_entry]->l4_sp = l4_sp;
	hldev->spdm_table[spdm_entry]->l4_dp = l4_dp;
	hldev->spdm_table[spdm_entry]->is_tcp = is_tcp;
	hldev->spdm_table[spdm_entry]->is_ipv4 = is_ipv4;
	hldev->spdm_table[spdm_entry]->tgt_queue = tgt_queue;
	hldev->spdm_table[spdm_entry]->jhash_value = jhash_value;
	hldev->spdm_table[spdm_entry]->spdm_entry = spdm_entry;
	return XGE_HAL_OK;
}
static xge_hal_status_e __hal_spdm_entry_add ( xge_hal_device_t * hldev , xge_hal_ipaddr_t * src_ip , xge_hal_ipaddr_t * dst_ip , u16 l4_sp , u16 l4_dp , u8 is_tcp , u8 is_ipv4 , u8 tgt_queue , u32 jhash_value , u16 spdm_entry ) { xge_hal_pci_bar0_t * bar0 = ( xge_hal_pci_bar0_t * ) ( void * ) hldev -> bar0 ; u64 val64 ; u64 spdm_line_arr [ 8 ] ; u8 line_no ; val64 = XGE_HAL_RX_PIC_INT_REG_SPDM_READY ; xge_os_pio_mem_write64 ( hldev -> pdev , hldev -> regh0 , val64 , & bar0 -> rxpic_int_reg ) ; xge_debug_device ( XGE_TRACE , " " , l4_sp , l4_dp , jhash_value , tgt_queue ) ; xge_os_memzero ( & spdm_line_arr , sizeof ( spdm_line_arr ) ) ; spdm_line_arr [ 0 ] = vBIT ( l4_sp , 0 , 16 ) | vBIT ( l4_dp , 16 , 32 ) | vBIT ( tgt_queue , 53 , 3 ) | vBIT ( is_tcp , 59 , 1 ) | vBIT ( is_ipv4 , 63 , 1 ) ; if ( is_ipv4 ) { spdm_line_arr [ 1 ] = vBIT ( src_ip -> ipv4 . addr , 0 , 32 ) | vBIT ( dst_ip -> ipv4 . addr , 32 , 32 ) ; } else { xge_os_memcpy ( & spdm_line_arr [ 1 ] , & src_ip -> ipv6 . addr [ 0 ] , 8 ) ; xge_os_memcpy ( & spdm_line_arr [ 2 ] , & src_ip -> ipv6 . addr [ 1 ] , 8 ) ; xge_os_memcpy ( & spdm_line_arr [ 3 ] , & dst_ip -> ipv6 . addr [ 0 ] , 8 ) ; xge_os_memcpy ( & spdm_line_arr [ 4 ] , & dst_ip -> ipv6 . addr [ 1 ] , 8 ) ; } spdm_line_arr [ 7 ] = vBIT ( jhash_value , 0 , 32 ) | BIT ( 63 ) ; for ( line_no = 0 ; line_no < 8 ; line_no ++ ) { xge_os_pio_mem_write64 ( hldev -> pdev , hldev -> regh0 , spdm_line_arr [ line_no ] , ( void * ) ( ( char * ) hldev -> spdm_mem_base + ( spdm_entry * 64 ) + ( line_no * 8 ) ) ) ; } if ( __hal_device_register_poll ( hldev , & bar0 -> rxpic_int_reg , 1 , XGE_HAL_RX_PIC_INT_REG_SPDM_READY , XGE_HAL_DEVICE_CMDMEM_WAIT_MAX_MILLIS ) != XGE_HAL_OK ) { return XGE_HAL_INF_MEM_STROBE_CMD_EXECUTING ; } hldev -> spdm_table [ spdm_entry ] -> in_use = 1 ; xge_os_memcpy ( & hldev -> spdm_table [ spdm_entry ] -> src_ip , src_ip , sizeof ( xge_hal_ipaddr_t ) ) ; xge_os_memcpy ( & hldev -> spdm_table [ spdm_entry ] -> dst_ip , dst_ip , sizeof ( xge_hal_ipaddr_t ) ) ; hldev -> spdm_table [ spdm_entry ] -> l4_sp = l4_sp ; hldev -> spdm_table [ spdm_entry ] -> l4_dp = l4_dp ; hldev -> spdm_table [ spdm_entry ] -> is_tcp = is_tcp ; hldev -> spdm_table [ spdm_entry ] -> is_ipv4 = is_ipv4 ; hldev -> spdm_table [ spdm_entry ] -> tgt_queue = tgt_queue ; hldev -> spdm_table [ spdm_entry ] -> jhash_value = jhash_value ; hldev -> spdm_table [ spdm_entry ] -> spdm_entry = spdm_entry ; return XGE_HAL_OK ; }
__hal_spdm_entry_add - Add a new entry to the SPDM table.
__hal_spdm_entry_add - Add a new entry to the SPDM table .
/*
	 * Clear the SPDM READY bit
	 */ /*
	 * Construct the SPDM entry.
	 */ /* entry enable bit */ /*
	 * Add the entry to the SPDM table
	 */ /*
	 * Wait for the operation to be completed.
	 */ /*
	 * Add this information to a local SPDM table. The purpose of
	 * maintaining a local SPDM table is to avoid a search in the
	 * adapter SPDM table for spdm entry lookup which is very costly
	 * in terms of time.
	 */