1 /******************************************************************************
2 * This software may be used and distributed according to the terms of
3 * the GNU General Public License (GPL), incorporated herein by reference.
4 * Drivers based on or derived from this code fall under the GPL and must
5 * retain the authorship, copyright and license notice. This file is not
6 * a complete program and may only be used when the entire operating
7 * system is licensed under the GPL.
8 * See the file COPYING in this distribution for more information.
10 * vxge-config.c: Driver for Neterion Inc's X3100 Series 10GbE PCIe I/O
11 * Virtualized Server Adapter.
12 * Copyright(c) 2002-2009 Neterion Inc.
13 ******************************************************************************/
14 #include <linux/vmalloc.h>
15 #include <linux/etherdevice.h>
16 #include <linux/pci.h>
17 #include <linux/pci_hotplug.h>
18 #include <linux/slab.h>
20 #include "vxge-traffic.h"
21 #include "vxge-config.h"
24 * __vxge_hw_channel_allocate - Allocate memory for channel
25 * This function allocates required memory for the channel and various arrays
28 struct __vxge_hw_channel
*
29 __vxge_hw_channel_allocate(struct __vxge_hw_vpath_handle
*vph
,
30 enum __vxge_hw_channel_type type
,
31 u32 length
, u32 per_dtr_space
, void *userdata
)
33 struct __vxge_hw_channel
*channel
;
34 struct __vxge_hw_device
*hldev
;
38 hldev
= vph
->vpath
->hldev
;
39 vp_id
= vph
->vpath
->vp_id
;
42 case VXGE_HW_CHANNEL_TYPE_FIFO
:
43 size
= sizeof(struct __vxge_hw_fifo
);
45 case VXGE_HW_CHANNEL_TYPE_RING
:
46 size
= sizeof(struct __vxge_hw_ring
);
52 channel
= kzalloc(size
, GFP_KERNEL
);
55 INIT_LIST_HEAD(&channel
->item
);
57 channel
->common_reg
= hldev
->common_reg
;
58 channel
->first_vp_id
= hldev
->first_vp_id
;
60 channel
->devh
= hldev
;
62 channel
->userdata
= userdata
;
63 channel
->per_dtr_space
= per_dtr_space
;
64 channel
->length
= length
;
65 channel
->vp_id
= vp_id
;
67 channel
->work_arr
= kzalloc(sizeof(void *)*length
, GFP_KERNEL
);
68 if (channel
->work_arr
== NULL
)
71 channel
->free_arr
= kzalloc(sizeof(void *)*length
, GFP_KERNEL
);
72 if (channel
->free_arr
== NULL
)
74 channel
->free_ptr
= length
;
76 channel
->reserve_arr
= kzalloc(sizeof(void *)*length
, GFP_KERNEL
);
77 if (channel
->reserve_arr
== NULL
)
79 channel
->reserve_ptr
= length
;
80 channel
->reserve_top
= 0;
82 channel
->orig_arr
= kzalloc(sizeof(void *)*length
, GFP_KERNEL
);
83 if (channel
->orig_arr
== NULL
)
88 __vxge_hw_channel_free(channel
);
95 * __vxge_hw_channel_free - Free memory allocated for channel
96 * This function deallocates memory from the channel and various arrays
99 void __vxge_hw_channel_free(struct __vxge_hw_channel
*channel
)
101 kfree(channel
->work_arr
);
102 kfree(channel
->free_arr
);
103 kfree(channel
->reserve_arr
);
104 kfree(channel
->orig_arr
);
109 * __vxge_hw_channel_initialize - Initialize a channel
110 * This function initializes a channel by properly setting the
114 __vxge_hw_channel_initialize(struct __vxge_hw_channel
*channel
)
117 struct __vxge_hw_virtualpath
*vpath
;
119 vpath
= channel
->vph
->vpath
;
121 if ((channel
->reserve_arr
!= NULL
) && (channel
->orig_arr
!= NULL
)) {
122 for (i
= 0; i
< channel
->length
; i
++)
123 channel
->orig_arr
[i
] = channel
->reserve_arr
[i
];
126 switch (channel
->type
) {
127 case VXGE_HW_CHANNEL_TYPE_FIFO
:
128 vpath
->fifoh
= (struct __vxge_hw_fifo
*)channel
;
129 channel
->stats
= &((struct __vxge_hw_fifo
*)
130 channel
)->stats
->common_stats
;
132 case VXGE_HW_CHANNEL_TYPE_RING
:
133 vpath
->ringh
= (struct __vxge_hw_ring
*)channel
;
134 channel
->stats
= &((struct __vxge_hw_ring
*)
135 channel
)->stats
->common_stats
;
145 * __vxge_hw_channel_reset - Resets a channel
146 * This function resets a channel by properly setting the various references
149 __vxge_hw_channel_reset(struct __vxge_hw_channel
*channel
)
153 for (i
= 0; i
< channel
->length
; i
++) {
154 if (channel
->reserve_arr
!= NULL
)
155 channel
->reserve_arr
[i
] = channel
->orig_arr
[i
];
156 if (channel
->free_arr
!= NULL
)
157 channel
->free_arr
[i
] = NULL
;
158 if (channel
->work_arr
!= NULL
)
159 channel
->work_arr
[i
] = NULL
;
161 channel
->free_ptr
= channel
->length
;
162 channel
->reserve_ptr
= channel
->length
;
163 channel
->reserve_top
= 0;
164 channel
->post_index
= 0;
165 channel
->compl_index
= 0;
171 * __vxge_hw_device_pci_e_init
172 * Initialize certain PCI/PCI-X configuration registers
173 * with recommended values. Save config space for future hw resets.
176 __vxge_hw_device_pci_e_init(struct __vxge_hw_device
*hldev
)
180 /* Set the PErr Repconse bit and SERR in PCI command register. */
181 pci_read_config_word(hldev
->pdev
, PCI_COMMAND
, &cmd
);
183 pci_write_config_word(hldev
->pdev
, PCI_COMMAND
, cmd
);
185 pci_save_state(hldev
->pdev
);
189 * __vxge_hw_device_register_poll
190 * Will poll certain register for specified amount of time.
191 * Will poll until masked bit is not cleared.
194 __vxge_hw_device_register_poll(void __iomem
*reg
, u64 mask
, u32 max_millis
)
198 enum vxge_hw_status ret
= VXGE_HW_FAIL
;
215 } while (++i
<= max_millis
);
220 /* __vxge_hw_device_vpath_reset_in_prog_check - Check if vpath reset
222 * This routine checks the vpath reset in progress register is turned zero
225 __vxge_hw_device_vpath_reset_in_prog_check(u64 __iomem
*vpath_rst_in_prog
)
227 enum vxge_hw_status status
;
228 status
= __vxge_hw_device_register_poll(vpath_rst_in_prog
,
229 VXGE_HW_VPATH_RST_IN_PROG_VPATH_RST_IN_PROG(0x1ffff),
230 VXGE_HW_DEF_DEVICE_POLL_MILLIS
);
235 * __vxge_hw_device_toc_get
236 * This routine sets the swapper and reads the toc pointer and returns the
237 * memory mapped address of the toc
239 struct vxge_hw_toc_reg __iomem
*
240 __vxge_hw_device_toc_get(void __iomem
*bar0
)
243 struct vxge_hw_toc_reg __iomem
*toc
= NULL
;
244 enum vxge_hw_status status
;
246 struct vxge_hw_legacy_reg __iomem
*legacy_reg
=
247 (struct vxge_hw_legacy_reg __iomem
*)bar0
;
249 status
= __vxge_hw_legacy_swapper_set(legacy_reg
);
250 if (status
!= VXGE_HW_OK
)
253 val64
= readq(&legacy_reg
->toc_first_pointer
);
254 toc
= (struct vxge_hw_toc_reg __iomem
*)(bar0
+val64
);
260 * __vxge_hw_device_reg_addr_get
261 * This routine sets the swapper and reads the toc pointer and initializes the
262 * register location pointers in the device object. It waits until the ric is
263 * completed initializing registers.
266 __vxge_hw_device_reg_addr_get(struct __vxge_hw_device
*hldev
)
270 enum vxge_hw_status status
= VXGE_HW_OK
;
272 hldev
->legacy_reg
= (struct vxge_hw_legacy_reg __iomem
*)hldev
->bar0
;
274 hldev
->toc_reg
= __vxge_hw_device_toc_get(hldev
->bar0
);
275 if (hldev
->toc_reg
== NULL
) {
276 status
= VXGE_HW_FAIL
;
280 val64
= readq(&hldev
->toc_reg
->toc_common_pointer
);
282 (struct vxge_hw_common_reg __iomem
*)(hldev
->bar0
+ val64
);
284 val64
= readq(&hldev
->toc_reg
->toc_mrpcim_pointer
);
286 (struct vxge_hw_mrpcim_reg __iomem
*)(hldev
->bar0
+ val64
);
288 for (i
= 0; i
< VXGE_HW_TITAN_SRPCIM_REG_SPACES
; i
++) {
289 val64
= readq(&hldev
->toc_reg
->toc_srpcim_pointer
[i
]);
290 hldev
->srpcim_reg
[i
] =
291 (struct vxge_hw_srpcim_reg __iomem
*)
292 (hldev
->bar0
+ val64
);
295 for (i
= 0; i
< VXGE_HW_TITAN_VPMGMT_REG_SPACES
; i
++) {
296 val64
= readq(&hldev
->toc_reg
->toc_vpmgmt_pointer
[i
]);
297 hldev
->vpmgmt_reg
[i
] =
298 (struct vxge_hw_vpmgmt_reg __iomem
*)(hldev
->bar0
+ val64
);
301 for (i
= 0; i
< VXGE_HW_TITAN_VPATH_REG_SPACES
; i
++) {
302 val64
= readq(&hldev
->toc_reg
->toc_vpath_pointer
[i
]);
303 hldev
->vpath_reg
[i
] =
304 (struct vxge_hw_vpath_reg __iomem
*)
305 (hldev
->bar0
+ val64
);
308 val64
= readq(&hldev
->toc_reg
->toc_kdfc
);
310 switch (VXGE_HW_TOC_GET_KDFC_INITIAL_BIR(val64
)) {
312 hldev
->kdfc
= (u8 __iomem
*)(hldev
->bar0
+
313 VXGE_HW_TOC_GET_KDFC_INITIAL_OFFSET(val64
));
319 status
= __vxge_hw_device_vpath_reset_in_prog_check(
320 (u64 __iomem
*)&hldev
->common_reg
->vpath_rst_in_prog
);
326 * __vxge_hw_device_id_get
327 * This routine returns sets the device id and revision numbers into the device
330 void __vxge_hw_device_id_get(struct __vxge_hw_device
*hldev
)
334 val64
= readq(&hldev
->common_reg
->titan_asic_id
);
336 (u16
)VXGE_HW_TITAN_ASIC_ID_GET_INITIAL_DEVICE_ID(val64
);
338 hldev
->major_revision
=
339 (u8
)VXGE_HW_TITAN_ASIC_ID_GET_INITIAL_MAJOR_REVISION(val64
);
341 hldev
->minor_revision
=
342 (u8
)VXGE_HW_TITAN_ASIC_ID_GET_INITIAL_MINOR_REVISION(val64
);
346 * __vxge_hw_device_access_rights_get: Get Access Rights of the driver
347 * This routine returns the Access Rights of the driver
350 __vxge_hw_device_access_rights_get(u32 host_type
, u32 func_id
)
352 u32 access_rights
= VXGE_HW_DEVICE_ACCESS_RIGHT_VPATH
;
355 case VXGE_HW_NO_MR_NO_SR_NORMAL_FUNCTION
:
357 access_rights
|= VXGE_HW_DEVICE_ACCESS_RIGHT_MRPCIM
|
358 VXGE_HW_DEVICE_ACCESS_RIGHT_SRPCIM
;
361 case VXGE_HW_MR_NO_SR_VH0_BASE_FUNCTION
:
362 access_rights
|= VXGE_HW_DEVICE_ACCESS_RIGHT_MRPCIM
|
363 VXGE_HW_DEVICE_ACCESS_RIGHT_SRPCIM
;
365 case VXGE_HW_NO_MR_SR_VH0_FUNCTION0
:
366 access_rights
|= VXGE_HW_DEVICE_ACCESS_RIGHT_MRPCIM
|
367 VXGE_HW_DEVICE_ACCESS_RIGHT_SRPCIM
;
369 case VXGE_HW_NO_MR_SR_VH0_VIRTUAL_FUNCTION
:
370 case VXGE_HW_SR_VH_VIRTUAL_FUNCTION
:
371 case VXGE_HW_MR_SR_VH0_INVALID_CONFIG
:
373 case VXGE_HW_SR_VH_FUNCTION0
:
374 case VXGE_HW_VH_NORMAL_FUNCTION
:
375 access_rights
|= VXGE_HW_DEVICE_ACCESS_RIGHT_SRPCIM
;
379 return access_rights
;
382 * __vxge_hw_device_is_privilaged
383 * This routine checks if the device function is privilaged or not
387 __vxge_hw_device_is_privilaged(u32 host_type
, u32 func_id
)
389 if (__vxge_hw_device_access_rights_get(host_type
,
391 VXGE_HW_DEVICE_ACCESS_RIGHT_MRPCIM
)
394 return VXGE_HW_ERR_PRIVILAGED_OPEARATION
;
398 * __vxge_hw_device_host_info_get
399 * This routine returns the host type assignments
401 void __vxge_hw_device_host_info_get(struct __vxge_hw_device
*hldev
)
406 val64
= readq(&hldev
->common_reg
->host_type_assignments
);
409 (u32
)VXGE_HW_HOST_TYPE_ASSIGNMENTS_GET_HOST_TYPE_ASSIGNMENTS(val64
);
411 hldev
->vpath_assignments
= readq(&hldev
->common_reg
->vpath_assignments
);
413 for (i
= 0; i
< VXGE_HW_MAX_VIRTUAL_PATHS
; i
++) {
415 if (!(hldev
->vpath_assignments
& vxge_mBIT(i
)))
419 __vxge_hw_vpath_func_id_get(i
, hldev
->vpmgmt_reg
[i
]);
421 hldev
->access_rights
= __vxge_hw_device_access_rights_get(
422 hldev
->host_type
, hldev
->func_id
);
424 hldev
->first_vp_id
= i
;
430 * __vxge_hw_verify_pci_e_info - Validate the pci-e link parameters such as
431 * link width and signalling rate.
433 static enum vxge_hw_status
434 __vxge_hw_verify_pci_e_info(struct __vxge_hw_device
*hldev
)
439 /* Get the negotiated link width and speed from PCI config space */
440 exp_cap
= pci_find_capability(hldev
->pdev
, PCI_CAP_ID_EXP
);
441 pci_read_config_word(hldev
->pdev
, exp_cap
+ PCI_EXP_LNKSTA
, &lnk
);
443 if ((lnk
& PCI_EXP_LNKSTA_CLS
) != 1)
444 return VXGE_HW_ERR_INVALID_PCI_INFO
;
446 switch ((lnk
& PCI_EXP_LNKSTA_NLW
) >> 4) {
447 case PCIE_LNK_WIDTH_RESRV
:
454 return VXGE_HW_ERR_INVALID_PCI_INFO
;
461 * __vxge_hw_device_initialize
462 * Initialize Titan-V hardware.
464 enum vxge_hw_status
__vxge_hw_device_initialize(struct __vxge_hw_device
*hldev
)
466 enum vxge_hw_status status
= VXGE_HW_OK
;
468 if (VXGE_HW_OK
== __vxge_hw_device_is_privilaged(hldev
->host_type
,
470 /* Validate the pci-e link width and speed */
471 status
= __vxge_hw_verify_pci_e_info(hldev
);
472 if (status
!= VXGE_HW_OK
)
481 * vxge_hw_device_hw_info_get - Get the hw information
482 * Returns the vpath mask that has the bits set for each vpath allocated
483 * for the driver, FW version information and the first mac addresse for
486 enum vxge_hw_status __devinit
487 vxge_hw_device_hw_info_get(void __iomem
*bar0
,
488 struct vxge_hw_device_hw_info
*hw_info
)
492 struct vxge_hw_toc_reg __iomem
*toc
;
493 struct vxge_hw_mrpcim_reg __iomem
*mrpcim_reg
;
494 struct vxge_hw_common_reg __iomem
*common_reg
;
495 struct vxge_hw_vpath_reg __iomem
*vpath_reg
;
496 struct vxge_hw_vpmgmt_reg __iomem
*vpmgmt_reg
;
497 enum vxge_hw_status status
;
499 memset(hw_info
, 0, sizeof(struct vxge_hw_device_hw_info
));
501 toc
= __vxge_hw_device_toc_get(bar0
);
503 status
= VXGE_HW_ERR_CRITICAL
;
507 val64
= readq(&toc
->toc_common_pointer
);
508 common_reg
= (struct vxge_hw_common_reg __iomem
*)(bar0
+ val64
);
510 status
= __vxge_hw_device_vpath_reset_in_prog_check(
511 (u64 __iomem
*)&common_reg
->vpath_rst_in_prog
);
512 if (status
!= VXGE_HW_OK
)
515 hw_info
->vpath_mask
= readq(&common_reg
->vpath_assignments
);
517 val64
= readq(&common_reg
->host_type_assignments
);
520 (u32
)VXGE_HW_HOST_TYPE_ASSIGNMENTS_GET_HOST_TYPE_ASSIGNMENTS(val64
);
522 for (i
= 0; i
< VXGE_HW_MAX_VIRTUAL_PATHS
; i
++) {
524 if (!((hw_info
->vpath_mask
) & vxge_mBIT(i
)))
527 val64
= readq(&toc
->toc_vpmgmt_pointer
[i
]);
529 vpmgmt_reg
= (struct vxge_hw_vpmgmt_reg __iomem
*)
532 hw_info
->func_id
= __vxge_hw_vpath_func_id_get(i
, vpmgmt_reg
);
533 if (__vxge_hw_device_access_rights_get(hw_info
->host_type
,
535 VXGE_HW_DEVICE_ACCESS_RIGHT_MRPCIM
) {
537 val64
= readq(&toc
->toc_mrpcim_pointer
);
539 mrpcim_reg
= (struct vxge_hw_mrpcim_reg __iomem
*)
542 writeq(0, &mrpcim_reg
->xgmac_gen_fw_memo_mask
);
546 val64
= readq(&toc
->toc_vpath_pointer
[i
]);
548 vpath_reg
= (struct vxge_hw_vpath_reg __iomem
*)(bar0
+ val64
);
550 hw_info
->function_mode
=
551 __vxge_hw_vpath_pci_func_mode_get(i
, vpath_reg
);
553 status
= __vxge_hw_vpath_fw_ver_get(i
, vpath_reg
, hw_info
);
554 if (status
!= VXGE_HW_OK
)
557 status
= __vxge_hw_vpath_card_info_get(i
, vpath_reg
, hw_info
);
558 if (status
!= VXGE_HW_OK
)
564 for (i
= 0; i
< VXGE_HW_MAX_VIRTUAL_PATHS
; i
++) {
566 if (!((hw_info
->vpath_mask
) & vxge_mBIT(i
)))
569 val64
= readq(&toc
->toc_vpath_pointer
[i
]);
570 vpath_reg
= (struct vxge_hw_vpath_reg __iomem
*)(bar0
+ val64
);
572 status
= __vxge_hw_vpath_addr_get(i
, vpath_reg
,
573 hw_info
->mac_addrs
[i
],
574 hw_info
->mac_addr_masks
[i
]);
575 if (status
!= VXGE_HW_OK
)
583 * vxge_hw_device_initialize - Initialize Titan device.
584 * Initialize Titan device. Note that all the arguments of this public API
585 * are 'IN', including @hldev. Driver cooperates with
586 * OS to find new Titan device, locate its PCI and memory spaces.
588 * When done, the driver allocates sizeof(struct __vxge_hw_device) bytes for HW
589 * to enable the latter to perform Titan hardware initialization.
591 enum vxge_hw_status __devinit
592 vxge_hw_device_initialize(
593 struct __vxge_hw_device
**devh
,
594 struct vxge_hw_device_attr
*attr
,
595 struct vxge_hw_device_config
*device_config
)
599 struct __vxge_hw_device
*hldev
= NULL
;
600 enum vxge_hw_status status
= VXGE_HW_OK
;
602 status
= __vxge_hw_device_config_check(device_config
);
603 if (status
!= VXGE_HW_OK
)
606 hldev
= (struct __vxge_hw_device
*)
607 vmalloc(sizeof(struct __vxge_hw_device
));
609 status
= VXGE_HW_ERR_OUT_OF_MEMORY
;
613 memset(hldev
, 0, sizeof(struct __vxge_hw_device
));
614 hldev
->magic
= VXGE_HW_DEVICE_MAGIC
;
616 vxge_hw_device_debug_set(hldev
, VXGE_ERR
, VXGE_COMPONENT_ALL
);
619 memcpy(&hldev
->config
, device_config
,
620 sizeof(struct vxge_hw_device_config
));
622 hldev
->bar0
= attr
->bar0
;
623 hldev
->pdev
= attr
->pdev
;
625 hldev
->uld_callbacks
.link_up
= attr
->uld_callbacks
.link_up
;
626 hldev
->uld_callbacks
.link_down
= attr
->uld_callbacks
.link_down
;
627 hldev
->uld_callbacks
.crit_err
= attr
->uld_callbacks
.crit_err
;
629 __vxge_hw_device_pci_e_init(hldev
);
631 status
= __vxge_hw_device_reg_addr_get(hldev
);
632 if (status
!= VXGE_HW_OK
) {
636 __vxge_hw_device_id_get(hldev
);
638 __vxge_hw_device_host_info_get(hldev
);
640 /* Incrementing for stats blocks */
643 for (i
= 0; i
< VXGE_HW_MAX_VIRTUAL_PATHS
; i
++) {
645 if (!(hldev
->vpath_assignments
& vxge_mBIT(i
)))
648 if (device_config
->vp_config
[i
].ring
.enable
==
650 nblocks
+= device_config
->vp_config
[i
].ring
.ring_blocks
;
652 if (device_config
->vp_config
[i
].fifo
.enable
==
654 nblocks
+= device_config
->vp_config
[i
].fifo
.fifo_blocks
;
658 if (__vxge_hw_blockpool_create(hldev
,
660 device_config
->dma_blockpool_initial
+ nblocks
,
661 device_config
->dma_blockpool_max
+ nblocks
) != VXGE_HW_OK
) {
663 vxge_hw_device_terminate(hldev
);
664 status
= VXGE_HW_ERR_OUT_OF_MEMORY
;
668 status
= __vxge_hw_device_initialize(hldev
);
670 if (status
!= VXGE_HW_OK
) {
671 vxge_hw_device_terminate(hldev
);
681 * vxge_hw_device_terminate - Terminate Titan device.
682 * Terminate HW device.
685 vxge_hw_device_terminate(struct __vxge_hw_device
*hldev
)
687 vxge_assert(hldev
->magic
== VXGE_HW_DEVICE_MAGIC
);
689 hldev
->magic
= VXGE_HW_DEVICE_DEAD
;
690 __vxge_hw_blockpool_destroy(&hldev
->block_pool
);
695 * vxge_hw_device_stats_get - Get the device hw statistics.
696 * Returns the vpath h/w stats for the device.
699 vxge_hw_device_stats_get(struct __vxge_hw_device
*hldev
,
700 struct vxge_hw_device_stats_hw_info
*hw_stats
)
703 enum vxge_hw_status status
= VXGE_HW_OK
;
705 for (i
= 0; i
< VXGE_HW_MAX_VIRTUAL_PATHS
; i
++) {
707 if (!(hldev
->vpaths_deployed
& vxge_mBIT(i
)) ||
708 (hldev
->virtual_paths
[i
].vp_open
==
709 VXGE_HW_VP_NOT_OPEN
))
712 memcpy(hldev
->virtual_paths
[i
].hw_stats_sav
,
713 hldev
->virtual_paths
[i
].hw_stats
,
714 sizeof(struct vxge_hw_vpath_stats_hw_info
));
716 status
= __vxge_hw_vpath_stats_get(
717 &hldev
->virtual_paths
[i
],
718 hldev
->virtual_paths
[i
].hw_stats
);
721 memcpy(hw_stats
, &hldev
->stats
.hw_dev_info_stats
,
722 sizeof(struct vxge_hw_device_stats_hw_info
));
728 * vxge_hw_driver_stats_get - Get the device sw statistics.
729 * Returns the vpath s/w stats for the device.
731 enum vxge_hw_status
vxge_hw_driver_stats_get(
732 struct __vxge_hw_device
*hldev
,
733 struct vxge_hw_device_stats_sw_info
*sw_stats
)
735 enum vxge_hw_status status
= VXGE_HW_OK
;
737 memcpy(sw_stats
, &hldev
->stats
.sw_dev_info_stats
,
738 sizeof(struct vxge_hw_device_stats_sw_info
));
744 * vxge_hw_mrpcim_stats_access - Access the statistics from the given location
745 * and offset and perform an operation
746 * Get the statistics from the given location and offset.
749 vxge_hw_mrpcim_stats_access(struct __vxge_hw_device
*hldev
,
750 u32 operation
, u32 location
, u32 offset
, u64
*stat
)
753 enum vxge_hw_status status
= VXGE_HW_OK
;
755 status
= __vxge_hw_device_is_privilaged(hldev
->host_type
,
757 if (status
!= VXGE_HW_OK
)
760 val64
= VXGE_HW_XMAC_STATS_SYS_CMD_OP(operation
) |
761 VXGE_HW_XMAC_STATS_SYS_CMD_STROBE
|
762 VXGE_HW_XMAC_STATS_SYS_CMD_LOC_SEL(location
) |
763 VXGE_HW_XMAC_STATS_SYS_CMD_OFFSET_SEL(offset
);
765 status
= __vxge_hw_pio_mem_write64(val64
,
766 &hldev
->mrpcim_reg
->xmac_stats_sys_cmd
,
767 VXGE_HW_XMAC_STATS_SYS_CMD_STROBE
,
768 hldev
->config
.device_poll_millis
);
770 if ((status
== VXGE_HW_OK
) && (operation
== VXGE_HW_STATS_OP_READ
))
771 *stat
= readq(&hldev
->mrpcim_reg
->xmac_stats_sys_data
);
779 * vxge_hw_device_xmac_aggr_stats_get - Get the Statistics on aggregate port
780 * Get the Statistics on aggregate port
783 vxge_hw_device_xmac_aggr_stats_get(struct __vxge_hw_device
*hldev
, u32 port
,
784 struct vxge_hw_xmac_aggr_stats
*aggr_stats
)
788 u32 offset
= VXGE_HW_STATS_AGGRn_OFFSET
;
789 enum vxge_hw_status status
= VXGE_HW_OK
;
791 val64
= (u64
*)aggr_stats
;
793 status
= __vxge_hw_device_is_privilaged(hldev
->host_type
,
795 if (status
!= VXGE_HW_OK
)
798 for (i
= 0; i
< sizeof(struct vxge_hw_xmac_aggr_stats
) / 8; i
++) {
799 status
= vxge_hw_mrpcim_stats_access(hldev
,
800 VXGE_HW_STATS_OP_READ
,
801 VXGE_HW_STATS_LOC_AGGR
,
802 ((offset
+ (104 * port
)) >> 3), val64
);
803 if (status
!= VXGE_HW_OK
)
814 * vxge_hw_device_xmac_port_stats_get - Get the Statistics on a port
815 * Get the Statistics on port
818 vxge_hw_device_xmac_port_stats_get(struct __vxge_hw_device
*hldev
, u32 port
,
819 struct vxge_hw_xmac_port_stats
*port_stats
)
822 enum vxge_hw_status status
= VXGE_HW_OK
;
825 val64
= (u64
*) port_stats
;
827 status
= __vxge_hw_device_is_privilaged(hldev
->host_type
,
829 if (status
!= VXGE_HW_OK
)
832 for (i
= 0; i
< sizeof(struct vxge_hw_xmac_port_stats
) / 8; i
++) {
833 status
= vxge_hw_mrpcim_stats_access(hldev
,
834 VXGE_HW_STATS_OP_READ
,
835 VXGE_HW_STATS_LOC_AGGR
,
836 ((offset
+ (608 * port
)) >> 3), val64
);
837 if (status
!= VXGE_HW_OK
)
849 * vxge_hw_device_xmac_stats_get - Get the XMAC Statistics
850 * Get the XMAC Statistics
853 vxge_hw_device_xmac_stats_get(struct __vxge_hw_device
*hldev
,
854 struct vxge_hw_xmac_stats
*xmac_stats
)
856 enum vxge_hw_status status
= VXGE_HW_OK
;
859 status
= vxge_hw_device_xmac_aggr_stats_get(hldev
,
860 0, &xmac_stats
->aggr_stats
[0]);
862 if (status
!= VXGE_HW_OK
)
865 status
= vxge_hw_device_xmac_aggr_stats_get(hldev
,
866 1, &xmac_stats
->aggr_stats
[1]);
867 if (status
!= VXGE_HW_OK
)
870 for (i
= 0; i
<= VXGE_HW_MAC_MAX_MAC_PORT_ID
; i
++) {
872 status
= vxge_hw_device_xmac_port_stats_get(hldev
,
873 i
, &xmac_stats
->port_stats
[i
]);
874 if (status
!= VXGE_HW_OK
)
878 for (i
= 0; i
< VXGE_HW_MAX_VIRTUAL_PATHS
; i
++) {
880 if (!(hldev
->vpaths_deployed
& vxge_mBIT(i
)))
883 status
= __vxge_hw_vpath_xmac_tx_stats_get(
884 &hldev
->virtual_paths
[i
],
885 &xmac_stats
->vpath_tx_stats
[i
]);
886 if (status
!= VXGE_HW_OK
)
889 status
= __vxge_hw_vpath_xmac_rx_stats_get(
890 &hldev
->virtual_paths
[i
],
891 &xmac_stats
->vpath_rx_stats
[i
]);
892 if (status
!= VXGE_HW_OK
)
900 * vxge_hw_device_debug_set - Set the debug module, level and timestamp
901 * This routine is used to dynamically change the debug output
903 void vxge_hw_device_debug_set(struct __vxge_hw_device
*hldev
,
904 enum vxge_debug_level level
, u32 mask
)
909 #if defined(VXGE_DEBUG_TRACE_MASK) || \
910 defined(VXGE_DEBUG_ERR_MASK)
911 hldev
->debug_module_mask
= mask
;
912 hldev
->debug_level
= level
;
915 #if defined(VXGE_DEBUG_ERR_MASK)
916 hldev
->level_err
= level
& VXGE_ERR
;
919 #if defined(VXGE_DEBUG_TRACE_MASK)
920 hldev
->level_trace
= level
& VXGE_TRACE
;
925 * vxge_hw_device_error_level_get - Get the error level
926 * This routine returns the current error level set
928 u32
vxge_hw_device_error_level_get(struct __vxge_hw_device
*hldev
)
930 #if defined(VXGE_DEBUG_ERR_MASK)
934 return hldev
->level_err
;
941 * vxge_hw_device_trace_level_get - Get the trace level
942 * This routine returns the current trace level set
944 u32
vxge_hw_device_trace_level_get(struct __vxge_hw_device
*hldev
)
946 #if defined(VXGE_DEBUG_TRACE_MASK)
950 return hldev
->level_trace
;
956 * vxge_hw_device_debug_mask_get - Get the debug mask
957 * This routine returns the current debug mask set
959 u32
vxge_hw_device_debug_mask_get(struct __vxge_hw_device
*hldev
)
961 #if defined(VXGE_DEBUG_TRACE_MASK) || defined(VXGE_DEBUG_ERR_MASK)
964 return hldev
->debug_module_mask
;
971 * vxge_hw_getpause_data -Pause frame frame generation and reception.
972 * Returns the Pause frame generation and reception capability of the NIC.
974 enum vxge_hw_status
vxge_hw_device_getpause_data(struct __vxge_hw_device
*hldev
,
975 u32 port
, u32
*tx
, u32
*rx
)
978 enum vxge_hw_status status
= VXGE_HW_OK
;
980 if ((hldev
== NULL
) || (hldev
->magic
!= VXGE_HW_DEVICE_MAGIC
)) {
981 status
= VXGE_HW_ERR_INVALID_DEVICE
;
985 if (port
> VXGE_HW_MAC_MAX_MAC_PORT_ID
) {
986 status
= VXGE_HW_ERR_INVALID_PORT
;
990 if (!(hldev
->access_rights
& VXGE_HW_DEVICE_ACCESS_RIGHT_MRPCIM
)) {
991 status
= VXGE_HW_ERR_PRIVILAGED_OPEARATION
;
995 val64
= readq(&hldev
->mrpcim_reg
->rxmac_pause_cfg_port
[port
]);
996 if (val64
& VXGE_HW_RXMAC_PAUSE_CFG_PORT_GEN_EN
)
998 if (val64
& VXGE_HW_RXMAC_PAUSE_CFG_PORT_RCV_EN
)
1005 * vxge_hw_device_setpause_data - set/reset pause frame generation.
1006 * It can be used to set or reset Pause frame generation or reception
1007 * support of the NIC.
1010 enum vxge_hw_status
vxge_hw_device_setpause_data(struct __vxge_hw_device
*hldev
,
1011 u32 port
, u32 tx
, u32 rx
)
1014 enum vxge_hw_status status
= VXGE_HW_OK
;
1016 if ((hldev
== NULL
) || (hldev
->magic
!= VXGE_HW_DEVICE_MAGIC
)) {
1017 status
= VXGE_HW_ERR_INVALID_DEVICE
;
1021 if (port
> VXGE_HW_MAC_MAX_MAC_PORT_ID
) {
1022 status
= VXGE_HW_ERR_INVALID_PORT
;
1026 status
= __vxge_hw_device_is_privilaged(hldev
->host_type
,
1028 if (status
!= VXGE_HW_OK
)
1031 val64
= readq(&hldev
->mrpcim_reg
->rxmac_pause_cfg_port
[port
]);
1033 val64
|= VXGE_HW_RXMAC_PAUSE_CFG_PORT_GEN_EN
;
1035 val64
&= ~VXGE_HW_RXMAC_PAUSE_CFG_PORT_GEN_EN
;
1037 val64
|= VXGE_HW_RXMAC_PAUSE_CFG_PORT_RCV_EN
;
1039 val64
&= ~VXGE_HW_RXMAC_PAUSE_CFG_PORT_RCV_EN
;
1041 writeq(val64
, &hldev
->mrpcim_reg
->rxmac_pause_cfg_port
[port
]);
1046 u16
vxge_hw_device_link_width_get(struct __vxge_hw_device
*hldev
)
1048 int link_width
, exp_cap
;
1051 exp_cap
= pci_find_capability(hldev
->pdev
, PCI_CAP_ID_EXP
);
1052 pci_read_config_word(hldev
->pdev
, exp_cap
+ PCI_EXP_LNKSTA
, &lnk
);
1053 link_width
= (lnk
& VXGE_HW_PCI_EXP_LNKCAP_LNK_WIDTH
) >> 4;
1058 * __vxge_hw_ring_block_memblock_idx - Return the memblock index
1059 * This function returns the index of memory block
1062 __vxge_hw_ring_block_memblock_idx(u8
*block
)
1064 return (u32
)*((u64
*)(block
+ VXGE_HW_RING_MEMBLOCK_IDX_OFFSET
));
1068 * __vxge_hw_ring_block_memblock_idx_set - Sets the memblock index
1069 * This function sets index to a memory block
1072 __vxge_hw_ring_block_memblock_idx_set(u8
*block
, u32 memblock_idx
)
1074 *((u64
*)(block
+ VXGE_HW_RING_MEMBLOCK_IDX_OFFSET
)) = memblock_idx
;
1078 * __vxge_hw_ring_block_next_pointer_set - Sets the next block pointer
1080 * Sets the next block pointer in RxD block
1083 __vxge_hw_ring_block_next_pointer_set(u8
*block
, dma_addr_t dma_next
)
1085 *((u64
*)(block
+ VXGE_HW_RING_NEXT_BLOCK_POINTER_OFFSET
)) = dma_next
;
1089 * __vxge_hw_ring_first_block_address_get - Returns the dma address of the
1091 * Returns the dma address of the first RxD block
1093 u64
__vxge_hw_ring_first_block_address_get(struct __vxge_hw_ring
*ring
)
1095 struct vxge_hw_mempool_dma
*dma_object
;
1097 dma_object
= ring
->mempool
->memblocks_dma_arr
;
1098 vxge_assert(dma_object
!= NULL
);
1100 return dma_object
->addr
;
1104 * __vxge_hw_ring_item_dma_addr - Return the dma address of an item
1105 * This function returns the dma address of a given item
1107 static dma_addr_t
__vxge_hw_ring_item_dma_addr(struct vxge_hw_mempool
*mempoolh
,
1112 struct vxge_hw_mempool_dma
*memblock_dma_object
;
1113 ptrdiff_t dma_item_offset
;
1115 /* get owner memblock index */
1116 memblock_idx
= __vxge_hw_ring_block_memblock_idx(item
);
1118 /* get owner memblock by memblock index */
1119 memblock
= mempoolh
->memblocks_arr
[memblock_idx
];
1121 /* get memblock DMA object by memblock index */
1122 memblock_dma_object
= mempoolh
->memblocks_dma_arr
+ memblock_idx
;
1124 /* calculate offset in the memblock of this item */
1125 dma_item_offset
= (u8
*)item
- (u8
*)memblock
;
1127 return memblock_dma_object
->addr
+ dma_item_offset
;
1131 * __vxge_hw_ring_rxdblock_link - Link the RxD blocks
1132 * This function returns the dma address of a given item
1134 static void __vxge_hw_ring_rxdblock_link(struct vxge_hw_mempool
*mempoolh
,
1135 struct __vxge_hw_ring
*ring
, u32 from
,
1138 u8
*to_item
, *from_item
;
1141 /* get "from" RxD block */
1142 from_item
= mempoolh
->items_arr
[from
];
1143 vxge_assert(from_item
);
1145 /* get "to" RxD block */
1146 to_item
= mempoolh
->items_arr
[to
];
1147 vxge_assert(to_item
);
1149 /* return address of the beginning of previous RxD block */
1150 to_dma
= __vxge_hw_ring_item_dma_addr(mempoolh
, to_item
);
1152 /* set next pointer for this RxD block to point on
1153 * previous item's DMA start address */
1154 __vxge_hw_ring_block_next_pointer_set(from_item
, to_dma
);
1158 * __vxge_hw_ring_mempool_item_alloc - Allocate List blocks for RxD
1160 * This function is callback passed to __vxge_hw_mempool_create to create memory
1161 * pool for RxD block
1164 __vxge_hw_ring_mempool_item_alloc(struct vxge_hw_mempool
*mempoolh
,
1166 struct vxge_hw_mempool_dma
*dma_object
,
1167 u32 index
, u32 is_last
)
1170 void *item
= mempoolh
->items_arr
[index
];
1171 struct __vxge_hw_ring
*ring
=
1172 (struct __vxge_hw_ring
*)mempoolh
->userdata
;
1174 /* format rxds array */
1175 for (i
= 0; i
< ring
->rxds_per_block
; i
++) {
1176 void *rxdblock_priv
;
1178 struct vxge_hw_ring_rxd_1
*rxdp
;
1180 u32 reserve_index
= ring
->channel
.reserve_ptr
-
1181 (index
* ring
->rxds_per_block
+ i
+ 1);
1182 u32 memblock_item_idx
;
1184 ring
->channel
.reserve_arr
[reserve_index
] = ((u8
*)item
) +
1187 /* Note: memblock_item_idx is index of the item within
1188 * the memblock. For instance, in case of three RxD-blocks
1189 * per memblock this value can be 0, 1 or 2. */
1190 rxdblock_priv
= __vxge_hw_mempool_item_priv(mempoolh
,
1191 memblock_index
, item
,
1192 &memblock_item_idx
);
1194 rxdp
= (struct vxge_hw_ring_rxd_1
*)
1195 ring
->channel
.reserve_arr
[reserve_index
];
1197 uld_priv
= ((u8
*)rxdblock_priv
+ ring
->rxd_priv_size
* i
);
1199 /* pre-format Host_Control */
1200 rxdp
->host_control
= (u64
)(size_t)uld_priv
;
1203 __vxge_hw_ring_block_memblock_idx_set(item
, memblock_index
);
1206 /* link last one with first one */
1207 __vxge_hw_ring_rxdblock_link(mempoolh
, ring
, index
, 0);
1211 /* link this RxD block with previous one */
1212 __vxge_hw_ring_rxdblock_link(mempoolh
, ring
, index
- 1, index
);
1217 * __vxge_hw_ring_replenish - Initial replenish of RxDs
1218 * This function replenishes the RxDs from reserve array to work array
1221 vxge_hw_ring_replenish(struct __vxge_hw_ring
*ring
)
1224 struct __vxge_hw_channel
*channel
;
1225 enum vxge_hw_status status
= VXGE_HW_OK
;
1227 channel
= &ring
->channel
;
1229 while (vxge_hw_channel_dtr_count(channel
) > 0) {
1231 status
= vxge_hw_ring_rxd_reserve(ring
, &rxd
);
1233 vxge_assert(status
== VXGE_HW_OK
);
1235 if (ring
->rxd_init
) {
1236 status
= ring
->rxd_init(rxd
, channel
->userdata
);
1237 if (status
!= VXGE_HW_OK
) {
1238 vxge_hw_ring_rxd_free(ring
, rxd
);
1243 vxge_hw_ring_rxd_post(ring
, rxd
);
1245 status
= VXGE_HW_OK
;
1251 * __vxge_hw_ring_create - Create a Ring
1252 * This function creates Ring and initializes it.
1256 __vxge_hw_ring_create(struct __vxge_hw_vpath_handle
*vp
,
1257 struct vxge_hw_ring_attr
*attr
)
1259 enum vxge_hw_status status
= VXGE_HW_OK
;
1260 struct __vxge_hw_ring
*ring
;
1262 struct vxge_hw_ring_config
*config
;
1263 struct __vxge_hw_device
*hldev
;
1265 struct vxge_hw_mempool_cbs ring_mp_callback
;
1267 if ((vp
== NULL
) || (attr
== NULL
)) {
1268 status
= VXGE_HW_FAIL
;
1272 hldev
= vp
->vpath
->hldev
;
1273 vp_id
= vp
->vpath
->vp_id
;
1275 config
= &hldev
->config
.vp_config
[vp_id
].ring
;
1277 ring_length
= config
->ring_blocks
*
1278 vxge_hw_ring_rxds_per_block_get(config
->buffer_mode
);
1280 ring
= (struct __vxge_hw_ring
*)__vxge_hw_channel_allocate(vp
,
1281 VXGE_HW_CHANNEL_TYPE_RING
,
1283 attr
->per_rxd_space
,
1287 status
= VXGE_HW_ERR_OUT_OF_MEMORY
;
1291 vp
->vpath
->ringh
= ring
;
1292 ring
->vp_id
= vp_id
;
1293 ring
->vp_reg
= vp
->vpath
->vp_reg
;
1294 ring
->common_reg
= hldev
->common_reg
;
1295 ring
->stats
= &vp
->vpath
->sw_stats
->ring_stats
;
1296 ring
->config
= config
;
1297 ring
->callback
= attr
->callback
;
1298 ring
->rxd_init
= attr
->rxd_init
;
1299 ring
->rxd_term
= attr
->rxd_term
;
1300 ring
->buffer_mode
= config
->buffer_mode
;
1301 ring
->rxds_limit
= config
->rxds_limit
;
1303 ring
->rxd_size
= vxge_hw_ring_rxd_size_get(config
->buffer_mode
);
1304 ring
->rxd_priv_size
=
1305 sizeof(struct __vxge_hw_ring_rxd_priv
) + attr
->per_rxd_space
;
1306 ring
->per_rxd_space
= attr
->per_rxd_space
;
1308 ring
->rxd_priv_size
=
1309 ((ring
->rxd_priv_size
+ VXGE_CACHE_LINE_SIZE
- 1) /
1310 VXGE_CACHE_LINE_SIZE
) * VXGE_CACHE_LINE_SIZE
;
1312 /* how many RxDs can fit into one block. Depends on configured
1314 ring
->rxds_per_block
=
1315 vxge_hw_ring_rxds_per_block_get(config
->buffer_mode
);
1317 /* calculate actual RxD block private size */
1318 ring
->rxdblock_priv_size
= ring
->rxd_priv_size
* ring
->rxds_per_block
;
1319 ring_mp_callback
.item_func_alloc
= __vxge_hw_ring_mempool_item_alloc
;
1320 ring
->mempool
= __vxge_hw_mempool_create(hldev
,
1323 ring
->rxdblock_priv_size
,
1324 ring
->config
->ring_blocks
,
1325 ring
->config
->ring_blocks
,
1329 if (ring
->mempool
== NULL
) {
1330 __vxge_hw_ring_delete(vp
);
1331 return VXGE_HW_ERR_OUT_OF_MEMORY
;
1334 status
= __vxge_hw_channel_initialize(&ring
->channel
);
1335 if (status
!= VXGE_HW_OK
) {
1336 __vxge_hw_ring_delete(vp
);
1341 * Specifying rxd_init callback means two things:
1342 * 1) rxds need to be initialized by driver at channel-open time;
1343 * 2) rxds need to be posted at channel-open time
1344 * (that's what the initial_replenish() below does)
1345 * Currently we don't have a case when the 1) is done without the 2).
1347 if (ring
->rxd_init
) {
1348 status
= vxge_hw_ring_replenish(ring
);
1349 if (status
!= VXGE_HW_OK
) {
1350 __vxge_hw_ring_delete(vp
);
1355 /* initial replenish will increment the counter in its post() routine,
1356 * we have to reset it */
1357 ring
->stats
->common_stats
.usage_cnt
= 0;
1363 * __vxge_hw_ring_abort - Returns the RxD
1364 * This function terminates the RxDs of ring
1366 enum vxge_hw_status
__vxge_hw_ring_abort(struct __vxge_hw_ring
*ring
)
1369 struct __vxge_hw_channel
*channel
;
1371 channel
= &ring
->channel
;
1374 vxge_hw_channel_dtr_try_complete(channel
, &rxdh
);
1379 vxge_hw_channel_dtr_complete(channel
);
1382 ring
->rxd_term(rxdh
, VXGE_HW_RXD_STATE_POSTED
,
1385 vxge_hw_channel_dtr_free(channel
, rxdh
);
1392 * __vxge_hw_ring_reset - Resets the ring
1393 * This function resets the ring during vpath reset operation
1395 enum vxge_hw_status
__vxge_hw_ring_reset(struct __vxge_hw_ring
*ring
)
1397 enum vxge_hw_status status
= VXGE_HW_OK
;
1398 struct __vxge_hw_channel
*channel
;
1400 channel
= &ring
->channel
;
1402 __vxge_hw_ring_abort(ring
);
1404 status
= __vxge_hw_channel_reset(channel
);
1406 if (status
!= VXGE_HW_OK
)
1409 if (ring
->rxd_init
) {
1410 status
= vxge_hw_ring_replenish(ring
);
1411 if (status
!= VXGE_HW_OK
)
1419 * __vxge_hw_ring_delete - Removes the ring
1420 * This function freeup the memory pool and removes the ring
1422 enum vxge_hw_status
__vxge_hw_ring_delete(struct __vxge_hw_vpath_handle
*vp
)
1424 struct __vxge_hw_ring
*ring
= vp
->vpath
->ringh
;
1426 __vxge_hw_ring_abort(ring
);
1429 __vxge_hw_mempool_destroy(ring
->mempool
);
1431 vp
->vpath
->ringh
= NULL
;
1432 __vxge_hw_channel_free(&ring
->channel
);
1438 * __vxge_hw_mempool_grow
1439 * Will resize mempool up to %num_allocate value.
1442 __vxge_hw_mempool_grow(struct vxge_hw_mempool
*mempool
, u32 num_allocate
,
1445 u32 i
, first_time
= mempool
->memblocks_allocated
== 0 ? 1 : 0;
1446 u32 n_items
= mempool
->items_per_memblock
;
1447 u32 start_block_idx
= mempool
->memblocks_allocated
;
1448 u32 end_block_idx
= mempool
->memblocks_allocated
+ num_allocate
;
1449 enum vxge_hw_status status
= VXGE_HW_OK
;
1453 if (end_block_idx
> mempool
->memblocks_max
) {
1454 status
= VXGE_HW_ERR_OUT_OF_MEMORY
;
1458 for (i
= start_block_idx
; i
< end_block_idx
; i
++) {
1460 u32 is_last
= ((end_block_idx
- 1) == i
);
1461 struct vxge_hw_mempool_dma
*dma_object
=
1462 mempool
->memblocks_dma_arr
+ i
;
1465 /* allocate memblock's private part. Each DMA memblock
1466 * has a space allocated for item's private usage upon
1467 * mempool's user request. Each time mempool grows, it will
1468 * allocate new memblock and its private part at once.
1469 * This helps to minimize memory usage a lot. */
1470 mempool
->memblocks_priv_arr
[i
] =
1471 vmalloc(mempool
->items_priv_size
* n_items
);
1472 if (mempool
->memblocks_priv_arr
[i
] == NULL
) {
1473 status
= VXGE_HW_ERR_OUT_OF_MEMORY
;
1477 memset(mempool
->memblocks_priv_arr
[i
], 0,
1478 mempool
->items_priv_size
* n_items
);
1480 /* allocate DMA-capable memblock */
1481 mempool
->memblocks_arr
[i
] =
1482 __vxge_hw_blockpool_malloc(mempool
->devh
,
1483 mempool
->memblock_size
, dma_object
);
1484 if (mempool
->memblocks_arr
[i
] == NULL
) {
1485 vfree(mempool
->memblocks_priv_arr
[i
]);
1486 status
= VXGE_HW_ERR_OUT_OF_MEMORY
;
1491 mempool
->memblocks_allocated
++;
1493 memset(mempool
->memblocks_arr
[i
], 0, mempool
->memblock_size
);
1495 the_memblock
= mempool
->memblocks_arr
[i
];
1497 /* fill the items hash array */
1498 for (j
= 0; j
< n_items
; j
++) {
1499 u32 index
= i
* n_items
+ j
;
1501 if (first_time
&& index
>= mempool
->items_initial
)
1504 mempool
->items_arr
[index
] =
1505 ((char *)the_memblock
+ j
*mempool
->item_size
);
1507 /* let caller to do more job on each item */
1508 if (mempool
->item_func_alloc
!= NULL
)
1509 mempool
->item_func_alloc(mempool
, i
,
1510 dma_object
, index
, is_last
);
1512 mempool
->items_current
= index
+ 1;
1515 if (first_time
&& mempool
->items_current
==
1516 mempool
->items_initial
)
1524 * vxge_hw_mempool_create
1525 * This function will create memory pool object. Pool may grow but will
1526 * never shrink. Pool consists of number of dynamically allocated blocks
1527 * with size enough to hold %items_initial number of items. Memory is
1528 * DMA-able but client must map/unmap before interoperating with the device.
1530 struct vxge_hw_mempool
*
1531 __vxge_hw_mempool_create(
1532 struct __vxge_hw_device
*devh
,
1535 u32 items_priv_size
,
1538 struct vxge_hw_mempool_cbs
*mp_callback
,
1541 enum vxge_hw_status status
= VXGE_HW_OK
;
1542 u32 memblocks_to_allocate
;
1543 struct vxge_hw_mempool
*mempool
= NULL
;
1546 if (memblock_size
< item_size
) {
1547 status
= VXGE_HW_FAIL
;
1551 mempool
= (struct vxge_hw_mempool
*)
1552 vmalloc(sizeof(struct vxge_hw_mempool
));
1553 if (mempool
== NULL
) {
1554 status
= VXGE_HW_ERR_OUT_OF_MEMORY
;
1557 memset(mempool
, 0, sizeof(struct vxge_hw_mempool
));
1559 mempool
->devh
= devh
;
1560 mempool
->memblock_size
= memblock_size
;
1561 mempool
->items_max
= items_max
;
1562 mempool
->items_initial
= items_initial
;
1563 mempool
->item_size
= item_size
;
1564 mempool
->items_priv_size
= items_priv_size
;
1565 mempool
->item_func_alloc
= mp_callback
->item_func_alloc
;
1566 mempool
->userdata
= userdata
;
1568 mempool
->memblocks_allocated
= 0;
1570 mempool
->items_per_memblock
= memblock_size
/ item_size
;
1572 mempool
->memblocks_max
= (items_max
+ mempool
->items_per_memblock
- 1) /
1573 mempool
->items_per_memblock
;
1575 /* allocate array of memblocks */
1576 mempool
->memblocks_arr
=
1577 (void **) vmalloc(sizeof(void *) * mempool
->memblocks_max
);
1578 if (mempool
->memblocks_arr
== NULL
) {
1579 __vxge_hw_mempool_destroy(mempool
);
1580 status
= VXGE_HW_ERR_OUT_OF_MEMORY
;
1584 memset(mempool
->memblocks_arr
, 0,
1585 sizeof(void *) * mempool
->memblocks_max
);
1587 /* allocate array of private parts of items per memblocks */
1588 mempool
->memblocks_priv_arr
=
1589 (void **) vmalloc(sizeof(void *) * mempool
->memblocks_max
);
1590 if (mempool
->memblocks_priv_arr
== NULL
) {
1591 __vxge_hw_mempool_destroy(mempool
);
1592 status
= VXGE_HW_ERR_OUT_OF_MEMORY
;
1596 memset(mempool
->memblocks_priv_arr
, 0,
1597 sizeof(void *) * mempool
->memblocks_max
);
1599 /* allocate array of memblocks DMA objects */
1600 mempool
->memblocks_dma_arr
= (struct vxge_hw_mempool_dma
*)
1601 vmalloc(sizeof(struct vxge_hw_mempool_dma
) *
1602 mempool
->memblocks_max
);
1604 if (mempool
->memblocks_dma_arr
== NULL
) {
1605 __vxge_hw_mempool_destroy(mempool
);
1606 status
= VXGE_HW_ERR_OUT_OF_MEMORY
;
1610 memset(mempool
->memblocks_dma_arr
, 0,
1611 sizeof(struct vxge_hw_mempool_dma
) *
1612 mempool
->memblocks_max
);
1614 /* allocate hash array of items */
1615 mempool
->items_arr
=
1616 (void **) vmalloc(sizeof(void *) * mempool
->items_max
);
1617 if (mempool
->items_arr
== NULL
) {
1618 __vxge_hw_mempool_destroy(mempool
);
1619 status
= VXGE_HW_ERR_OUT_OF_MEMORY
;
1623 memset(mempool
->items_arr
, 0, sizeof(void *) * mempool
->items_max
);
1625 /* calculate initial number of memblocks */
1626 memblocks_to_allocate
= (mempool
->items_initial
+
1627 mempool
->items_per_memblock
- 1) /
1628 mempool
->items_per_memblock
;
1630 /* pre-allocate the mempool */
1631 status
= __vxge_hw_mempool_grow(mempool
, memblocks_to_allocate
,
1633 if (status
!= VXGE_HW_OK
) {
1634 __vxge_hw_mempool_destroy(mempool
);
1635 status
= VXGE_HW_ERR_OUT_OF_MEMORY
;
1645 * vxge_hw_mempool_destroy
1647 void __vxge_hw_mempool_destroy(struct vxge_hw_mempool
*mempool
)
1650 struct __vxge_hw_device
*devh
= mempool
->devh
;
1652 for (i
= 0; i
< mempool
->memblocks_allocated
; i
++) {
1653 struct vxge_hw_mempool_dma
*dma_object
;
1655 vxge_assert(mempool
->memblocks_arr
[i
]);
1656 vxge_assert(mempool
->memblocks_dma_arr
+ i
);
1658 dma_object
= mempool
->memblocks_dma_arr
+ i
;
1660 for (j
= 0; j
< mempool
->items_per_memblock
; j
++) {
1661 u32 index
= i
* mempool
->items_per_memblock
+ j
;
1663 /* to skip last partially filled(if any) memblock */
1664 if (index
>= mempool
->items_current
)
1668 vfree(mempool
->memblocks_priv_arr
[i
]);
1670 __vxge_hw_blockpool_free(devh
, mempool
->memblocks_arr
[i
],
1671 mempool
->memblock_size
, dma_object
);
1674 vfree(mempool
->items_arr
);
1676 vfree(mempool
->memblocks_dma_arr
);
1678 vfree(mempool
->memblocks_priv_arr
);
1680 vfree(mempool
->memblocks_arr
);
1686 * __vxge_hw_device_fifo_config_check - Check fifo configuration.
1687 * Check the fifo configuration
1690 __vxge_hw_device_fifo_config_check(struct vxge_hw_fifo_config
*fifo_config
)
1692 if ((fifo_config
->fifo_blocks
< VXGE_HW_MIN_FIFO_BLOCKS
) ||
1693 (fifo_config
->fifo_blocks
> VXGE_HW_MAX_FIFO_BLOCKS
))
1694 return VXGE_HW_BADCFG_FIFO_BLOCKS
;
1700 * __vxge_hw_device_vpath_config_check - Check vpath configuration.
1701 * Check the vpath configuration
1704 __vxge_hw_device_vpath_config_check(struct vxge_hw_vp_config
*vp_config
)
1706 enum vxge_hw_status status
;
1708 if ((vp_config
->min_bandwidth
< VXGE_HW_VPATH_BANDWIDTH_MIN
) ||
1709 (vp_config
->min_bandwidth
>
1710 VXGE_HW_VPATH_BANDWIDTH_MAX
))
1711 return VXGE_HW_BADCFG_VPATH_MIN_BANDWIDTH
;
1713 status
= __vxge_hw_device_fifo_config_check(&vp_config
->fifo
);
1714 if (status
!= VXGE_HW_OK
)
1717 if ((vp_config
->mtu
!= VXGE_HW_VPATH_USE_FLASH_DEFAULT_INITIAL_MTU
) &&
1718 ((vp_config
->mtu
< VXGE_HW_VPATH_MIN_INITIAL_MTU
) ||
1719 (vp_config
->mtu
> VXGE_HW_VPATH_MAX_INITIAL_MTU
)))
1720 return VXGE_HW_BADCFG_VPATH_MTU
;
1722 if ((vp_config
->rpa_strip_vlan_tag
!=
1723 VXGE_HW_VPATH_RPA_STRIP_VLAN_TAG_USE_FLASH_DEFAULT
) &&
1724 (vp_config
->rpa_strip_vlan_tag
!=
1725 VXGE_HW_VPATH_RPA_STRIP_VLAN_TAG_ENABLE
) &&
1726 (vp_config
->rpa_strip_vlan_tag
!=
1727 VXGE_HW_VPATH_RPA_STRIP_VLAN_TAG_DISABLE
))
1728 return VXGE_HW_BADCFG_VPATH_RPA_STRIP_VLAN_TAG
;
1734 * __vxge_hw_device_config_check - Check device configuration.
1735 * Check the device configuration
1738 __vxge_hw_device_config_check(struct vxge_hw_device_config
*new_config
)
1741 enum vxge_hw_status status
;
1743 if ((new_config
->intr_mode
!= VXGE_HW_INTR_MODE_IRQLINE
) &&
1744 (new_config
->intr_mode
!= VXGE_HW_INTR_MODE_MSIX
) &&
1745 (new_config
->intr_mode
!= VXGE_HW_INTR_MODE_MSIX_ONE_SHOT
) &&
1746 (new_config
->intr_mode
!= VXGE_HW_INTR_MODE_DEF
))
1747 return VXGE_HW_BADCFG_INTR_MODE
;
1749 if ((new_config
->rts_mac_en
!= VXGE_HW_RTS_MAC_DISABLE
) &&
1750 (new_config
->rts_mac_en
!= VXGE_HW_RTS_MAC_ENABLE
))
1751 return VXGE_HW_BADCFG_RTS_MAC_EN
;
1753 for (i
= 0; i
< VXGE_HW_MAX_VIRTUAL_PATHS
; i
++) {
1754 status
= __vxge_hw_device_vpath_config_check(
1755 &new_config
->vp_config
[i
]);
1756 if (status
!= VXGE_HW_OK
)
1764 * vxge_hw_device_config_default_get - Initialize device config with defaults.
1765 * Initialize Titan device config with default values.
1767 enum vxge_hw_status __devinit
1768 vxge_hw_device_config_default_get(struct vxge_hw_device_config
*device_config
)
1772 device_config
->dma_blockpool_initial
=
1773 VXGE_HW_INITIAL_DMA_BLOCK_POOL_SIZE
;
1774 device_config
->dma_blockpool_max
= VXGE_HW_MAX_DMA_BLOCK_POOL_SIZE
;
1775 device_config
->intr_mode
= VXGE_HW_INTR_MODE_DEF
;
1776 device_config
->rth_en
= VXGE_HW_RTH_DEFAULT
;
1777 device_config
->rth_it_type
= VXGE_HW_RTH_IT_TYPE_DEFAULT
;
1778 device_config
->device_poll_millis
= VXGE_HW_DEF_DEVICE_POLL_MILLIS
;
1779 device_config
->rts_mac_en
= VXGE_HW_RTS_MAC_DEFAULT
;
1781 for (i
= 0; i
< VXGE_HW_MAX_VIRTUAL_PATHS
; i
++) {
1783 device_config
->vp_config
[i
].vp_id
= i
;
1785 device_config
->vp_config
[i
].min_bandwidth
=
1786 VXGE_HW_VPATH_BANDWIDTH_DEFAULT
;
1788 device_config
->vp_config
[i
].ring
.enable
= VXGE_HW_RING_DEFAULT
;
1790 device_config
->vp_config
[i
].ring
.ring_blocks
=
1791 VXGE_HW_DEF_RING_BLOCKS
;
1793 device_config
->vp_config
[i
].ring
.buffer_mode
=
1794 VXGE_HW_RING_RXD_BUFFER_MODE_DEFAULT
;
1796 device_config
->vp_config
[i
].ring
.scatter_mode
=
1797 VXGE_HW_RING_SCATTER_MODE_USE_FLASH_DEFAULT
;
1799 device_config
->vp_config
[i
].ring
.rxds_limit
=
1800 VXGE_HW_DEF_RING_RXDS_LIMIT
;
1802 device_config
->vp_config
[i
].fifo
.enable
= VXGE_HW_FIFO_ENABLE
;
1804 device_config
->vp_config
[i
].fifo
.fifo_blocks
=
1805 VXGE_HW_MIN_FIFO_BLOCKS
;
1807 device_config
->vp_config
[i
].fifo
.max_frags
=
1808 VXGE_HW_MAX_FIFO_FRAGS
;
1810 device_config
->vp_config
[i
].fifo
.memblock_size
=
1811 VXGE_HW_DEF_FIFO_MEMBLOCK_SIZE
;
1813 device_config
->vp_config
[i
].fifo
.alignment_size
=
1814 VXGE_HW_DEF_FIFO_ALIGNMENT_SIZE
;
1816 device_config
->vp_config
[i
].fifo
.intr
=
1817 VXGE_HW_FIFO_QUEUE_INTR_DEFAULT
;
1819 device_config
->vp_config
[i
].fifo
.no_snoop_bits
=
1820 VXGE_HW_FIFO_NO_SNOOP_DEFAULT
;
1821 device_config
->vp_config
[i
].tti
.intr_enable
=
1822 VXGE_HW_TIM_INTR_DEFAULT
;
1824 device_config
->vp_config
[i
].tti
.btimer_val
=
1825 VXGE_HW_USE_FLASH_DEFAULT
;
1827 device_config
->vp_config
[i
].tti
.timer_ac_en
=
1828 VXGE_HW_USE_FLASH_DEFAULT
;
1830 device_config
->vp_config
[i
].tti
.timer_ci_en
=
1831 VXGE_HW_USE_FLASH_DEFAULT
;
1833 device_config
->vp_config
[i
].tti
.timer_ri_en
=
1834 VXGE_HW_USE_FLASH_DEFAULT
;
1836 device_config
->vp_config
[i
].tti
.rtimer_val
=
1837 VXGE_HW_USE_FLASH_DEFAULT
;
1839 device_config
->vp_config
[i
].tti
.util_sel
=
1840 VXGE_HW_USE_FLASH_DEFAULT
;
1842 device_config
->vp_config
[i
].tti
.ltimer_val
=
1843 VXGE_HW_USE_FLASH_DEFAULT
;
1845 device_config
->vp_config
[i
].tti
.urange_a
=
1846 VXGE_HW_USE_FLASH_DEFAULT
;
1848 device_config
->vp_config
[i
].tti
.uec_a
=
1849 VXGE_HW_USE_FLASH_DEFAULT
;
1851 device_config
->vp_config
[i
].tti
.urange_b
=
1852 VXGE_HW_USE_FLASH_DEFAULT
;
1854 device_config
->vp_config
[i
].tti
.uec_b
=
1855 VXGE_HW_USE_FLASH_DEFAULT
;
1857 device_config
->vp_config
[i
].tti
.urange_c
=
1858 VXGE_HW_USE_FLASH_DEFAULT
;
1860 device_config
->vp_config
[i
].tti
.uec_c
=
1861 VXGE_HW_USE_FLASH_DEFAULT
;
1863 device_config
->vp_config
[i
].tti
.uec_d
=
1864 VXGE_HW_USE_FLASH_DEFAULT
;
1866 device_config
->vp_config
[i
].rti
.intr_enable
=
1867 VXGE_HW_TIM_INTR_DEFAULT
;
1869 device_config
->vp_config
[i
].rti
.btimer_val
=
1870 VXGE_HW_USE_FLASH_DEFAULT
;
1872 device_config
->vp_config
[i
].rti
.timer_ac_en
=
1873 VXGE_HW_USE_FLASH_DEFAULT
;
1875 device_config
->vp_config
[i
].rti
.timer_ci_en
=
1876 VXGE_HW_USE_FLASH_DEFAULT
;
1878 device_config
->vp_config
[i
].rti
.timer_ri_en
=
1879 VXGE_HW_USE_FLASH_DEFAULT
;
1881 device_config
->vp_config
[i
].rti
.rtimer_val
=
1882 VXGE_HW_USE_FLASH_DEFAULT
;
1884 device_config
->vp_config
[i
].rti
.util_sel
=
1885 VXGE_HW_USE_FLASH_DEFAULT
;
1887 device_config
->vp_config
[i
].rti
.ltimer_val
=
1888 VXGE_HW_USE_FLASH_DEFAULT
;
1890 device_config
->vp_config
[i
].rti
.urange_a
=
1891 VXGE_HW_USE_FLASH_DEFAULT
;
1893 device_config
->vp_config
[i
].rti
.uec_a
=
1894 VXGE_HW_USE_FLASH_DEFAULT
;
1896 device_config
->vp_config
[i
].rti
.urange_b
=
1897 VXGE_HW_USE_FLASH_DEFAULT
;
1899 device_config
->vp_config
[i
].rti
.uec_b
=
1900 VXGE_HW_USE_FLASH_DEFAULT
;
1902 device_config
->vp_config
[i
].rti
.urange_c
=
1903 VXGE_HW_USE_FLASH_DEFAULT
;
1905 device_config
->vp_config
[i
].rti
.uec_c
=
1906 VXGE_HW_USE_FLASH_DEFAULT
;
1908 device_config
->vp_config
[i
].rti
.uec_d
=
1909 VXGE_HW_USE_FLASH_DEFAULT
;
1911 device_config
->vp_config
[i
].mtu
=
1912 VXGE_HW_VPATH_USE_FLASH_DEFAULT_INITIAL_MTU
;
1914 device_config
->vp_config
[i
].rpa_strip_vlan_tag
=
1915 VXGE_HW_VPATH_RPA_STRIP_VLAN_TAG_USE_FLASH_DEFAULT
;
1922 * _hw_legacy_swapper_set - Set the swapper bits for the legacy secion.
1923 * Set the swapper bits appropriately for the lagacy section.
1926 __vxge_hw_legacy_swapper_set(struct vxge_hw_legacy_reg __iomem
*legacy_reg
)
1929 enum vxge_hw_status status
= VXGE_HW_OK
;
1931 val64
= readq(&legacy_reg
->toc_swapper_fb
);
1937 case VXGE_HW_SWAPPER_INITIAL_VALUE
:
1940 case VXGE_HW_SWAPPER_BYTE_SWAPPED_BIT_FLIPPED
:
1941 writeq(VXGE_HW_SWAPPER_READ_BYTE_SWAP_ENABLE
,
1942 &legacy_reg
->pifm_rd_swap_en
);
1943 writeq(VXGE_HW_SWAPPER_READ_BIT_FLAP_ENABLE
,
1944 &legacy_reg
->pifm_rd_flip_en
);
1945 writeq(VXGE_HW_SWAPPER_WRITE_BYTE_SWAP_ENABLE
,
1946 &legacy_reg
->pifm_wr_swap_en
);
1947 writeq(VXGE_HW_SWAPPER_WRITE_BIT_FLAP_ENABLE
,
1948 &legacy_reg
->pifm_wr_flip_en
);
1951 case VXGE_HW_SWAPPER_BYTE_SWAPPED
:
1952 writeq(VXGE_HW_SWAPPER_READ_BYTE_SWAP_ENABLE
,
1953 &legacy_reg
->pifm_rd_swap_en
);
1954 writeq(VXGE_HW_SWAPPER_WRITE_BYTE_SWAP_ENABLE
,
1955 &legacy_reg
->pifm_wr_swap_en
);
1958 case VXGE_HW_SWAPPER_BIT_FLIPPED
:
1959 writeq(VXGE_HW_SWAPPER_READ_BIT_FLAP_ENABLE
,
1960 &legacy_reg
->pifm_rd_flip_en
);
1961 writeq(VXGE_HW_SWAPPER_WRITE_BIT_FLAP_ENABLE
,
1962 &legacy_reg
->pifm_wr_flip_en
);
1968 val64
= readq(&legacy_reg
->toc_swapper_fb
);
1970 if (val64
!= VXGE_HW_SWAPPER_INITIAL_VALUE
)
1971 status
= VXGE_HW_ERR_SWAPPER_CTRL
;
1977 * __vxge_hw_vpath_swapper_set - Set the swapper bits for the vpath.
1978 * Set the swapper bits appropriately for the vpath.
1981 __vxge_hw_vpath_swapper_set(struct vxge_hw_vpath_reg __iomem
*vpath_reg
)
1983 #ifndef __BIG_ENDIAN
1986 val64
= readq(&vpath_reg
->vpath_general_cfg1
);
1988 val64
|= VXGE_HW_VPATH_GENERAL_CFG1_CTL_BYTE_SWAPEN
;
1989 writeq(val64
, &vpath_reg
->vpath_general_cfg1
);
1996 * __vxge_hw_kdfc_swapper_set - Set the swapper bits for the kdfc.
1997 * Set the swapper bits appropriately for the vpath.
2000 __vxge_hw_kdfc_swapper_set(
2001 struct vxge_hw_legacy_reg __iomem
*legacy_reg
,
2002 struct vxge_hw_vpath_reg __iomem
*vpath_reg
)
2006 val64
= readq(&legacy_reg
->pifm_wr_swap_en
);
2008 if (val64
== VXGE_HW_SWAPPER_WRITE_BYTE_SWAP_ENABLE
) {
2009 val64
= readq(&vpath_reg
->kdfcctl_cfg0
);
2012 val64
|= VXGE_HW_KDFCCTL_CFG0_BYTE_SWAPEN_FIFO0
|
2013 VXGE_HW_KDFCCTL_CFG0_BYTE_SWAPEN_FIFO1
|
2014 VXGE_HW_KDFCCTL_CFG0_BYTE_SWAPEN_FIFO2
;
2016 writeq(val64
, &vpath_reg
->kdfcctl_cfg0
);
2024 * vxge_hw_mgmt_device_config - Retrieve device configuration.
2025 * Get device configuration. Permits to retrieve at run-time configuration
2026 * values that were used to initialize and configure the device.
2029 vxge_hw_mgmt_device_config(struct __vxge_hw_device
*hldev
,
2030 struct vxge_hw_device_config
*dev_config
, int size
)
2033 if ((hldev
== NULL
) || (hldev
->magic
!= VXGE_HW_DEVICE_MAGIC
))
2034 return VXGE_HW_ERR_INVALID_DEVICE
;
2036 if (size
!= sizeof(struct vxge_hw_device_config
))
2037 return VXGE_HW_ERR_VERSION_CONFLICT
;
2039 memcpy(dev_config
, &hldev
->config
,
2040 sizeof(struct vxge_hw_device_config
));
2046 * vxge_hw_mgmt_reg_read - Read Titan register.
2049 vxge_hw_mgmt_reg_read(struct __vxge_hw_device
*hldev
,
2050 enum vxge_hw_mgmt_reg_type type
,
2051 u32 index
, u32 offset
, u64
*value
)
2053 enum vxge_hw_status status
= VXGE_HW_OK
;
2055 if ((hldev
== NULL
) || (hldev
->magic
!= VXGE_HW_DEVICE_MAGIC
)) {
2056 status
= VXGE_HW_ERR_INVALID_DEVICE
;
2061 case vxge_hw_mgmt_reg_type_legacy
:
2062 if (offset
> sizeof(struct vxge_hw_legacy_reg
) - 8) {
2063 status
= VXGE_HW_ERR_INVALID_OFFSET
;
2066 *value
= readq((void __iomem
*)hldev
->legacy_reg
+ offset
);
2068 case vxge_hw_mgmt_reg_type_toc
:
2069 if (offset
> sizeof(struct vxge_hw_toc_reg
) - 8) {
2070 status
= VXGE_HW_ERR_INVALID_OFFSET
;
2073 *value
= readq((void __iomem
*)hldev
->toc_reg
+ offset
);
2075 case vxge_hw_mgmt_reg_type_common
:
2076 if (offset
> sizeof(struct vxge_hw_common_reg
) - 8) {
2077 status
= VXGE_HW_ERR_INVALID_OFFSET
;
2080 *value
= readq((void __iomem
*)hldev
->common_reg
+ offset
);
2082 case vxge_hw_mgmt_reg_type_mrpcim
:
2083 if (!(hldev
->access_rights
&
2084 VXGE_HW_DEVICE_ACCESS_RIGHT_MRPCIM
)) {
2085 status
= VXGE_HW_ERR_PRIVILAGED_OPEARATION
;
2088 if (offset
> sizeof(struct vxge_hw_mrpcim_reg
) - 8) {
2089 status
= VXGE_HW_ERR_INVALID_OFFSET
;
2092 *value
= readq((void __iomem
*)hldev
->mrpcim_reg
+ offset
);
2094 case vxge_hw_mgmt_reg_type_srpcim
:
2095 if (!(hldev
->access_rights
&
2096 VXGE_HW_DEVICE_ACCESS_RIGHT_SRPCIM
)) {
2097 status
= VXGE_HW_ERR_PRIVILAGED_OPEARATION
;
2100 if (index
> VXGE_HW_TITAN_SRPCIM_REG_SPACES
- 1) {
2101 status
= VXGE_HW_ERR_INVALID_INDEX
;
2104 if (offset
> sizeof(struct vxge_hw_srpcim_reg
) - 8) {
2105 status
= VXGE_HW_ERR_INVALID_OFFSET
;
2108 *value
= readq((void __iomem
*)hldev
->srpcim_reg
[index
] +
2111 case vxge_hw_mgmt_reg_type_vpmgmt
:
2112 if ((index
> VXGE_HW_TITAN_VPMGMT_REG_SPACES
- 1) ||
2113 (!(hldev
->vpath_assignments
& vxge_mBIT(index
)))) {
2114 status
= VXGE_HW_ERR_INVALID_INDEX
;
2117 if (offset
> sizeof(struct vxge_hw_vpmgmt_reg
) - 8) {
2118 status
= VXGE_HW_ERR_INVALID_OFFSET
;
2121 *value
= readq((void __iomem
*)hldev
->vpmgmt_reg
[index
] +
2124 case vxge_hw_mgmt_reg_type_vpath
:
2125 if ((index
> VXGE_HW_TITAN_VPATH_REG_SPACES
- 1) ||
2126 (!(hldev
->vpath_assignments
& vxge_mBIT(index
)))) {
2127 status
= VXGE_HW_ERR_INVALID_INDEX
;
2130 if (index
> VXGE_HW_TITAN_VPATH_REG_SPACES
- 1) {
2131 status
= VXGE_HW_ERR_INVALID_INDEX
;
2134 if (offset
> sizeof(struct vxge_hw_vpath_reg
) - 8) {
2135 status
= VXGE_HW_ERR_INVALID_OFFSET
;
2138 *value
= readq((void __iomem
*)hldev
->vpath_reg
[index
] +
2142 status
= VXGE_HW_ERR_INVALID_TYPE
;
2151 * vxge_hw_vpath_strip_fcs_check - Check for FCS strip.
2154 vxge_hw_vpath_strip_fcs_check(struct __vxge_hw_device
*hldev
, u64 vpath_mask
)
2156 struct vxge_hw_vpmgmt_reg __iomem
*vpmgmt_reg
;
2157 enum vxge_hw_status status
= VXGE_HW_OK
;
2160 for (i
= 0; i
< VXGE_HW_MAX_VIRTUAL_PATHS
; i
++) {
2161 if (!((vpath_mask
) & vxge_mBIT(i
)))
2163 vpmgmt_reg
= hldev
->vpmgmt_reg
[i
];
2164 for (j
= 0; j
< VXGE_HW_MAC_MAX_MAC_PORT_ID
; j
++) {
2165 if (readq(&vpmgmt_reg
->rxmac_cfg0_port_vpmgmt_clone
[j
])
2166 & VXGE_HW_RXMAC_CFG0_PORT_VPMGMT_CLONE_STRIP_FCS
)
2167 return VXGE_HW_FAIL
;
2173 * vxge_hw_mgmt_reg_Write - Write Titan register.
2176 vxge_hw_mgmt_reg_write(struct __vxge_hw_device
*hldev
,
2177 enum vxge_hw_mgmt_reg_type type
,
2178 u32 index
, u32 offset
, u64 value
)
2180 enum vxge_hw_status status
= VXGE_HW_OK
;
2182 if ((hldev
== NULL
) || (hldev
->magic
!= VXGE_HW_DEVICE_MAGIC
)) {
2183 status
= VXGE_HW_ERR_INVALID_DEVICE
;
2188 case vxge_hw_mgmt_reg_type_legacy
:
2189 if (offset
> sizeof(struct vxge_hw_legacy_reg
) - 8) {
2190 status
= VXGE_HW_ERR_INVALID_OFFSET
;
2193 writeq(value
, (void __iomem
*)hldev
->legacy_reg
+ offset
);
2195 case vxge_hw_mgmt_reg_type_toc
:
2196 if (offset
> sizeof(struct vxge_hw_toc_reg
) - 8) {
2197 status
= VXGE_HW_ERR_INVALID_OFFSET
;
2200 writeq(value
, (void __iomem
*)hldev
->toc_reg
+ offset
);
2202 case vxge_hw_mgmt_reg_type_common
:
2203 if (offset
> sizeof(struct vxge_hw_common_reg
) - 8) {
2204 status
= VXGE_HW_ERR_INVALID_OFFSET
;
2207 writeq(value
, (void __iomem
*)hldev
->common_reg
+ offset
);
2209 case vxge_hw_mgmt_reg_type_mrpcim
:
2210 if (!(hldev
->access_rights
&
2211 VXGE_HW_DEVICE_ACCESS_RIGHT_MRPCIM
)) {
2212 status
= VXGE_HW_ERR_PRIVILAGED_OPEARATION
;
2215 if (offset
> sizeof(struct vxge_hw_mrpcim_reg
) - 8) {
2216 status
= VXGE_HW_ERR_INVALID_OFFSET
;
2219 writeq(value
, (void __iomem
*)hldev
->mrpcim_reg
+ offset
);
2221 case vxge_hw_mgmt_reg_type_srpcim
:
2222 if (!(hldev
->access_rights
&
2223 VXGE_HW_DEVICE_ACCESS_RIGHT_SRPCIM
)) {
2224 status
= VXGE_HW_ERR_PRIVILAGED_OPEARATION
;
2227 if (index
> VXGE_HW_TITAN_SRPCIM_REG_SPACES
- 1) {
2228 status
= VXGE_HW_ERR_INVALID_INDEX
;
2231 if (offset
> sizeof(struct vxge_hw_srpcim_reg
) - 8) {
2232 status
= VXGE_HW_ERR_INVALID_OFFSET
;
2235 writeq(value
, (void __iomem
*)hldev
->srpcim_reg
[index
] +
2239 case vxge_hw_mgmt_reg_type_vpmgmt
:
2240 if ((index
> VXGE_HW_TITAN_VPMGMT_REG_SPACES
- 1) ||
2241 (!(hldev
->vpath_assignments
& vxge_mBIT(index
)))) {
2242 status
= VXGE_HW_ERR_INVALID_INDEX
;
2245 if (offset
> sizeof(struct vxge_hw_vpmgmt_reg
) - 8) {
2246 status
= VXGE_HW_ERR_INVALID_OFFSET
;
2249 writeq(value
, (void __iomem
*)hldev
->vpmgmt_reg
[index
] +
2252 case vxge_hw_mgmt_reg_type_vpath
:
2253 if ((index
> VXGE_HW_TITAN_VPATH_REG_SPACES
-1) ||
2254 (!(hldev
->vpath_assignments
& vxge_mBIT(index
)))) {
2255 status
= VXGE_HW_ERR_INVALID_INDEX
;
2258 if (offset
> sizeof(struct vxge_hw_vpath_reg
) - 8) {
2259 status
= VXGE_HW_ERR_INVALID_OFFSET
;
2262 writeq(value
, (void __iomem
*)hldev
->vpath_reg
[index
] +
2266 status
= VXGE_HW_ERR_INVALID_TYPE
;
2274 * __vxge_hw_fifo_mempool_item_alloc - Allocate List blocks for TxD
2276 * This function is callback passed to __vxge_hw_mempool_create to create memory
2280 __vxge_hw_fifo_mempool_item_alloc(
2281 struct vxge_hw_mempool
*mempoolh
,
2282 u32 memblock_index
, struct vxge_hw_mempool_dma
*dma_object
,
2283 u32 index
, u32 is_last
)
2285 u32 memblock_item_idx
;
2286 struct __vxge_hw_fifo_txdl_priv
*txdl_priv
;
2287 struct vxge_hw_fifo_txd
*txdp
=
2288 (struct vxge_hw_fifo_txd
*)mempoolh
->items_arr
[index
];
2289 struct __vxge_hw_fifo
*fifo
=
2290 (struct __vxge_hw_fifo
*)mempoolh
->userdata
;
2291 void *memblock
= mempoolh
->memblocks_arr
[memblock_index
];
2295 txdp
->host_control
= (u64
) (size_t)
2296 __vxge_hw_mempool_item_priv(mempoolh
, memblock_index
, txdp
,
2297 &memblock_item_idx
);
2299 txdl_priv
= __vxge_hw_fifo_txdl_priv(fifo
, txdp
);
2301 vxge_assert(txdl_priv
);
2303 fifo
->channel
.reserve_arr
[fifo
->channel
.reserve_ptr
- 1 - index
] = txdp
;
2305 /* pre-format HW's TxDL's private */
2306 txdl_priv
->dma_offset
= (char *)txdp
- (char *)memblock
;
2307 txdl_priv
->dma_addr
= dma_object
->addr
+ txdl_priv
->dma_offset
;
2308 txdl_priv
->dma_handle
= dma_object
->handle
;
2309 txdl_priv
->memblock
= memblock
;
2310 txdl_priv
->first_txdp
= txdp
;
2311 txdl_priv
->next_txdl_priv
= NULL
;
2312 txdl_priv
->alloc_frags
= 0;
2316 * __vxge_hw_fifo_create - Create a FIFO
2317 * This function creates FIFO and initializes it.
2320 __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle
*vp
,
2321 struct vxge_hw_fifo_attr
*attr
)
2323 enum vxge_hw_status status
= VXGE_HW_OK
;
2324 struct __vxge_hw_fifo
*fifo
;
2325 struct vxge_hw_fifo_config
*config
;
2326 u32 txdl_size
, txdl_per_memblock
;
2327 struct vxge_hw_mempool_cbs fifo_mp_callback
;
2328 struct __vxge_hw_virtualpath
*vpath
;
2330 if ((vp
== NULL
) || (attr
== NULL
)) {
2331 status
= VXGE_HW_ERR_INVALID_HANDLE
;
2335 config
= &vpath
->hldev
->config
.vp_config
[vpath
->vp_id
].fifo
;
2337 txdl_size
= config
->max_frags
* sizeof(struct vxge_hw_fifo_txd
);
2339 txdl_per_memblock
= config
->memblock_size
/ txdl_size
;
2341 fifo
= (struct __vxge_hw_fifo
*)__vxge_hw_channel_allocate(vp
,
2342 VXGE_HW_CHANNEL_TYPE_FIFO
,
2343 config
->fifo_blocks
* txdl_per_memblock
,
2344 attr
->per_txdl_space
, attr
->userdata
);
2347 status
= VXGE_HW_ERR_OUT_OF_MEMORY
;
2351 vpath
->fifoh
= fifo
;
2352 fifo
->nofl_db
= vpath
->nofl_db
;
2354 fifo
->vp_id
= vpath
->vp_id
;
2355 fifo
->vp_reg
= vpath
->vp_reg
;
2356 fifo
->stats
= &vpath
->sw_stats
->fifo_stats
;
2358 fifo
->config
= config
;
2360 /* apply "interrupts per txdl" attribute */
2361 fifo
->interrupt_type
= VXGE_HW_FIFO_TXD_INT_TYPE_UTILZ
;
2363 if (fifo
->config
->intr
)
2364 fifo
->interrupt_type
= VXGE_HW_FIFO_TXD_INT_TYPE_PER_LIST
;
2366 fifo
->no_snoop_bits
= config
->no_snoop_bits
;
2369 * FIFO memory management strategy:
2371 * TxDL split into three independent parts:
2373 * - TxD HW private part
2374 * - driver private part
2376 * Adaptative memory allocation used. i.e. Memory allocated on
2377 * demand with the size which will fit into one memory block.
2378 * One memory block may contain more than one TxDL.
2380 * During "reserve" operations more memory can be allocated on demand
2381 * for example due to FIFO full condition.
2383 * Pool of memory memblocks never shrinks except in __vxge_hw_fifo_close
2384 * routine which will essentially stop the channel and free resources.
2387 /* TxDL common private size == TxDL private + driver private */
2389 sizeof(struct __vxge_hw_fifo_txdl_priv
) + attr
->per_txdl_space
;
2390 fifo
->priv_size
= ((fifo
->priv_size
+ VXGE_CACHE_LINE_SIZE
- 1) /
2391 VXGE_CACHE_LINE_SIZE
) * VXGE_CACHE_LINE_SIZE
;
2393 fifo
->per_txdl_space
= attr
->per_txdl_space
;
2395 /* recompute txdl size to be cacheline aligned */
2396 fifo
->txdl_size
= txdl_size
;
2397 fifo
->txdl_per_memblock
= txdl_per_memblock
;
2399 fifo
->txdl_term
= attr
->txdl_term
;
2400 fifo
->callback
= attr
->callback
;
2402 if (fifo
->txdl_per_memblock
== 0) {
2403 __vxge_hw_fifo_delete(vp
);
2404 status
= VXGE_HW_ERR_INVALID_BLOCK_SIZE
;
2408 fifo_mp_callback
.item_func_alloc
= __vxge_hw_fifo_mempool_item_alloc
;
2411 __vxge_hw_mempool_create(vpath
->hldev
,
2412 fifo
->config
->memblock_size
,
2415 (fifo
->config
->fifo_blocks
* fifo
->txdl_per_memblock
),
2416 (fifo
->config
->fifo_blocks
* fifo
->txdl_per_memblock
),
2420 if (fifo
->mempool
== NULL
) {
2421 __vxge_hw_fifo_delete(vp
);
2422 status
= VXGE_HW_ERR_OUT_OF_MEMORY
;
2426 status
= __vxge_hw_channel_initialize(&fifo
->channel
);
2427 if (status
!= VXGE_HW_OK
) {
2428 __vxge_hw_fifo_delete(vp
);
2432 vxge_assert(fifo
->channel
.reserve_ptr
);
2438 * __vxge_hw_fifo_abort - Returns the TxD
2439 * This function terminates the TxDs of fifo
2441 enum vxge_hw_status
__vxge_hw_fifo_abort(struct __vxge_hw_fifo
*fifo
)
2446 vxge_hw_channel_dtr_try_complete(&fifo
->channel
, &txdlh
);
2451 vxge_hw_channel_dtr_complete(&fifo
->channel
);
2453 if (fifo
->txdl_term
) {
2454 fifo
->txdl_term(txdlh
,
2455 VXGE_HW_TXDL_STATE_POSTED
,
2456 fifo
->channel
.userdata
);
2459 vxge_hw_channel_dtr_free(&fifo
->channel
, txdlh
);
2466 * __vxge_hw_fifo_reset - Resets the fifo
2467 * This function resets the fifo during vpath reset operation
2469 enum vxge_hw_status
__vxge_hw_fifo_reset(struct __vxge_hw_fifo
*fifo
)
2471 enum vxge_hw_status status
= VXGE_HW_OK
;
2473 __vxge_hw_fifo_abort(fifo
);
2474 status
= __vxge_hw_channel_reset(&fifo
->channel
);
2480 * __vxge_hw_fifo_delete - Removes the FIFO
2481 * This function freeup the memory pool and removes the FIFO
2483 enum vxge_hw_status
__vxge_hw_fifo_delete(struct __vxge_hw_vpath_handle
*vp
)
2485 struct __vxge_hw_fifo
*fifo
= vp
->vpath
->fifoh
;
2487 __vxge_hw_fifo_abort(fifo
);
2490 __vxge_hw_mempool_destroy(fifo
->mempool
);
2492 vp
->vpath
->fifoh
= NULL
;
2494 __vxge_hw_channel_free(&fifo
->channel
);
2500 * __vxge_hw_vpath_pci_read - Read the content of given address
2501 * in pci config space.
2502 * Read from the vpath pci config space.
2505 __vxge_hw_vpath_pci_read(struct __vxge_hw_virtualpath
*vpath
,
2506 u32 phy_func_0
, u32 offset
, u32
*val
)
2509 enum vxge_hw_status status
= VXGE_HW_OK
;
2510 struct vxge_hw_vpath_reg __iomem
*vp_reg
= vpath
->vp_reg
;
2512 val64
= VXGE_HW_PCI_CONFIG_ACCESS_CFG1_ADDRESS(offset
);
2515 val64
|= VXGE_HW_PCI_CONFIG_ACCESS_CFG1_SEL_FUNC0
;
2517 writeq(val64
, &vp_reg
->pci_config_access_cfg1
);
2519 writeq(VXGE_HW_PCI_CONFIG_ACCESS_CFG2_REQ
,
2520 &vp_reg
->pci_config_access_cfg2
);
2523 status
= __vxge_hw_device_register_poll(
2524 &vp_reg
->pci_config_access_cfg2
,
2525 VXGE_HW_INTR_MASK_ALL
, VXGE_HW_DEF_DEVICE_POLL_MILLIS
);
2527 if (status
!= VXGE_HW_OK
)
2530 val64
= readq(&vp_reg
->pci_config_access_status
);
2532 if (val64
& VXGE_HW_PCI_CONFIG_ACCESS_STATUS_ACCESS_ERR
) {
2533 status
= VXGE_HW_FAIL
;
2536 *val
= (u32
)vxge_bVALn(val64
, 32, 32);
2542 * __vxge_hw_vpath_func_id_get - Get the function id of the vpath.
2543 * Returns the function number of the vpath.
2546 __vxge_hw_vpath_func_id_get(u32 vp_id
,
2547 struct vxge_hw_vpmgmt_reg __iomem
*vpmgmt_reg
)
2551 val64
= readq(&vpmgmt_reg
->vpath_to_func_map_cfg1
);
2554 (u32
)VXGE_HW_VPATH_TO_FUNC_MAP_CFG1_GET_VPATH_TO_FUNC_MAP_CFG1(val64
);
2558 * __vxge_hw_read_rts_ds - Program RTS steering critieria
2561 __vxge_hw_read_rts_ds(struct vxge_hw_vpath_reg __iomem
*vpath_reg
,
2564 writeq(0, &vpath_reg
->rts_access_steer_ctrl
);
2566 writeq(dta_struct_sel
, &vpath_reg
->rts_access_steer_data0
);
2567 writeq(0, &vpath_reg
->rts_access_steer_data1
);
2573 * __vxge_hw_vpath_card_info_get - Get the serial numbers,
2574 * part number and product description.
2577 __vxge_hw_vpath_card_info_get(
2579 struct vxge_hw_vpath_reg __iomem
*vpath_reg
,
2580 struct vxge_hw_device_hw_info
*hw_info
)
2586 enum vxge_hw_status status
= VXGE_HW_OK
;
2587 u8
*serial_number
= hw_info
->serial_number
;
2588 u8
*part_number
= hw_info
->part_number
;
2589 u8
*product_desc
= hw_info
->product_desc
;
2591 __vxge_hw_read_rts_ds(vpath_reg
,
2592 VXGE_HW_RTS_ACCESS_STEER_DATA0_MEMO_ITEM_SERIAL_NUMBER
);
2594 val64
= VXGE_HW_RTS_ACCESS_STEER_CTRL_ACTION(
2595 VXGE_HW_RTS_ACCESS_STEER_CTRL_ACTION_READ_MEMO_ENTRY
) |
2596 VXGE_HW_RTS_ACCESS_STEER_CTRL_DATA_STRUCT_SEL(
2597 VXGE_HW_RTS_ACCESS_STEER_CTRL_DATA_STRUCT_SEL_FW_MEMO
) |
2598 VXGE_HW_RTS_ACCESS_STEER_CTRL_STROBE
|
2599 VXGE_HW_RTS_ACCESS_STEER_CTRL_OFFSET(0);
2601 status
= __vxge_hw_pio_mem_write64(val64
,
2602 &vpath_reg
->rts_access_steer_ctrl
,
2603 VXGE_HW_RTS_ACCESS_STEER_CTRL_STROBE
,
2604 VXGE_HW_DEF_DEVICE_POLL_MILLIS
);
2606 if (status
!= VXGE_HW_OK
)
2609 val64
= readq(&vpath_reg
->rts_access_steer_ctrl
);
2611 if (val64
& VXGE_HW_RTS_ACCESS_STEER_CTRL_RMACJ_STATUS
) {
2612 data1
= readq(&vpath_reg
->rts_access_steer_data0
);
2613 ((u64
*)serial_number
)[0] = be64_to_cpu(data1
);
2615 data2
= readq(&vpath_reg
->rts_access_steer_data1
);
2616 ((u64
*)serial_number
)[1] = be64_to_cpu(data2
);
2617 status
= VXGE_HW_OK
;
2621 __vxge_hw_read_rts_ds(vpath_reg
,
2622 VXGE_HW_RTS_ACCESS_STEER_DATA0_MEMO_ITEM_PART_NUMBER
);
2624 val64
= VXGE_HW_RTS_ACCESS_STEER_CTRL_ACTION(
2625 VXGE_HW_RTS_ACCESS_STEER_CTRL_ACTION_READ_MEMO_ENTRY
) |
2626 VXGE_HW_RTS_ACCESS_STEER_CTRL_DATA_STRUCT_SEL(
2627 VXGE_HW_RTS_ACCESS_STEER_CTRL_DATA_STRUCT_SEL_FW_MEMO
) |
2628 VXGE_HW_RTS_ACCESS_STEER_CTRL_STROBE
|
2629 VXGE_HW_RTS_ACCESS_STEER_CTRL_OFFSET(0);
2631 status
= __vxge_hw_pio_mem_write64(val64
,
2632 &vpath_reg
->rts_access_steer_ctrl
,
2633 VXGE_HW_RTS_ACCESS_STEER_CTRL_STROBE
,
2634 VXGE_HW_DEF_DEVICE_POLL_MILLIS
);
2636 if (status
!= VXGE_HW_OK
)
2639 val64
= readq(&vpath_reg
->rts_access_steer_ctrl
);
2641 if (val64
& VXGE_HW_RTS_ACCESS_STEER_CTRL_RMACJ_STATUS
) {
2643 data1
= readq(&vpath_reg
->rts_access_steer_data0
);
2644 ((u64
*)part_number
)[0] = be64_to_cpu(data1
);
2646 data2
= readq(&vpath_reg
->rts_access_steer_data1
);
2647 ((u64
*)part_number
)[1] = be64_to_cpu(data2
);
2649 status
= VXGE_HW_OK
;
2656 for (i
= VXGE_HW_RTS_ACCESS_STEER_DATA0_MEMO_ITEM_DESC_0
;
2657 i
<= VXGE_HW_RTS_ACCESS_STEER_DATA0_MEMO_ITEM_DESC_3
; i
++) {
2659 __vxge_hw_read_rts_ds(vpath_reg
, i
);
2661 val64
= VXGE_HW_RTS_ACCESS_STEER_CTRL_ACTION(
2662 VXGE_HW_RTS_ACCESS_STEER_CTRL_ACTION_READ_MEMO_ENTRY
) |
2663 VXGE_HW_RTS_ACCESS_STEER_CTRL_DATA_STRUCT_SEL(
2664 VXGE_HW_RTS_ACCESS_STEER_CTRL_DATA_STRUCT_SEL_FW_MEMO
) |
2665 VXGE_HW_RTS_ACCESS_STEER_CTRL_STROBE
|
2666 VXGE_HW_RTS_ACCESS_STEER_CTRL_OFFSET(0);
2668 status
= __vxge_hw_pio_mem_write64(val64
,
2669 &vpath_reg
->rts_access_steer_ctrl
,
2670 VXGE_HW_RTS_ACCESS_STEER_CTRL_STROBE
,
2671 VXGE_HW_DEF_DEVICE_POLL_MILLIS
);
2673 if (status
!= VXGE_HW_OK
)
2676 val64
= readq(&vpath_reg
->rts_access_steer_ctrl
);
2678 if (val64
& VXGE_HW_RTS_ACCESS_STEER_CTRL_RMACJ_STATUS
) {
2680 data1
= readq(&vpath_reg
->rts_access_steer_data0
);
2681 ((u64
*)product_desc
)[j
++] = be64_to_cpu(data1
);
2683 data2
= readq(&vpath_reg
->rts_access_steer_data1
);
2684 ((u64
*)product_desc
)[j
++] = be64_to_cpu(data2
);
2686 status
= VXGE_HW_OK
;
2695 * __vxge_hw_vpath_fw_ver_get - Get the fw version
2696 * Returns FW Version
2699 __vxge_hw_vpath_fw_ver_get(
2701 struct vxge_hw_vpath_reg __iomem
*vpath_reg
,
2702 struct vxge_hw_device_hw_info
*hw_info
)
2707 struct vxge_hw_device_version
*fw_version
= &hw_info
->fw_version
;
2708 struct vxge_hw_device_date
*fw_date
= &hw_info
->fw_date
;
2709 struct vxge_hw_device_version
*flash_version
= &hw_info
->flash_version
;
2710 struct vxge_hw_device_date
*flash_date
= &hw_info
->flash_date
;
2711 enum vxge_hw_status status
= VXGE_HW_OK
;
2713 val64
= VXGE_HW_RTS_ACCESS_STEER_CTRL_ACTION(
2714 VXGE_HW_RTS_ACCESS_STEER_CTRL_ACTION_READ_ENTRY
) |
2715 VXGE_HW_RTS_ACCESS_STEER_CTRL_DATA_STRUCT_SEL(
2716 VXGE_HW_RTS_ACCESS_STEER_CTRL_DATA_STRUCT_SEL_FW_MEMO
) |
2717 VXGE_HW_RTS_ACCESS_STEER_CTRL_STROBE
|
2718 VXGE_HW_RTS_ACCESS_STEER_CTRL_OFFSET(0);
2720 status
= __vxge_hw_pio_mem_write64(val64
,
2721 &vpath_reg
->rts_access_steer_ctrl
,
2722 VXGE_HW_RTS_ACCESS_STEER_CTRL_STROBE
,
2723 VXGE_HW_DEF_DEVICE_POLL_MILLIS
);
2725 if (status
!= VXGE_HW_OK
)
2728 val64
= readq(&vpath_reg
->rts_access_steer_ctrl
);
2730 if (val64
& VXGE_HW_RTS_ACCESS_STEER_CTRL_RMACJ_STATUS
) {
2732 data1
= readq(&vpath_reg
->rts_access_steer_data0
);
2733 data2
= readq(&vpath_reg
->rts_access_steer_data1
);
2736 (u32
)VXGE_HW_RTS_ACCESS_STEER_DATA0_GET_FW_VER_DAY(
2739 (u32
)VXGE_HW_RTS_ACCESS_STEER_DATA0_GET_FW_VER_MONTH(
2742 (u32
)VXGE_HW_RTS_ACCESS_STEER_DATA0_GET_FW_VER_YEAR(
2745 snprintf(fw_date
->date
, VXGE_HW_FW_STRLEN
, "%2.2d/%2.2d/%4.4d",
2746 fw_date
->month
, fw_date
->day
, fw_date
->year
);
2749 (u32
)VXGE_HW_RTS_ACCESS_STEER_DATA0_GET_FW_VER_MAJOR(data1
);
2751 (u32
)VXGE_HW_RTS_ACCESS_STEER_DATA0_GET_FW_VER_MINOR(data1
);
2753 (u32
)VXGE_HW_RTS_ACCESS_STEER_DATA0_GET_FW_VER_BUILD(data1
);
2755 snprintf(fw_version
->version
, VXGE_HW_FW_STRLEN
, "%d.%d.%d",
2756 fw_version
->major
, fw_version
->minor
, fw_version
->build
);
2759 (u32
)VXGE_HW_RTS_ACCESS_STEER_DATA1_GET_FLASH_VER_DAY(data2
);
2761 (u32
)VXGE_HW_RTS_ACCESS_STEER_DATA1_GET_FLASH_VER_MONTH(data2
);
2763 (u32
)VXGE_HW_RTS_ACCESS_STEER_DATA1_GET_FLASH_VER_YEAR(data2
);
2765 snprintf(flash_date
->date
, VXGE_HW_FW_STRLEN
,
2766 "%2.2d/%2.2d/%4.4d",
2767 flash_date
->month
, flash_date
->day
, flash_date
->year
);
2769 flash_version
->major
=
2770 (u32
)VXGE_HW_RTS_ACCESS_STEER_DATA1_GET_FLASH_VER_MAJOR(data2
);
2771 flash_version
->minor
=
2772 (u32
)VXGE_HW_RTS_ACCESS_STEER_DATA1_GET_FLASH_VER_MINOR(data2
);
2773 flash_version
->build
=
2774 (u32
)VXGE_HW_RTS_ACCESS_STEER_DATA1_GET_FLASH_VER_BUILD(data2
);
2776 snprintf(flash_version
->version
, VXGE_HW_FW_STRLEN
, "%d.%d.%d",
2777 flash_version
->major
, flash_version
->minor
,
2778 flash_version
->build
);
2780 status
= VXGE_HW_OK
;
2783 status
= VXGE_HW_FAIL
;
2789 * __vxge_hw_vpath_pci_func_mode_get - Get the pci mode
2790 * Returns pci function mode
2793 __vxge_hw_vpath_pci_func_mode_get(
2795 struct vxge_hw_vpath_reg __iomem
*vpath_reg
)
2799 enum vxge_hw_status status
= VXGE_HW_OK
;
2801 __vxge_hw_read_rts_ds(vpath_reg
,
2802 VXGE_HW_RTS_ACCESS_STEER_DATA0_MEMO_ITEM_PCI_MODE
);
2804 val64
= VXGE_HW_RTS_ACCESS_STEER_CTRL_ACTION(
2805 VXGE_HW_RTS_ACCESS_STEER_CTRL_ACTION_READ_MEMO_ENTRY
) |
2806 VXGE_HW_RTS_ACCESS_STEER_CTRL_DATA_STRUCT_SEL(
2807 VXGE_HW_RTS_ACCESS_STEER_CTRL_DATA_STRUCT_SEL_FW_MEMO
) |
2808 VXGE_HW_RTS_ACCESS_STEER_CTRL_STROBE
|
2809 VXGE_HW_RTS_ACCESS_STEER_CTRL_OFFSET(0);
2811 status
= __vxge_hw_pio_mem_write64(val64
,
2812 &vpath_reg
->rts_access_steer_ctrl
,
2813 VXGE_HW_RTS_ACCESS_STEER_CTRL_STROBE
,
2814 VXGE_HW_DEF_DEVICE_POLL_MILLIS
);
2816 if (status
!= VXGE_HW_OK
)
2819 val64
= readq(&vpath_reg
->rts_access_steer_ctrl
);
2821 if (val64
& VXGE_HW_RTS_ACCESS_STEER_CTRL_RMACJ_STATUS
) {
2822 data1
= readq(&vpath_reg
->rts_access_steer_data0
);
2823 status
= VXGE_HW_OK
;
2826 status
= VXGE_HW_FAIL
;
2833 * vxge_hw_device_flick_link_led - Flick (blink) link LED.
2834 * @hldev: HW device.
2835 * @on_off: TRUE if flickering to be on, FALSE to be off
2837 * Flicker the link LED.
2840 vxge_hw_device_flick_link_led(struct __vxge_hw_device
*hldev
,
2844 enum vxge_hw_status status
= VXGE_HW_OK
;
2845 struct vxge_hw_vpath_reg __iomem
*vp_reg
;
2847 if (hldev
== NULL
) {
2848 status
= VXGE_HW_ERR_INVALID_DEVICE
;
2852 vp_reg
= hldev
->vpath_reg
[hldev
->first_vp_id
];
2854 writeq(0, &vp_reg
->rts_access_steer_ctrl
);
2856 writeq(on_off
, &vp_reg
->rts_access_steer_data0
);
2857 writeq(0, &vp_reg
->rts_access_steer_data1
);
2860 val64
= VXGE_HW_RTS_ACCESS_STEER_CTRL_ACTION(
2861 VXGE_HW_RTS_ACCESS_STEER_CTRL_ACTION_LED_CONTROL
) |
2862 VXGE_HW_RTS_ACCESS_STEER_CTRL_DATA_STRUCT_SEL(
2863 VXGE_HW_RTS_ACCESS_STEER_CTRL_DATA_STRUCT_SEL_FW_MEMO
) |
2864 VXGE_HW_RTS_ACCESS_STEER_CTRL_STROBE
|
2865 VXGE_HW_RTS_ACCESS_STEER_CTRL_OFFSET(0);
2867 status
= __vxge_hw_pio_mem_write64(val64
,
2868 &vp_reg
->rts_access_steer_ctrl
,
2869 VXGE_HW_RTS_ACCESS_STEER_CTRL_STROBE
,
2870 VXGE_HW_DEF_DEVICE_POLL_MILLIS
);
2876 * __vxge_hw_vpath_rts_table_get - Get the entries from RTS access tables
2879 __vxge_hw_vpath_rts_table_get(
2880 struct __vxge_hw_vpath_handle
*vp
,
2881 u32 action
, u32 rts_table
, u32 offset
, u64
*data1
, u64
*data2
)
2884 struct __vxge_hw_virtualpath
*vpath
;
2885 struct vxge_hw_vpath_reg __iomem
*vp_reg
;
2887 enum vxge_hw_status status
= VXGE_HW_OK
;
2890 status
= VXGE_HW_ERR_INVALID_HANDLE
;
2895 vp_reg
= vpath
->vp_reg
;
2897 val64
= VXGE_HW_RTS_ACCESS_STEER_CTRL_ACTION(action
) |
2898 VXGE_HW_RTS_ACCESS_STEER_CTRL_DATA_STRUCT_SEL(rts_table
) |
2899 VXGE_HW_RTS_ACCESS_STEER_CTRL_STROBE
|
2900 VXGE_HW_RTS_ACCESS_STEER_CTRL_OFFSET(offset
);
2903 VXGE_HW_RTS_ACS_STEER_CTRL_DATA_STRUCT_SEL_RTH_SOLO_IT
) ||
2905 VXGE_HW_RTS_ACS_STEER_CTRL_DATA_STRUCT_SEL_RTH_MULTI_IT
) ||
2907 VXGE_HW_RTS_ACCESS_STEER_CTRL_DATA_STRUCT_SEL_RTH_MASK
) ||
2909 VXGE_HW_RTS_ACCESS_STEER_CTRL_DATA_STRUCT_SEL_RTH_KEY
)) {
2910 val64
= val64
| VXGE_HW_RTS_ACCESS_STEER_CTRL_TABLE_SEL
;
2913 status
= __vxge_hw_pio_mem_write64(val64
,
2914 &vp_reg
->rts_access_steer_ctrl
,
2915 VXGE_HW_RTS_ACCESS_STEER_CTRL_STROBE
,
2916 vpath
->hldev
->config
.device_poll_millis
);
2918 if (status
!= VXGE_HW_OK
)
2921 val64
= readq(&vp_reg
->rts_access_steer_ctrl
);
2923 if (val64
& VXGE_HW_RTS_ACCESS_STEER_CTRL_RMACJ_STATUS
) {
2925 *data1
= readq(&vp_reg
->rts_access_steer_data0
);
2928 VXGE_HW_RTS_ACCESS_STEER_CTRL_DATA_STRUCT_SEL_DA
) ||
2930 VXGE_HW_RTS_ACS_STEER_CTRL_DATA_STRUCT_SEL_RTH_MULTI_IT
)) {
2931 *data2
= readq(&vp_reg
->rts_access_steer_data1
);
2933 status
= VXGE_HW_OK
;
2935 status
= VXGE_HW_FAIL
;
2941 * __vxge_hw_vpath_rts_table_set - Set the entries of RTS access tables
2944 __vxge_hw_vpath_rts_table_set(
2945 struct __vxge_hw_vpath_handle
*vp
, u32 action
, u32 rts_table
,
2946 u32 offset
, u64 data1
, u64 data2
)
2949 struct __vxge_hw_virtualpath
*vpath
;
2950 enum vxge_hw_status status
= VXGE_HW_OK
;
2951 struct vxge_hw_vpath_reg __iomem
*vp_reg
;
2954 status
= VXGE_HW_ERR_INVALID_HANDLE
;
2959 vp_reg
= vpath
->vp_reg
;
2961 writeq(data1
, &vp_reg
->rts_access_steer_data0
);
2964 if ((rts_table
== VXGE_HW_RTS_ACCESS_STEER_CTRL_DATA_STRUCT_SEL_DA
) ||
2966 VXGE_HW_RTS_ACS_STEER_CTRL_DATA_STRUCT_SEL_RTH_MULTI_IT
)) {
2967 writeq(data2
, &vp_reg
->rts_access_steer_data1
);
2971 val64
= VXGE_HW_RTS_ACCESS_STEER_CTRL_ACTION(action
) |
2972 VXGE_HW_RTS_ACCESS_STEER_CTRL_DATA_STRUCT_SEL(rts_table
) |
2973 VXGE_HW_RTS_ACCESS_STEER_CTRL_STROBE
|
2974 VXGE_HW_RTS_ACCESS_STEER_CTRL_OFFSET(offset
);
2976 status
= __vxge_hw_pio_mem_write64(val64
,
2977 &vp_reg
->rts_access_steer_ctrl
,
2978 VXGE_HW_RTS_ACCESS_STEER_CTRL_STROBE
,
2979 vpath
->hldev
->config
.device_poll_millis
);
2981 if (status
!= VXGE_HW_OK
)
2984 val64
= readq(&vp_reg
->rts_access_steer_ctrl
);
2986 if (val64
& VXGE_HW_RTS_ACCESS_STEER_CTRL_RMACJ_STATUS
)
2987 status
= VXGE_HW_OK
;
2989 status
= VXGE_HW_FAIL
;
2995 * __vxge_hw_vpath_addr_get - Get the hw address entry for this vpath
2996 * from MAC address table.
2999 __vxge_hw_vpath_addr_get(
3000 u32 vp_id
, struct vxge_hw_vpath_reg __iomem
*vpath_reg
,
3001 u8 (macaddr
)[ETH_ALEN
], u8 (macaddr_mask
)[ETH_ALEN
])
3007 enum vxge_hw_status status
= VXGE_HW_OK
;
3009 val64
= VXGE_HW_RTS_ACCESS_STEER_CTRL_ACTION(
3010 VXGE_HW_RTS_ACCESS_STEER_CTRL_ACTION_LIST_FIRST_ENTRY
) |
3011 VXGE_HW_RTS_ACCESS_STEER_CTRL_DATA_STRUCT_SEL(
3012 VXGE_HW_RTS_ACCESS_STEER_CTRL_DATA_STRUCT_SEL_DA
) |
3013 VXGE_HW_RTS_ACCESS_STEER_CTRL_STROBE
|
3014 VXGE_HW_RTS_ACCESS_STEER_CTRL_OFFSET(0);
3016 status
= __vxge_hw_pio_mem_write64(val64
,
3017 &vpath_reg
->rts_access_steer_ctrl
,
3018 VXGE_HW_RTS_ACCESS_STEER_CTRL_STROBE
,
3019 VXGE_HW_DEF_DEVICE_POLL_MILLIS
);
3021 if (status
!= VXGE_HW_OK
)
3024 val64
= readq(&vpath_reg
->rts_access_steer_ctrl
);
3026 if (val64
& VXGE_HW_RTS_ACCESS_STEER_CTRL_RMACJ_STATUS
) {
3028 data1
= readq(&vpath_reg
->rts_access_steer_data0
);
3029 data2
= readq(&vpath_reg
->rts_access_steer_data1
);
3031 data1
= VXGE_HW_RTS_ACCESS_STEER_DATA0_GET_DA_MAC_ADDR(data1
);
3032 data2
= VXGE_HW_RTS_ACCESS_STEER_DATA1_GET_DA_MAC_ADDR_MASK(
3035 for (i
= ETH_ALEN
; i
> 0; i
--) {
3036 macaddr
[i
-1] = (u8
)(data1
& 0xFF);
3039 macaddr_mask
[i
-1] = (u8
)(data2
& 0xFF);
3042 status
= VXGE_HW_OK
;
3044 status
= VXGE_HW_FAIL
;
3050 * vxge_hw_vpath_rts_rth_set - Set/configure RTS hashing.
3052 enum vxge_hw_status
vxge_hw_vpath_rts_rth_set(
3053 struct __vxge_hw_vpath_handle
*vp
,
3054 enum vxge_hw_rth_algoritms algorithm
,
3055 struct vxge_hw_rth_hash_types
*hash_type
,
3059 enum vxge_hw_status status
= VXGE_HW_OK
;
3062 status
= VXGE_HW_ERR_INVALID_HANDLE
;
3066 status
= __vxge_hw_vpath_rts_table_get(vp
,
3067 VXGE_HW_RTS_ACCESS_STEER_CTRL_ACTION_READ_ENTRY
,
3068 VXGE_HW_RTS_ACCESS_STEER_CTRL_DATA_STRUCT_SEL_RTH_GEN_CFG
,
3071 data0
&= ~(VXGE_HW_RTS_ACCESS_STEER_DATA0_RTH_GEN_BUCKET_SIZE(0xf) |
3072 VXGE_HW_RTS_ACCESS_STEER_DATA0_RTH_GEN_ALG_SEL(0x3));
3074 data0
|= VXGE_HW_RTS_ACCESS_STEER_DATA0_RTH_GEN_RTH_EN
|
3075 VXGE_HW_RTS_ACCESS_STEER_DATA0_RTH_GEN_BUCKET_SIZE(bucket_size
) |
3076 VXGE_HW_RTS_ACCESS_STEER_DATA0_RTH_GEN_ALG_SEL(algorithm
);
3078 if (hash_type
->hash_type_tcpipv4_en
)
3079 data0
|= VXGE_HW_RTS_ACCESS_STEER_DATA0_RTH_GEN_RTH_TCP_IPV4_EN
;
3081 if (hash_type
->hash_type_ipv4_en
)
3082 data0
|= VXGE_HW_RTS_ACCESS_STEER_DATA0_RTH_GEN_RTH_IPV4_EN
;
3084 if (hash_type
->hash_type_tcpipv6_en
)
3085 data0
|= VXGE_HW_RTS_ACCESS_STEER_DATA0_RTH_GEN_RTH_TCP_IPV6_EN
;
3087 if (hash_type
->hash_type_ipv6_en
)
3088 data0
|= VXGE_HW_RTS_ACCESS_STEER_DATA0_RTH_GEN_RTH_IPV6_EN
;
3090 if (hash_type
->hash_type_tcpipv6ex_en
)
3092 VXGE_HW_RTS_ACCESS_STEER_DATA0_RTH_GEN_RTH_TCP_IPV6_EX_EN
;
3094 if (hash_type
->hash_type_ipv6ex_en
)
3095 data0
|= VXGE_HW_RTS_ACCESS_STEER_DATA0_RTH_GEN_RTH_IPV6_EX_EN
;
3097 if (VXGE_HW_RTS_ACCESS_STEER_DATA0_GET_RTH_GEN_ACTIVE_TABLE(data0
))
3098 data0
&= ~VXGE_HW_RTS_ACCESS_STEER_DATA0_RTH_GEN_ACTIVE_TABLE
;
3100 data0
|= VXGE_HW_RTS_ACCESS_STEER_DATA0_RTH_GEN_ACTIVE_TABLE
;
3102 status
= __vxge_hw_vpath_rts_table_set(vp
,
3103 VXGE_HW_RTS_ACCESS_STEER_CTRL_ACTION_WRITE_ENTRY
,
3104 VXGE_HW_RTS_ACCESS_STEER_CTRL_DATA_STRUCT_SEL_RTH_GEN_CFG
,
3111 vxge_hw_rts_rth_data0_data1_get(u32 j
, u64
*data0
, u64
*data1
,
3112 u16 flag
, u8
*itable
)
3116 *data0
= VXGE_HW_RTS_ACCESS_STEER_DATA0_RTH_ITEM0_BUCKET_NUM(j
)|
3117 VXGE_HW_RTS_ACCESS_STEER_DATA0_RTH_ITEM0_ENTRY_EN
|
3118 VXGE_HW_RTS_ACCESS_STEER_DATA0_RTH_ITEM0_BUCKET_DATA(
3122 VXGE_HW_RTS_ACCESS_STEER_DATA0_RTH_ITEM1_BUCKET_NUM(j
)|
3123 VXGE_HW_RTS_ACCESS_STEER_DATA0_RTH_ITEM1_ENTRY_EN
|
3124 VXGE_HW_RTS_ACCESS_STEER_DATA0_RTH_ITEM1_BUCKET_DATA(
3127 *data1
= VXGE_HW_RTS_ACCESS_STEER_DATA1_RTH_ITEM0_BUCKET_NUM(j
)|
3128 VXGE_HW_RTS_ACCESS_STEER_DATA1_RTH_ITEM0_ENTRY_EN
|
3129 VXGE_HW_RTS_ACCESS_STEER_DATA1_RTH_ITEM0_BUCKET_DATA(
3133 VXGE_HW_RTS_ACCESS_STEER_DATA1_RTH_ITEM1_BUCKET_NUM(j
)|
3134 VXGE_HW_RTS_ACCESS_STEER_DATA1_RTH_ITEM1_ENTRY_EN
|
3135 VXGE_HW_RTS_ACCESS_STEER_DATA1_RTH_ITEM1_BUCKET_DATA(
3142 * vxge_hw_vpath_rts_rth_itable_set - Set/configure indirection table (IT).
3144 enum vxge_hw_status
vxge_hw_vpath_rts_rth_itable_set(
3145 struct __vxge_hw_vpath_handle
**vpath_handles
,
3151 u32 i
, j
, action
, rts_table
;
3155 enum vxge_hw_status status
= VXGE_HW_OK
;
3156 struct __vxge_hw_vpath_handle
*vp
= vpath_handles
[0];
3159 status
= VXGE_HW_ERR_INVALID_HANDLE
;
3163 max_entries
= (((u32
)1) << itable_size
);
3165 if (vp
->vpath
->hldev
->config
.rth_it_type
3166 == VXGE_HW_RTH_IT_TYPE_SOLO_IT
) {
3167 action
= VXGE_HW_RTS_ACCESS_STEER_CTRL_ACTION_WRITE_ENTRY
;
3169 VXGE_HW_RTS_ACS_STEER_CTRL_DATA_STRUCT_SEL_RTH_SOLO_IT
;
3171 for (j
= 0; j
< max_entries
; j
++) {
3176 VXGE_HW_RTS_ACCESS_STEER_DATA0_RTH_SOLO_IT_BUCKET_DATA(
3179 status
= __vxge_hw_vpath_rts_table_set(vpath_handles
[0],
3180 action
, rts_table
, j
, data0
, data1
);
3182 if (status
!= VXGE_HW_OK
)
3186 for (j
= 0; j
< max_entries
; j
++) {
3191 VXGE_HW_RTS_ACCESS_STEER_DATA0_RTH_SOLO_IT_ENTRY_EN
|
3192 VXGE_HW_RTS_ACCESS_STEER_DATA0_RTH_SOLO_IT_BUCKET_DATA(
3195 status
= __vxge_hw_vpath_rts_table_set(
3196 vpath_handles
[mtable
[itable
[j
]]], action
,
3197 rts_table
, j
, data0
, data1
);
3199 if (status
!= VXGE_HW_OK
)
3203 action
= VXGE_HW_RTS_ACCESS_STEER_CTRL_ACTION_WRITE_ENTRY
;
3205 VXGE_HW_RTS_ACS_STEER_CTRL_DATA_STRUCT_SEL_RTH_MULTI_IT
;
3206 for (i
= 0; i
< vpath_count
; i
++) {
3208 for (j
= 0; j
< max_entries
;) {
3213 while (j
< max_entries
) {
3214 if (mtable
[itable
[j
]] != i
) {
3218 vxge_hw_rts_rth_data0_data1_get(j
,
3219 &data0
, &data1
, 1, itable
);
3224 while (j
< max_entries
) {
3225 if (mtable
[itable
[j
]] != i
) {
3229 vxge_hw_rts_rth_data0_data1_get(j
,
3230 &data0
, &data1
, 2, itable
);
3235 while (j
< max_entries
) {
3236 if (mtable
[itable
[j
]] != i
) {
3240 vxge_hw_rts_rth_data0_data1_get(j
,
3241 &data0
, &data1
, 3, itable
);
3246 while (j
< max_entries
) {
3247 if (mtable
[itable
[j
]] != i
) {
3251 vxge_hw_rts_rth_data0_data1_get(j
,
3252 &data0
, &data1
, 4, itable
);
3258 status
= __vxge_hw_vpath_rts_table_set(
3263 if (status
!= VXGE_HW_OK
)
3274 * vxge_hw_vpath_check_leak - Check for memory leak
3275 * @ringh: Handle to the ring object used for receive
3277 * If PRC_RXD_DOORBELL_VPn.NEW_QW_CNT is larger or equal to
3278 * PRC_CFG6_VPn.RXD_SPAT then a leak has occurred.
3279 * Returns: VXGE_HW_FAIL, if leak has occurred.
3283 vxge_hw_vpath_check_leak(struct __vxge_hw_ring
*ring
)
3285 enum vxge_hw_status status
= VXGE_HW_OK
;
3286 u64 rxd_new_count
, rxd_spat
;
3291 rxd_new_count
= readl(&ring
->vp_reg
->prc_rxd_doorbell
);
3292 rxd_spat
= readq(&ring
->vp_reg
->prc_cfg6
);
3293 rxd_spat
= VXGE_HW_PRC_CFG6_RXD_SPAT(rxd_spat
);
3295 if (rxd_new_count
>= rxd_spat
)
3296 status
= VXGE_HW_FAIL
;
3302 * __vxge_hw_vpath_mgmt_read
3303 * This routine reads the vpath_mgmt registers
3305 static enum vxge_hw_status
3306 __vxge_hw_vpath_mgmt_read(
3307 struct __vxge_hw_device
*hldev
,
3308 struct __vxge_hw_virtualpath
*vpath
)
3310 u32 i
, mtu
= 0, max_pyld
= 0;
3312 enum vxge_hw_status status
= VXGE_HW_OK
;
3314 for (i
= 0; i
< VXGE_HW_MAC_MAX_MAC_PORT_ID
; i
++) {
3316 val64
= readq(&vpath
->vpmgmt_reg
->
3317 rxmac_cfg0_port_vpmgmt_clone
[i
]);
3320 VXGE_HW_RXMAC_CFG0_PORT_VPMGMT_CLONE_GET_MAX_PYLD_LEN
3326 vpath
->max_mtu
= mtu
+ VXGE_HW_MAC_HEADER_MAX_SIZE
;
3328 val64
= readq(&vpath
->vpmgmt_reg
->xmac_vsport_choices_vp
);
3330 for (i
= 0; i
< VXGE_HW_MAX_VIRTUAL_PATHS
; i
++) {
3331 if (val64
& vxge_mBIT(i
))
3332 vpath
->vsport_number
= i
;
3335 val64
= readq(&vpath
->vpmgmt_reg
->xgmac_gen_status_vpmgmt_clone
);
3337 if (val64
& VXGE_HW_XGMAC_GEN_STATUS_VPMGMT_CLONE_XMACJ_NTWK_OK
)
3338 VXGE_HW_DEVICE_LINK_STATE_SET(vpath
->hldev
, VXGE_HW_LINK_UP
);
3340 VXGE_HW_DEVICE_LINK_STATE_SET(vpath
->hldev
, VXGE_HW_LINK_DOWN
);
3346 * __vxge_hw_vpath_reset_check - Check if resetting the vpath completed
3347 * This routine checks the vpath_rst_in_prog register to see if
3348 * adapter completed the reset process for the vpath
3351 __vxge_hw_vpath_reset_check(struct __vxge_hw_virtualpath
*vpath
)
3353 enum vxge_hw_status status
;
3355 status
= __vxge_hw_device_register_poll(
3356 &vpath
->hldev
->common_reg
->vpath_rst_in_prog
,
3357 VXGE_HW_VPATH_RST_IN_PROG_VPATH_RST_IN_PROG(
3358 1 << (16 - vpath
->vp_id
)),
3359 vpath
->hldev
->config
.device_poll_millis
);
3365 * __vxge_hw_vpath_reset
3366 * This routine resets the vpath on the device
3369 __vxge_hw_vpath_reset(struct __vxge_hw_device
*hldev
, u32 vp_id
)
3372 enum vxge_hw_status status
= VXGE_HW_OK
;
3374 val64
= VXGE_HW_CMN_RSTHDLR_CFG0_SW_RESET_VPATH(1 << (16 - vp_id
));
3376 __vxge_hw_pio_mem_write32_upper((u32
)vxge_bVALn(val64
, 0, 32),
3377 &hldev
->common_reg
->cmn_rsthdlr_cfg0
);
3383 * __vxge_hw_vpath_sw_reset
3384 * This routine resets the vpath structures
3387 __vxge_hw_vpath_sw_reset(struct __vxge_hw_device
*hldev
, u32 vp_id
)
3389 enum vxge_hw_status status
= VXGE_HW_OK
;
3390 struct __vxge_hw_virtualpath
*vpath
;
3392 vpath
= (struct __vxge_hw_virtualpath
*)&hldev
->virtual_paths
[vp_id
];
3395 status
= __vxge_hw_ring_reset(vpath
->ringh
);
3396 if (status
!= VXGE_HW_OK
)
3401 status
= __vxge_hw_fifo_reset(vpath
->fifoh
);
3407 * __vxge_hw_vpath_prc_configure
3408 * This routine configures the prc registers of virtual path using the config
3412 __vxge_hw_vpath_prc_configure(struct __vxge_hw_device
*hldev
, u32 vp_id
)
3415 struct __vxge_hw_virtualpath
*vpath
;
3416 struct vxge_hw_vp_config
*vp_config
;
3417 struct vxge_hw_vpath_reg __iomem
*vp_reg
;
3419 vpath
= &hldev
->virtual_paths
[vp_id
];
3420 vp_reg
= vpath
->vp_reg
;
3421 vp_config
= vpath
->vp_config
;
3423 if (vp_config
->ring
.enable
== VXGE_HW_RING_DISABLE
)
3426 val64
= readq(&vp_reg
->prc_cfg1
);
3427 val64
|= VXGE_HW_PRC_CFG1_RTI_TINT_DISABLE
;
3428 writeq(val64
, &vp_reg
->prc_cfg1
);
3430 val64
= readq(&vpath
->vp_reg
->prc_cfg6
);
3431 val64
|= VXGE_HW_PRC_CFG6_DOORBELL_MODE_EN
;
3432 writeq(val64
, &vpath
->vp_reg
->prc_cfg6
);
3434 val64
= readq(&vp_reg
->prc_cfg7
);
3436 if (vpath
->vp_config
->ring
.scatter_mode
!=
3437 VXGE_HW_RING_SCATTER_MODE_USE_FLASH_DEFAULT
) {
3439 val64
&= ~VXGE_HW_PRC_CFG7_SCATTER_MODE(0x3);
3441 switch (vpath
->vp_config
->ring
.scatter_mode
) {
3442 case VXGE_HW_RING_SCATTER_MODE_A
:
3443 val64
|= VXGE_HW_PRC_CFG7_SCATTER_MODE(
3444 VXGE_HW_PRC_CFG7_SCATTER_MODE_A
);
3446 case VXGE_HW_RING_SCATTER_MODE_B
:
3447 val64
|= VXGE_HW_PRC_CFG7_SCATTER_MODE(
3448 VXGE_HW_PRC_CFG7_SCATTER_MODE_B
);
3450 case VXGE_HW_RING_SCATTER_MODE_C
:
3451 val64
|= VXGE_HW_PRC_CFG7_SCATTER_MODE(
3452 VXGE_HW_PRC_CFG7_SCATTER_MODE_C
);
3457 writeq(val64
, &vp_reg
->prc_cfg7
);
3459 writeq(VXGE_HW_PRC_CFG5_RXD0_ADD(
3460 __vxge_hw_ring_first_block_address_get(
3461 vpath
->ringh
) >> 3), &vp_reg
->prc_cfg5
);
3463 val64
= readq(&vp_reg
->prc_cfg4
);
3464 val64
|= VXGE_HW_PRC_CFG4_IN_SVC
;
3465 val64
&= ~VXGE_HW_PRC_CFG4_RING_MODE(0x3);
3467 val64
|= VXGE_HW_PRC_CFG4_RING_MODE(
3468 VXGE_HW_PRC_CFG4_RING_MODE_ONE_BUFFER
);
3470 if (hldev
->config
.rth_en
== VXGE_HW_RTH_DISABLE
)
3471 val64
|= VXGE_HW_PRC_CFG4_RTH_DISABLE
;
3473 val64
&= ~VXGE_HW_PRC_CFG4_RTH_DISABLE
;
3475 writeq(val64
, &vp_reg
->prc_cfg4
);
3479 * __vxge_hw_vpath_kdfc_configure
3480 * This routine configures the kdfc registers of virtual path using the
3484 __vxge_hw_vpath_kdfc_configure(struct __vxge_hw_device
*hldev
, u32 vp_id
)
3488 enum vxge_hw_status status
= VXGE_HW_OK
;
3489 struct __vxge_hw_virtualpath
*vpath
;
3490 struct vxge_hw_vpath_reg __iomem
*vp_reg
;
3492 vpath
= &hldev
->virtual_paths
[vp_id
];
3493 vp_reg
= vpath
->vp_reg
;
3494 status
= __vxge_hw_kdfc_swapper_set(hldev
->legacy_reg
, vp_reg
);
3496 if (status
!= VXGE_HW_OK
)
3499 val64
= readq(&vp_reg
->kdfc_drbl_triplet_total
);
3501 vpath
->max_kdfc_db
=
3502 (u32
)VXGE_HW_KDFC_DRBL_TRIPLET_TOTAL_GET_KDFC_MAX_SIZE(
3505 if (vpath
->vp_config
->fifo
.enable
== VXGE_HW_FIFO_ENABLE
) {
3507 vpath
->max_nofl_db
= vpath
->max_kdfc_db
;
3509 if (vpath
->max_nofl_db
<
3510 ((vpath
->vp_config
->fifo
.memblock_size
/
3511 (vpath
->vp_config
->fifo
.max_frags
*
3512 sizeof(struct vxge_hw_fifo_txd
))) *
3513 vpath
->vp_config
->fifo
.fifo_blocks
)) {
3515 return VXGE_HW_BADCFG_FIFO_BLOCKS
;
3517 val64
= VXGE_HW_KDFC_FIFO_TRPL_PARTITION_LENGTH_0(
3518 (vpath
->max_nofl_db
*2)-1);
3521 writeq(val64
, &vp_reg
->kdfc_fifo_trpl_partition
);
3523 writeq(VXGE_HW_KDFC_FIFO_TRPL_CTRL_TRIPLET_ENABLE
,
3524 &vp_reg
->kdfc_fifo_trpl_ctrl
);
3526 val64
= readq(&vp_reg
->kdfc_trpl_fifo_0_ctrl
);
3528 val64
&= ~(VXGE_HW_KDFC_TRPL_FIFO_0_CTRL_MODE(0x3) |
3529 VXGE_HW_KDFC_TRPL_FIFO_0_CTRL_SELECT(0xFF));
3531 val64
|= VXGE_HW_KDFC_TRPL_FIFO_0_CTRL_MODE(
3532 VXGE_HW_KDFC_TRPL_FIFO_0_CTRL_MODE_NON_OFFLOAD_ONLY
) |
3533 #ifndef __BIG_ENDIAN
3534 VXGE_HW_KDFC_TRPL_FIFO_0_CTRL_SWAP_EN
|
3536 VXGE_HW_KDFC_TRPL_FIFO_0_CTRL_SELECT(0);
3538 writeq(val64
, &vp_reg
->kdfc_trpl_fifo_0_ctrl
);
3539 writeq((u64
)0, &vp_reg
->kdfc_trpl_fifo_0_wb_address
);
3541 vpath_stride
= readq(&hldev
->toc_reg
->toc_kdfc_vpath_stride
);
3544 (struct __vxge_hw_non_offload_db_wrapper __iomem
*)
3545 (hldev
->kdfc
+ (vp_id
*
3546 VXGE_HW_TOC_KDFC_VPATH_STRIDE_GET_TOC_KDFC_VPATH_STRIDE(
3553 * __vxge_hw_vpath_mac_configure
3554 * This routine configures the mac of virtual path using the config passed
3557 __vxge_hw_vpath_mac_configure(struct __vxge_hw_device
*hldev
, u32 vp_id
)
3560 enum vxge_hw_status status
= VXGE_HW_OK
;
3561 struct __vxge_hw_virtualpath
*vpath
;
3562 struct vxge_hw_vp_config
*vp_config
;
3563 struct vxge_hw_vpath_reg __iomem
*vp_reg
;
3565 vpath
= &hldev
->virtual_paths
[vp_id
];
3566 vp_reg
= vpath
->vp_reg
;
3567 vp_config
= vpath
->vp_config
;
3569 writeq(VXGE_HW_XMAC_VSPORT_CHOICE_VSPORT_NUMBER(
3570 vpath
->vsport_number
), &vp_reg
->xmac_vsport_choice
);
3572 if (vp_config
->ring
.enable
== VXGE_HW_RING_ENABLE
) {
3574 val64
= readq(&vp_reg
->xmac_rpa_vcfg
);
3576 if (vp_config
->rpa_strip_vlan_tag
!=
3577 VXGE_HW_VPATH_RPA_STRIP_VLAN_TAG_USE_FLASH_DEFAULT
) {
3578 if (vp_config
->rpa_strip_vlan_tag
)
3579 val64
|= VXGE_HW_XMAC_RPA_VCFG_STRIP_VLAN_TAG
;
3581 val64
&= ~VXGE_HW_XMAC_RPA_VCFG_STRIP_VLAN_TAG
;
3584 writeq(val64
, &vp_reg
->xmac_rpa_vcfg
);
3585 val64
= readq(&vp_reg
->rxmac_vcfg0
);
3587 if (vp_config
->mtu
!=
3588 VXGE_HW_VPATH_USE_FLASH_DEFAULT_INITIAL_MTU
) {
3589 val64
&= ~VXGE_HW_RXMAC_VCFG0_RTS_MAX_FRM_LEN(0x3fff);
3590 if ((vp_config
->mtu
+
3591 VXGE_HW_MAC_HEADER_MAX_SIZE
) < vpath
->max_mtu
)
3592 val64
|= VXGE_HW_RXMAC_VCFG0_RTS_MAX_FRM_LEN(
3594 VXGE_HW_MAC_HEADER_MAX_SIZE
);
3596 val64
|= VXGE_HW_RXMAC_VCFG0_RTS_MAX_FRM_LEN(
3600 writeq(val64
, &vp_reg
->rxmac_vcfg0
);
3602 val64
= readq(&vp_reg
->rxmac_vcfg1
);
3604 val64
&= ~(VXGE_HW_RXMAC_VCFG1_RTS_RTH_MULTI_IT_BD_MODE(0x3) |
3605 VXGE_HW_RXMAC_VCFG1_RTS_RTH_MULTI_IT_EN_MODE
);
3607 if (hldev
->config
.rth_it_type
==
3608 VXGE_HW_RTH_IT_TYPE_MULTI_IT
) {
3609 val64
|= VXGE_HW_RXMAC_VCFG1_RTS_RTH_MULTI_IT_BD_MODE(
3611 VXGE_HW_RXMAC_VCFG1_RTS_RTH_MULTI_IT_EN_MODE
;
3614 writeq(val64
, &vp_reg
->rxmac_vcfg1
);
3620 * __vxge_hw_vpath_tim_configure
3621 * This routine configures the tim registers of virtual path using the config
3625 __vxge_hw_vpath_tim_configure(struct __vxge_hw_device
*hldev
, u32 vp_id
)
3628 enum vxge_hw_status status
= VXGE_HW_OK
;
3629 struct __vxge_hw_virtualpath
*vpath
;
3630 struct vxge_hw_vpath_reg __iomem
*vp_reg
;
3631 struct vxge_hw_vp_config
*config
;
3633 vpath
= &hldev
->virtual_paths
[vp_id
];
3634 vp_reg
= vpath
->vp_reg
;
3635 config
= vpath
->vp_config
;
3637 writeq((u64
)0, &vp_reg
->tim_dest_addr
);
3638 writeq((u64
)0, &vp_reg
->tim_vpath_map
);
3639 writeq((u64
)0, &vp_reg
->tim_bitmap
);
3640 writeq((u64
)0, &vp_reg
->tim_remap
);
3642 if (config
->ring
.enable
== VXGE_HW_RING_ENABLE
)
3643 writeq(VXGE_HW_TIM_RING_ASSN_INT_NUM(
3644 (vp_id
* VXGE_HW_MAX_INTR_PER_VP
) +
3645 VXGE_HW_VPATH_INTR_RX
), &vp_reg
->tim_ring_assn
);
3647 val64
= readq(&vp_reg
->tim_pci_cfg
);
3648 val64
|= VXGE_HW_TIM_PCI_CFG_ADD_PAD
;
3649 writeq(val64
, &vp_reg
->tim_pci_cfg
);
3651 if (config
->fifo
.enable
== VXGE_HW_FIFO_ENABLE
) {
3653 val64
= readq(&vp_reg
->tim_cfg1_int_num
[VXGE_HW_VPATH_INTR_TX
]);
3655 if (config
->tti
.btimer_val
!= VXGE_HW_USE_FLASH_DEFAULT
) {
3656 val64
&= ~VXGE_HW_TIM_CFG1_INT_NUM_BTIMER_VAL(
3658 val64
|= VXGE_HW_TIM_CFG1_INT_NUM_BTIMER_VAL(
3659 config
->tti
.btimer_val
);
3662 val64
&= ~VXGE_HW_TIM_CFG1_INT_NUM_BITMP_EN
;
3664 if (config
->tti
.timer_ac_en
!= VXGE_HW_USE_FLASH_DEFAULT
) {
3665 if (config
->tti
.timer_ac_en
)
3666 val64
|= VXGE_HW_TIM_CFG1_INT_NUM_TIMER_AC
;
3668 val64
&= ~VXGE_HW_TIM_CFG1_INT_NUM_TIMER_AC
;
3671 if (config
->tti
.timer_ci_en
!= VXGE_HW_USE_FLASH_DEFAULT
) {
3672 if (config
->tti
.timer_ci_en
)
3673 val64
|= VXGE_HW_TIM_CFG1_INT_NUM_TIMER_CI
;
3675 val64
&= ~VXGE_HW_TIM_CFG1_INT_NUM_TIMER_CI
;
3678 if (config
->tti
.urange_a
!= VXGE_HW_USE_FLASH_DEFAULT
) {
3679 val64
&= ~VXGE_HW_TIM_CFG1_INT_NUM_URNG_A(0x3f);
3680 val64
|= VXGE_HW_TIM_CFG1_INT_NUM_URNG_A(
3681 config
->tti
.urange_a
);
3684 if (config
->tti
.urange_b
!= VXGE_HW_USE_FLASH_DEFAULT
) {
3685 val64
&= ~VXGE_HW_TIM_CFG1_INT_NUM_URNG_B(0x3f);
3686 val64
|= VXGE_HW_TIM_CFG1_INT_NUM_URNG_B(
3687 config
->tti
.urange_b
);
3690 if (config
->tti
.urange_c
!= VXGE_HW_USE_FLASH_DEFAULT
) {
3691 val64
&= ~VXGE_HW_TIM_CFG1_INT_NUM_URNG_C(0x3f);
3692 val64
|= VXGE_HW_TIM_CFG1_INT_NUM_URNG_C(
3693 config
->tti
.urange_c
);
3696 writeq(val64
, &vp_reg
->tim_cfg1_int_num
[VXGE_HW_VPATH_INTR_TX
]);
3697 val64
= readq(&vp_reg
->tim_cfg2_int_num
[VXGE_HW_VPATH_INTR_TX
]);
3699 if (config
->tti
.uec_a
!= VXGE_HW_USE_FLASH_DEFAULT
) {
3700 val64
&= ~VXGE_HW_TIM_CFG2_INT_NUM_UEC_A(0xffff);
3701 val64
|= VXGE_HW_TIM_CFG2_INT_NUM_UEC_A(
3705 if (config
->tti
.uec_b
!= VXGE_HW_USE_FLASH_DEFAULT
) {
3706 val64
&= ~VXGE_HW_TIM_CFG2_INT_NUM_UEC_B(0xffff);
3707 val64
|= VXGE_HW_TIM_CFG2_INT_NUM_UEC_B(
3711 if (config
->tti
.uec_c
!= VXGE_HW_USE_FLASH_DEFAULT
) {
3712 val64
&= ~VXGE_HW_TIM_CFG2_INT_NUM_UEC_C(0xffff);
3713 val64
|= VXGE_HW_TIM_CFG2_INT_NUM_UEC_C(
3717 if (config
->tti
.uec_d
!= VXGE_HW_USE_FLASH_DEFAULT
) {
3718 val64
&= ~VXGE_HW_TIM_CFG2_INT_NUM_UEC_D(0xffff);
3719 val64
|= VXGE_HW_TIM_CFG2_INT_NUM_UEC_D(
3723 writeq(val64
, &vp_reg
->tim_cfg2_int_num
[VXGE_HW_VPATH_INTR_TX
]);
3724 val64
= readq(&vp_reg
->tim_cfg3_int_num
[VXGE_HW_VPATH_INTR_TX
]);
3726 if (config
->tti
.timer_ri_en
!= VXGE_HW_USE_FLASH_DEFAULT
) {
3727 if (config
->tti
.timer_ri_en
)
3728 val64
|= VXGE_HW_TIM_CFG3_INT_NUM_TIMER_RI
;
3730 val64
&= ~VXGE_HW_TIM_CFG3_INT_NUM_TIMER_RI
;
3733 if (config
->tti
.rtimer_val
!= VXGE_HW_USE_FLASH_DEFAULT
) {
3734 val64
&= ~VXGE_HW_TIM_CFG3_INT_NUM_RTIMER_VAL(
3736 val64
|= VXGE_HW_TIM_CFG3_INT_NUM_RTIMER_VAL(
3737 config
->tti
.rtimer_val
);
3740 if (config
->tti
.util_sel
!= VXGE_HW_USE_FLASH_DEFAULT
) {
3741 val64
&= ~VXGE_HW_TIM_CFG3_INT_NUM_UTIL_SEL(0x3f);
3742 val64
|= VXGE_HW_TIM_CFG3_INT_NUM_UTIL_SEL(
3743 config
->tti
.util_sel
);
3746 if (config
->tti
.ltimer_val
!= VXGE_HW_USE_FLASH_DEFAULT
) {
3747 val64
&= ~VXGE_HW_TIM_CFG3_INT_NUM_LTIMER_VAL(
3749 val64
|= VXGE_HW_TIM_CFG3_INT_NUM_LTIMER_VAL(
3750 config
->tti
.ltimer_val
);
3753 writeq(val64
, &vp_reg
->tim_cfg3_int_num
[VXGE_HW_VPATH_INTR_TX
]);
3756 if (config
->ring
.enable
== VXGE_HW_RING_ENABLE
) {
3758 val64
= readq(&vp_reg
->tim_cfg1_int_num
[VXGE_HW_VPATH_INTR_RX
]);
3760 if (config
->rti
.btimer_val
!= VXGE_HW_USE_FLASH_DEFAULT
) {
3761 val64
&= ~VXGE_HW_TIM_CFG1_INT_NUM_BTIMER_VAL(
3763 val64
|= VXGE_HW_TIM_CFG1_INT_NUM_BTIMER_VAL(
3764 config
->rti
.btimer_val
);
3767 val64
&= ~VXGE_HW_TIM_CFG1_INT_NUM_BITMP_EN
;
3769 if (config
->rti
.timer_ac_en
!= VXGE_HW_USE_FLASH_DEFAULT
) {
3770 if (config
->rti
.timer_ac_en
)
3771 val64
|= VXGE_HW_TIM_CFG1_INT_NUM_TIMER_AC
;
3773 val64
&= ~VXGE_HW_TIM_CFG1_INT_NUM_TIMER_AC
;
3776 if (config
->rti
.timer_ci_en
!= VXGE_HW_USE_FLASH_DEFAULT
) {
3777 if (config
->rti
.timer_ci_en
)
3778 val64
|= VXGE_HW_TIM_CFG1_INT_NUM_TIMER_CI
;
3780 val64
&= ~VXGE_HW_TIM_CFG1_INT_NUM_TIMER_CI
;
3783 if (config
->rti
.urange_a
!= VXGE_HW_USE_FLASH_DEFAULT
) {
3784 val64
&= ~VXGE_HW_TIM_CFG1_INT_NUM_URNG_A(0x3f);
3785 val64
|= VXGE_HW_TIM_CFG1_INT_NUM_URNG_A(
3786 config
->rti
.urange_a
);
3789 if (config
->rti
.urange_b
!= VXGE_HW_USE_FLASH_DEFAULT
) {
3790 val64
&= ~VXGE_HW_TIM_CFG1_INT_NUM_URNG_B(0x3f);
3791 val64
|= VXGE_HW_TIM_CFG1_INT_NUM_URNG_B(
3792 config
->rti
.urange_b
);
3795 if (config
->rti
.urange_c
!= VXGE_HW_USE_FLASH_DEFAULT
) {
3796 val64
&= ~VXGE_HW_TIM_CFG1_INT_NUM_URNG_C(0x3f);
3797 val64
|= VXGE_HW_TIM_CFG1_INT_NUM_URNG_C(
3798 config
->rti
.urange_c
);
3801 writeq(val64
, &vp_reg
->tim_cfg1_int_num
[VXGE_HW_VPATH_INTR_RX
]);
3802 val64
= readq(&vp_reg
->tim_cfg2_int_num
[VXGE_HW_VPATH_INTR_RX
]);
3804 if (config
->rti
.uec_a
!= VXGE_HW_USE_FLASH_DEFAULT
) {
3805 val64
&= ~VXGE_HW_TIM_CFG2_INT_NUM_UEC_A(0xffff);
3806 val64
|= VXGE_HW_TIM_CFG2_INT_NUM_UEC_A(
3810 if (config
->rti
.uec_b
!= VXGE_HW_USE_FLASH_DEFAULT
) {
3811 val64
&= ~VXGE_HW_TIM_CFG2_INT_NUM_UEC_B(0xffff);
3812 val64
|= VXGE_HW_TIM_CFG2_INT_NUM_UEC_B(
3816 if (config
->rti
.uec_c
!= VXGE_HW_USE_FLASH_DEFAULT
) {
3817 val64
&= ~VXGE_HW_TIM_CFG2_INT_NUM_UEC_C(0xffff);
3818 val64
|= VXGE_HW_TIM_CFG2_INT_NUM_UEC_C(
3822 if (config
->rti
.uec_d
!= VXGE_HW_USE_FLASH_DEFAULT
) {
3823 val64
&= ~VXGE_HW_TIM_CFG2_INT_NUM_UEC_D(0xffff);
3824 val64
|= VXGE_HW_TIM_CFG2_INT_NUM_UEC_D(
3828 writeq(val64
, &vp_reg
->tim_cfg2_int_num
[VXGE_HW_VPATH_INTR_RX
]);
3829 val64
= readq(&vp_reg
->tim_cfg3_int_num
[VXGE_HW_VPATH_INTR_RX
]);
3831 if (config
->rti
.timer_ri_en
!= VXGE_HW_USE_FLASH_DEFAULT
) {
3832 if (config
->rti
.timer_ri_en
)
3833 val64
|= VXGE_HW_TIM_CFG3_INT_NUM_TIMER_RI
;
3835 val64
&= ~VXGE_HW_TIM_CFG3_INT_NUM_TIMER_RI
;
3838 if (config
->rti
.rtimer_val
!= VXGE_HW_USE_FLASH_DEFAULT
) {
3839 val64
&= ~VXGE_HW_TIM_CFG3_INT_NUM_RTIMER_VAL(
3841 val64
|= VXGE_HW_TIM_CFG3_INT_NUM_RTIMER_VAL(
3842 config
->rti
.rtimer_val
);
3845 if (config
->rti
.util_sel
!= VXGE_HW_USE_FLASH_DEFAULT
) {
3846 val64
&= ~VXGE_HW_TIM_CFG3_INT_NUM_UTIL_SEL(0x3f);
3847 val64
|= VXGE_HW_TIM_CFG3_INT_NUM_UTIL_SEL(
3848 config
->rti
.util_sel
);
3851 if (config
->rti
.ltimer_val
!= VXGE_HW_USE_FLASH_DEFAULT
) {
3852 val64
&= ~VXGE_HW_TIM_CFG3_INT_NUM_LTIMER_VAL(
3854 val64
|= VXGE_HW_TIM_CFG3_INT_NUM_LTIMER_VAL(
3855 config
->rti
.ltimer_val
);
3858 writeq(val64
, &vp_reg
->tim_cfg3_int_num
[VXGE_HW_VPATH_INTR_RX
]);
3862 writeq(val64
, &vp_reg
->tim_cfg1_int_num
[VXGE_HW_VPATH_INTR_EINTA
]);
3863 writeq(val64
, &vp_reg
->tim_cfg2_int_num
[VXGE_HW_VPATH_INTR_EINTA
]);
3864 writeq(val64
, &vp_reg
->tim_cfg3_int_num
[VXGE_HW_VPATH_INTR_EINTA
]);
3865 writeq(val64
, &vp_reg
->tim_cfg1_int_num
[VXGE_HW_VPATH_INTR_BMAP
]);
3866 writeq(val64
, &vp_reg
->tim_cfg2_int_num
[VXGE_HW_VPATH_INTR_BMAP
]);
3867 writeq(val64
, &vp_reg
->tim_cfg3_int_num
[VXGE_HW_VPATH_INTR_BMAP
]);
3873 vxge_hw_vpath_tti_ci_set(struct __vxge_hw_device
*hldev
, u32 vp_id
)
3875 struct __vxge_hw_virtualpath
*vpath
;
3876 struct vxge_hw_vpath_reg __iomem
*vp_reg
;
3877 struct vxge_hw_vp_config
*config
;
3880 vpath
= &hldev
->virtual_paths
[vp_id
];
3881 vp_reg
= vpath
->vp_reg
;
3882 config
= vpath
->vp_config
;
3884 if (config
->fifo
.enable
== VXGE_HW_FIFO_ENABLE
) {
3885 val64
= readq(&vp_reg
->tim_cfg1_int_num
[VXGE_HW_VPATH_INTR_TX
]);
3887 if (config
->tti
.timer_ci_en
!= VXGE_HW_TIM_TIMER_CI_ENABLE
) {
3888 config
->tti
.timer_ci_en
= VXGE_HW_TIM_TIMER_CI_ENABLE
;
3889 val64
|= VXGE_HW_TIM_CFG1_INT_NUM_TIMER_CI
;
3891 &vp_reg
->tim_cfg1_int_num
[VXGE_HW_VPATH_INTR_TX
]);
3896 * __vxge_hw_vpath_initialize
3897 * This routine is the final phase of init which initializes the
3898 * registers of the vpath using the configuration passed.
3901 __vxge_hw_vpath_initialize(struct __vxge_hw_device
*hldev
, u32 vp_id
)
3905 enum vxge_hw_status status
= VXGE_HW_OK
;
3906 struct __vxge_hw_virtualpath
*vpath
;
3907 struct vxge_hw_vpath_reg __iomem
*vp_reg
;
3909 vpath
= &hldev
->virtual_paths
[vp_id
];
3911 if (!(hldev
->vpath_assignments
& vxge_mBIT(vp_id
))) {
3912 status
= VXGE_HW_ERR_VPATH_NOT_AVAILABLE
;
3915 vp_reg
= vpath
->vp_reg
;
3917 status
= __vxge_hw_vpath_swapper_set(vpath
->vp_reg
);
3919 if (status
!= VXGE_HW_OK
)
3922 status
= __vxge_hw_vpath_mac_configure(hldev
, vp_id
);
3924 if (status
!= VXGE_HW_OK
)
3927 status
= __vxge_hw_vpath_kdfc_configure(hldev
, vp_id
);
3929 if (status
!= VXGE_HW_OK
)
3932 status
= __vxge_hw_vpath_tim_configure(hldev
, vp_id
);
3934 if (status
!= VXGE_HW_OK
)
3937 val64
= readq(&vp_reg
->rtdma_rd_optimization_ctrl
);
3939 /* Get MRRS value from device control */
3940 status
= __vxge_hw_vpath_pci_read(vpath
, 1, 0x78, &val32
);
3942 if (status
== VXGE_HW_OK
) {
3943 val32
= (val32
& VXGE_HW_PCI_EXP_DEVCTL_READRQ
) >> 12;
3945 ~(VXGE_HW_RTDMA_RD_OPTIMIZATION_CTRL_FB_FILL_THRESH(7));
3947 VXGE_HW_RTDMA_RD_OPTIMIZATION_CTRL_FB_FILL_THRESH(val32
);
3949 val64
|= VXGE_HW_RTDMA_RD_OPTIMIZATION_CTRL_FB_WAIT_FOR_SPACE
;
3952 val64
&= ~(VXGE_HW_RTDMA_RD_OPTIMIZATION_CTRL_FB_ADDR_BDRY(7));
3954 VXGE_HW_RTDMA_RD_OPTIMIZATION_CTRL_FB_ADDR_BDRY(
3955 VXGE_HW_MAX_PAYLOAD_SIZE_512
);
3957 val64
|= VXGE_HW_RTDMA_RD_OPTIMIZATION_CTRL_FB_ADDR_BDRY_EN
;
3958 writeq(val64
, &vp_reg
->rtdma_rd_optimization_ctrl
);
3965 * __vxge_hw_vp_initialize - Initialize Virtual Path structure
3966 * This routine is the initial phase of init which resets the vpath and
3967 * initializes the software support structures.
3970 __vxge_hw_vp_initialize(struct __vxge_hw_device
*hldev
, u32 vp_id
,
3971 struct vxge_hw_vp_config
*config
)
3973 struct __vxge_hw_virtualpath
*vpath
;
3974 enum vxge_hw_status status
= VXGE_HW_OK
;
3976 if (!(hldev
->vpath_assignments
& vxge_mBIT(vp_id
))) {
3977 status
= VXGE_HW_ERR_VPATH_NOT_AVAILABLE
;
3981 vpath
= &hldev
->virtual_paths
[vp_id
];
3983 vpath
->vp_id
= vp_id
;
3984 vpath
->vp_open
= VXGE_HW_VP_OPEN
;
3985 vpath
->hldev
= hldev
;
3986 vpath
->vp_config
= config
;
3987 vpath
->vp_reg
= hldev
->vpath_reg
[vp_id
];
3988 vpath
->vpmgmt_reg
= hldev
->vpmgmt_reg
[vp_id
];
3990 __vxge_hw_vpath_reset(hldev
, vp_id
);
3992 status
= __vxge_hw_vpath_reset_check(vpath
);
3994 if (status
!= VXGE_HW_OK
) {
3995 memset(vpath
, 0, sizeof(struct __vxge_hw_virtualpath
));
3999 status
= __vxge_hw_vpath_mgmt_read(hldev
, vpath
);
4001 if (status
!= VXGE_HW_OK
) {
4002 memset(vpath
, 0, sizeof(struct __vxge_hw_virtualpath
));
4006 INIT_LIST_HEAD(&vpath
->vpath_handles
);
4008 vpath
->sw_stats
= &hldev
->stats
.sw_dev_info_stats
.vpath_info
[vp_id
];
4010 VXGE_HW_DEVICE_TIM_INT_MASK_SET(hldev
->tim_int_mask0
,
4011 hldev
->tim_int_mask1
, vp_id
);
4013 status
= __vxge_hw_vpath_initialize(hldev
, vp_id
);
4015 if (status
!= VXGE_HW_OK
)
4016 __vxge_hw_vp_terminate(hldev
, vp_id
);
4022 * __vxge_hw_vp_terminate - Terminate Virtual Path structure
4023 * This routine closes all channels it opened and freeup memory
4026 __vxge_hw_vp_terminate(struct __vxge_hw_device
*hldev
, u32 vp_id
)
4028 struct __vxge_hw_virtualpath
*vpath
;
4030 vpath
= &hldev
->virtual_paths
[vp_id
];
4032 if (vpath
->vp_open
== VXGE_HW_VP_NOT_OPEN
)
4035 VXGE_HW_DEVICE_TIM_INT_MASK_RESET(vpath
->hldev
->tim_int_mask0
,
4036 vpath
->hldev
->tim_int_mask1
, vpath
->vp_id
);
4037 hldev
->stats
.hw_dev_info_stats
.vpath_info
[vpath
->vp_id
] = NULL
;
4039 memset(vpath
, 0, sizeof(struct __vxge_hw_virtualpath
));
4045 * vxge_hw_vpath_mtu_set - Set MTU.
4046 * Set new MTU value. Example, to use jumbo frames:
4047 * vxge_hw_vpath_mtu_set(my_device, 9600);
4050 vxge_hw_vpath_mtu_set(struct __vxge_hw_vpath_handle
*vp
, u32 new_mtu
)
4053 enum vxge_hw_status status
= VXGE_HW_OK
;
4054 struct __vxge_hw_virtualpath
*vpath
;
4057 status
= VXGE_HW_ERR_INVALID_HANDLE
;
4062 new_mtu
+= VXGE_HW_MAC_HEADER_MAX_SIZE
;
4064 if ((new_mtu
< VXGE_HW_MIN_MTU
) || (new_mtu
> vpath
->max_mtu
))
4065 status
= VXGE_HW_ERR_INVALID_MTU_SIZE
;
4067 val64
= readq(&vpath
->vp_reg
->rxmac_vcfg0
);
4069 val64
&= ~VXGE_HW_RXMAC_VCFG0_RTS_MAX_FRM_LEN(0x3fff);
4070 val64
|= VXGE_HW_RXMAC_VCFG0_RTS_MAX_FRM_LEN(new_mtu
);
4072 writeq(val64
, &vpath
->vp_reg
->rxmac_vcfg0
);
4074 vpath
->vp_config
->mtu
= new_mtu
- VXGE_HW_MAC_HEADER_MAX_SIZE
;
4081 * vxge_hw_vpath_open - Open a virtual path on a given adapter
4082 * This function is used to open access to virtual path of an
4083 * adapter for offload, GRO operations. This function returns
4087 vxge_hw_vpath_open(struct __vxge_hw_device
*hldev
,
4088 struct vxge_hw_vpath_attr
*attr
,
4089 struct __vxge_hw_vpath_handle
**vpath_handle
)
4091 struct __vxge_hw_virtualpath
*vpath
;
4092 struct __vxge_hw_vpath_handle
*vp
;
4093 enum vxge_hw_status status
;
4095 vpath
= &hldev
->virtual_paths
[attr
->vp_id
];
4097 if (vpath
->vp_open
== VXGE_HW_VP_OPEN
) {
4098 status
= VXGE_HW_ERR_INVALID_STATE
;
4099 goto vpath_open_exit1
;
4102 status
= __vxge_hw_vp_initialize(hldev
, attr
->vp_id
,
4103 &hldev
->config
.vp_config
[attr
->vp_id
]);
4105 if (status
!= VXGE_HW_OK
)
4106 goto vpath_open_exit1
;
4108 vp
= (struct __vxge_hw_vpath_handle
*)
4109 vmalloc(sizeof(struct __vxge_hw_vpath_handle
));
4111 status
= VXGE_HW_ERR_OUT_OF_MEMORY
;
4112 goto vpath_open_exit2
;
4115 memset(vp
, 0, sizeof(struct __vxge_hw_vpath_handle
));
4119 if (vpath
->vp_config
->fifo
.enable
== VXGE_HW_FIFO_ENABLE
) {
4120 status
= __vxge_hw_fifo_create(vp
, &attr
->fifo_attr
);
4121 if (status
!= VXGE_HW_OK
)
4122 goto vpath_open_exit6
;
4125 if (vpath
->vp_config
->ring
.enable
== VXGE_HW_RING_ENABLE
) {
4126 status
= __vxge_hw_ring_create(vp
, &attr
->ring_attr
);
4127 if (status
!= VXGE_HW_OK
)
4128 goto vpath_open_exit7
;
4130 __vxge_hw_vpath_prc_configure(hldev
, attr
->vp_id
);
4133 vpath
->fifoh
->tx_intr_num
=
4134 (attr
->vp_id
* VXGE_HW_MAX_INTR_PER_VP
) +
4135 VXGE_HW_VPATH_INTR_TX
;
4137 vpath
->stats_block
= __vxge_hw_blockpool_block_allocate(hldev
,
4138 VXGE_HW_BLOCK_SIZE
);
4140 if (vpath
->stats_block
== NULL
) {
4141 status
= VXGE_HW_ERR_OUT_OF_MEMORY
;
4142 goto vpath_open_exit8
;
4145 vpath
->hw_stats
= (struct vxge_hw_vpath_stats_hw_info
*)vpath
->
4146 stats_block
->memblock
;
4147 memset(vpath
->hw_stats
, 0,
4148 sizeof(struct vxge_hw_vpath_stats_hw_info
));
4150 hldev
->stats
.hw_dev_info_stats
.vpath_info
[attr
->vp_id
] =
4153 vpath
->hw_stats_sav
=
4154 &hldev
->stats
.hw_dev_info_stats
.vpath_info_sav
[attr
->vp_id
];
4155 memset(vpath
->hw_stats_sav
, 0,
4156 sizeof(struct vxge_hw_vpath_stats_hw_info
));
4158 writeq(vpath
->stats_block
->dma_addr
, &vpath
->vp_reg
->stats_cfg
);
4160 status
= vxge_hw_vpath_stats_enable(vp
);
4161 if (status
!= VXGE_HW_OK
)
4162 goto vpath_open_exit8
;
4164 list_add(&vp
->item
, &vpath
->vpath_handles
);
4166 hldev
->vpaths_deployed
|= vxge_mBIT(vpath
->vp_id
);
4170 attr
->fifo_attr
.userdata
= vpath
->fifoh
;
4171 attr
->ring_attr
.userdata
= vpath
->ringh
;
4176 if (vpath
->ringh
!= NULL
)
4177 __vxge_hw_ring_delete(vp
);
4179 if (vpath
->fifoh
!= NULL
)
4180 __vxge_hw_fifo_delete(vp
);
4184 __vxge_hw_vp_terminate(hldev
, attr
->vp_id
);
4191 * vxge_hw_vpath_rx_doorbell_post - Close the handle got from previous vpath
4193 * @vp: Handle got from previous vpath open
4195 * This function is used to close access to virtual path opened
4199 vxge_hw_vpath_rx_doorbell_init(struct __vxge_hw_vpath_handle
*vp
)
4201 struct __vxge_hw_virtualpath
*vpath
= NULL
;
4202 u64 new_count
, val64
, val164
;
4203 struct __vxge_hw_ring
*ring
;
4206 ring
= vpath
->ringh
;
4208 new_count
= readq(&vpath
->vp_reg
->rxdmem_size
);
4209 new_count
&= 0x1fff;
4210 val164
= (VXGE_HW_RXDMEM_SIZE_PRC_RXDMEM_SIZE(new_count
));
4212 writeq(VXGE_HW_PRC_RXD_DOORBELL_NEW_QW_CNT(val164
),
4213 &vpath
->vp_reg
->prc_rxd_doorbell
);
4214 readl(&vpath
->vp_reg
->prc_rxd_doorbell
);
4217 val64
= readq(&vpath
->vp_reg
->prc_cfg6
);
4218 val64
= VXGE_HW_PRC_CFG6_RXD_SPAT(val64
);
4222 * Each RxD is of 4 qwords
4224 new_count
-= (val64
+ 1);
4225 val64
= min(val164
, new_count
) / 4;
4227 ring
->rxds_limit
= min(ring
->rxds_limit
, val64
);
4228 if (ring
->rxds_limit
< 4)
4229 ring
->rxds_limit
= 4;
4233 * vxge_hw_vpath_close - Close the handle got from previous vpath (vpath) open
4234 * This function is used to close access to virtual path opened
4237 enum vxge_hw_status
vxge_hw_vpath_close(struct __vxge_hw_vpath_handle
*vp
)
4239 struct __vxge_hw_virtualpath
*vpath
= NULL
;
4240 struct __vxge_hw_device
*devh
= NULL
;
4241 u32 vp_id
= vp
->vpath
->vp_id
;
4242 u32 is_empty
= TRUE
;
4243 enum vxge_hw_status status
= VXGE_HW_OK
;
4246 devh
= vpath
->hldev
;
4248 if (vpath
->vp_open
== VXGE_HW_VP_NOT_OPEN
) {
4249 status
= VXGE_HW_ERR_VPATH_NOT_OPEN
;
4250 goto vpath_close_exit
;
4253 list_del(&vp
->item
);
4255 if (!list_empty(&vpath
->vpath_handles
)) {
4256 list_add(&vp
->item
, &vpath
->vpath_handles
);
4261 status
= VXGE_HW_FAIL
;
4262 goto vpath_close_exit
;
4265 devh
->vpaths_deployed
&= ~vxge_mBIT(vp_id
);
4267 if (vpath
->ringh
!= NULL
)
4268 __vxge_hw_ring_delete(vp
);
4270 if (vpath
->fifoh
!= NULL
)
4271 __vxge_hw_fifo_delete(vp
);
4273 if (vpath
->stats_block
!= NULL
)
4274 __vxge_hw_blockpool_block_free(devh
, vpath
->stats_block
);
4278 __vxge_hw_vp_terminate(devh
, vp_id
);
4280 vpath
->vp_open
= VXGE_HW_VP_NOT_OPEN
;
4287 * vxge_hw_vpath_reset - Resets vpath
4288 * This function is used to request a reset of vpath
4290 enum vxge_hw_status
vxge_hw_vpath_reset(struct __vxge_hw_vpath_handle
*vp
)
4292 enum vxge_hw_status status
;
4294 struct __vxge_hw_virtualpath
*vpath
= vp
->vpath
;
4296 vp_id
= vpath
->vp_id
;
4298 if (vpath
->vp_open
== VXGE_HW_VP_NOT_OPEN
) {
4299 status
= VXGE_HW_ERR_VPATH_NOT_OPEN
;
4303 status
= __vxge_hw_vpath_reset(vpath
->hldev
, vp_id
);
4304 if (status
== VXGE_HW_OK
)
4305 vpath
->sw_stats
->soft_reset_cnt
++;
4311 * vxge_hw_vpath_recover_from_reset - Poll for reset complete and re-initialize.
4312 * This function poll's for the vpath reset completion and re initializes
4316 vxge_hw_vpath_recover_from_reset(struct __vxge_hw_vpath_handle
*vp
)
4318 struct __vxge_hw_virtualpath
*vpath
= NULL
;
4319 enum vxge_hw_status status
;
4320 struct __vxge_hw_device
*hldev
;
4323 vp_id
= vp
->vpath
->vp_id
;
4325 hldev
= vpath
->hldev
;
4327 if (vpath
->vp_open
== VXGE_HW_VP_NOT_OPEN
) {
4328 status
= VXGE_HW_ERR_VPATH_NOT_OPEN
;
4332 status
= __vxge_hw_vpath_reset_check(vpath
);
4333 if (status
!= VXGE_HW_OK
)
4336 status
= __vxge_hw_vpath_sw_reset(hldev
, vp_id
);
4337 if (status
!= VXGE_HW_OK
)
4340 status
= __vxge_hw_vpath_initialize(hldev
, vp_id
);
4341 if (status
!= VXGE_HW_OK
)
4344 if (vpath
->ringh
!= NULL
)
4345 __vxge_hw_vpath_prc_configure(hldev
, vp_id
);
4347 memset(vpath
->hw_stats
, 0,
4348 sizeof(struct vxge_hw_vpath_stats_hw_info
));
4350 memset(vpath
->hw_stats_sav
, 0,
4351 sizeof(struct vxge_hw_vpath_stats_hw_info
));
4353 writeq(vpath
->stats_block
->dma_addr
,
4354 &vpath
->vp_reg
->stats_cfg
);
4356 status
= vxge_hw_vpath_stats_enable(vp
);
4363 * vxge_hw_vpath_enable - Enable vpath.
4364 * This routine clears the vpath reset thereby enabling a vpath
4365 * to start forwarding frames and generating interrupts.
4368 vxge_hw_vpath_enable(struct __vxge_hw_vpath_handle
*vp
)
4370 struct __vxge_hw_device
*hldev
;
4373 hldev
= vp
->vpath
->hldev
;
4375 val64
= VXGE_HW_CMN_RSTHDLR_CFG1_CLR_VPATH_RESET(
4376 1 << (16 - vp
->vpath
->vp_id
));
4378 __vxge_hw_pio_mem_write32_upper((u32
)vxge_bVALn(val64
, 0, 32),
4379 &hldev
->common_reg
->cmn_rsthdlr_cfg1
);
4383 * vxge_hw_vpath_stats_enable - Enable vpath h/wstatistics.
4384 * Enable the DMA vpath statistics. The function is to be called to re-enable
4385 * the adapter to update stats into the host memory
4388 vxge_hw_vpath_stats_enable(struct __vxge_hw_vpath_handle
*vp
)
4390 enum vxge_hw_status status
= VXGE_HW_OK
;
4391 struct __vxge_hw_virtualpath
*vpath
;
4395 if (vpath
->vp_open
== VXGE_HW_VP_NOT_OPEN
) {
4396 status
= VXGE_HW_ERR_VPATH_NOT_OPEN
;
4400 memcpy(vpath
->hw_stats_sav
, vpath
->hw_stats
,
4401 sizeof(struct vxge_hw_vpath_stats_hw_info
));
4403 status
= __vxge_hw_vpath_stats_get(vpath
, vpath
->hw_stats
);
4409 * __vxge_hw_vpath_stats_access - Get the statistics from the given location
4410 * and offset and perform an operation
4413 __vxge_hw_vpath_stats_access(struct __vxge_hw_virtualpath
*vpath
,
4414 u32 operation
, u32 offset
, u64
*stat
)
4417 enum vxge_hw_status status
= VXGE_HW_OK
;
4418 struct vxge_hw_vpath_reg __iomem
*vp_reg
;
4420 if (vpath
->vp_open
== VXGE_HW_VP_NOT_OPEN
) {
4421 status
= VXGE_HW_ERR_VPATH_NOT_OPEN
;
4422 goto vpath_stats_access_exit
;
4425 vp_reg
= vpath
->vp_reg
;
4427 val64
= VXGE_HW_XMAC_STATS_ACCESS_CMD_OP(operation
) |
4428 VXGE_HW_XMAC_STATS_ACCESS_CMD_STROBE
|
4429 VXGE_HW_XMAC_STATS_ACCESS_CMD_OFFSET_SEL(offset
);
4431 status
= __vxge_hw_pio_mem_write64(val64
,
4432 &vp_reg
->xmac_stats_access_cmd
,
4433 VXGE_HW_XMAC_STATS_ACCESS_CMD_STROBE
,
4434 vpath
->hldev
->config
.device_poll_millis
);
4436 if ((status
== VXGE_HW_OK
) && (operation
== VXGE_HW_STATS_OP_READ
))
4437 *stat
= readq(&vp_reg
->xmac_stats_access_data
);
4441 vpath_stats_access_exit
:
4446 * __vxge_hw_vpath_xmac_tx_stats_get - Get the TX Statistics of a vpath
4449 __vxge_hw_vpath_xmac_tx_stats_get(
4450 struct __vxge_hw_virtualpath
*vpath
,
4451 struct vxge_hw_xmac_vpath_tx_stats
*vpath_tx_stats
)
4455 u32 offset
= VXGE_HW_STATS_VPATH_TX_OFFSET
;
4456 enum vxge_hw_status status
= VXGE_HW_OK
;
4458 val64
= (u64
*) vpath_tx_stats
;
4460 if (vpath
->vp_open
== VXGE_HW_VP_NOT_OPEN
) {
4461 status
= VXGE_HW_ERR_VPATH_NOT_OPEN
;
4465 for (i
= 0; i
< sizeof(struct vxge_hw_xmac_vpath_tx_stats
) / 8; i
++) {
4466 status
= __vxge_hw_vpath_stats_access(vpath
,
4467 VXGE_HW_STATS_OP_READ
,
4469 if (status
!= VXGE_HW_OK
)
4479 * __vxge_hw_vpath_xmac_rx_stats_get - Get the RX Statistics of a vpath
4482 __vxge_hw_vpath_xmac_rx_stats_get(struct __vxge_hw_virtualpath
*vpath
,
4483 struct vxge_hw_xmac_vpath_rx_stats
*vpath_rx_stats
)
4486 enum vxge_hw_status status
= VXGE_HW_OK
;
4488 u32 offset
= VXGE_HW_STATS_VPATH_RX_OFFSET
;
4489 val64
= (u64
*) vpath_rx_stats
;
4491 if (vpath
->vp_open
== VXGE_HW_VP_NOT_OPEN
) {
4492 status
= VXGE_HW_ERR_VPATH_NOT_OPEN
;
4495 for (i
= 0; i
< sizeof(struct vxge_hw_xmac_vpath_rx_stats
) / 8; i
++) {
4496 status
= __vxge_hw_vpath_stats_access(vpath
,
4497 VXGE_HW_STATS_OP_READ
,
4498 offset
>> 3, val64
);
4499 if (status
!= VXGE_HW_OK
)
4510 * __vxge_hw_vpath_stats_get - Get the vpath hw statistics.
4512 enum vxge_hw_status
__vxge_hw_vpath_stats_get(
4513 struct __vxge_hw_virtualpath
*vpath
,
4514 struct vxge_hw_vpath_stats_hw_info
*hw_stats
)
4517 enum vxge_hw_status status
= VXGE_HW_OK
;
4518 struct vxge_hw_vpath_reg __iomem
*vp_reg
;
4520 if (vpath
->vp_open
== VXGE_HW_VP_NOT_OPEN
) {
4521 status
= VXGE_HW_ERR_VPATH_NOT_OPEN
;
4524 vp_reg
= vpath
->vp_reg
;
4526 val64
= readq(&vp_reg
->vpath_debug_stats0
);
4527 hw_stats
->ini_num_mwr_sent
=
4528 (u32
)VXGE_HW_VPATH_DEBUG_STATS0_GET_INI_NUM_MWR_SENT(val64
);
4530 val64
= readq(&vp_reg
->vpath_debug_stats1
);
4531 hw_stats
->ini_num_mrd_sent
=
4532 (u32
)VXGE_HW_VPATH_DEBUG_STATS1_GET_INI_NUM_MRD_SENT(val64
);
4534 val64
= readq(&vp_reg
->vpath_debug_stats2
);
4535 hw_stats
->ini_num_cpl_rcvd
=
4536 (u32
)VXGE_HW_VPATH_DEBUG_STATS2_GET_INI_NUM_CPL_RCVD(val64
);
4538 val64
= readq(&vp_reg
->vpath_debug_stats3
);
4539 hw_stats
->ini_num_mwr_byte_sent
=
4540 VXGE_HW_VPATH_DEBUG_STATS3_GET_INI_NUM_MWR_BYTE_SENT(val64
);
4542 val64
= readq(&vp_reg
->vpath_debug_stats4
);
4543 hw_stats
->ini_num_cpl_byte_rcvd
=
4544 VXGE_HW_VPATH_DEBUG_STATS4_GET_INI_NUM_CPL_BYTE_RCVD(val64
);
4546 val64
= readq(&vp_reg
->vpath_debug_stats5
);
4547 hw_stats
->wrcrdtarb_xoff
=
4548 (u32
)VXGE_HW_VPATH_DEBUG_STATS5_GET_WRCRDTARB_XOFF(val64
);
4550 val64
= readq(&vp_reg
->vpath_debug_stats6
);
4551 hw_stats
->rdcrdtarb_xoff
=
4552 (u32
)VXGE_HW_VPATH_DEBUG_STATS6_GET_RDCRDTARB_XOFF(val64
);
4554 val64
= readq(&vp_reg
->vpath_genstats_count01
);
4555 hw_stats
->vpath_genstats_count0
=
4556 (u32
)VXGE_HW_VPATH_GENSTATS_COUNT01_GET_PPIF_VPATH_GENSTATS_COUNT0(
4559 val64
= readq(&vp_reg
->vpath_genstats_count01
);
4560 hw_stats
->vpath_genstats_count1
=
4561 (u32
)VXGE_HW_VPATH_GENSTATS_COUNT01_GET_PPIF_VPATH_GENSTATS_COUNT1(
4564 val64
= readq(&vp_reg
->vpath_genstats_count23
);
4565 hw_stats
->vpath_genstats_count2
=
4566 (u32
)VXGE_HW_VPATH_GENSTATS_COUNT23_GET_PPIF_VPATH_GENSTATS_COUNT2(
4569 val64
= readq(&vp_reg
->vpath_genstats_count01
);
4570 hw_stats
->vpath_genstats_count3
=
4571 (u32
)VXGE_HW_VPATH_GENSTATS_COUNT23_GET_PPIF_VPATH_GENSTATS_COUNT3(
4574 val64
= readq(&vp_reg
->vpath_genstats_count4
);
4575 hw_stats
->vpath_genstats_count4
=
4576 (u32
)VXGE_HW_VPATH_GENSTATS_COUNT4_GET_PPIF_VPATH_GENSTATS_COUNT4(
4579 val64
= readq(&vp_reg
->vpath_genstats_count5
);
4580 hw_stats
->vpath_genstats_count5
=
4581 (u32
)VXGE_HW_VPATH_GENSTATS_COUNT5_GET_PPIF_VPATH_GENSTATS_COUNT5(
4584 status
= __vxge_hw_vpath_xmac_tx_stats_get(vpath
, &hw_stats
->tx_stats
);
4585 if (status
!= VXGE_HW_OK
)
4588 status
= __vxge_hw_vpath_xmac_rx_stats_get(vpath
, &hw_stats
->rx_stats
);
4589 if (status
!= VXGE_HW_OK
)
4592 VXGE_HW_VPATH_STATS_PIO_READ(
4593 VXGE_HW_STATS_VPATH_PROG_EVENT_VNUM0_OFFSET
);
4595 hw_stats
->prog_event_vnum0
=
4596 (u32
)VXGE_HW_STATS_GET_VPATH_PROG_EVENT_VNUM0(val64
);
4598 hw_stats
->prog_event_vnum1
=
4599 (u32
)VXGE_HW_STATS_GET_VPATH_PROG_EVENT_VNUM1(val64
);
4601 VXGE_HW_VPATH_STATS_PIO_READ(
4602 VXGE_HW_STATS_VPATH_PROG_EVENT_VNUM2_OFFSET
);
4604 hw_stats
->prog_event_vnum2
=
4605 (u32
)VXGE_HW_STATS_GET_VPATH_PROG_EVENT_VNUM2(val64
);
4607 hw_stats
->prog_event_vnum3
=
4608 (u32
)VXGE_HW_STATS_GET_VPATH_PROG_EVENT_VNUM3(val64
);
4610 val64
= readq(&vp_reg
->rx_multi_cast_stats
);
4611 hw_stats
->rx_multi_cast_frame_discard
=
4612 (u16
)VXGE_HW_RX_MULTI_CAST_STATS_GET_FRAME_DISCARD(val64
);
4614 val64
= readq(&vp_reg
->rx_frm_transferred
);
4615 hw_stats
->rx_frm_transferred
=
4616 (u32
)VXGE_HW_RX_FRM_TRANSFERRED_GET_RX_FRM_TRANSFERRED(val64
);
4618 val64
= readq(&vp_reg
->rxd_returned
);
4619 hw_stats
->rxd_returned
=
4620 (u16
)VXGE_HW_RXD_RETURNED_GET_RXD_RETURNED(val64
);
4622 val64
= readq(&vp_reg
->dbg_stats_rx_mpa
);
4623 hw_stats
->rx_mpa_len_fail_frms
=
4624 (u16
)VXGE_HW_DBG_STATS_GET_RX_MPA_LEN_FAIL_FRMS(val64
);
4625 hw_stats
->rx_mpa_mrk_fail_frms
=
4626 (u16
)VXGE_HW_DBG_STATS_GET_RX_MPA_MRK_FAIL_FRMS(val64
);
4627 hw_stats
->rx_mpa_crc_fail_frms
=
4628 (u16
)VXGE_HW_DBG_STATS_GET_RX_MPA_CRC_FAIL_FRMS(val64
);
4630 val64
= readq(&vp_reg
->dbg_stats_rx_fau
);
4631 hw_stats
->rx_permitted_frms
=
4632 (u16
)VXGE_HW_DBG_STATS_GET_RX_FAU_RX_PERMITTED_FRMS(val64
);
4633 hw_stats
->rx_vp_reset_discarded_frms
=
4634 (u16
)VXGE_HW_DBG_STATS_GET_RX_FAU_RX_VP_RESET_DISCARDED_FRMS(val64
);
4635 hw_stats
->rx_wol_frms
=
4636 (u16
)VXGE_HW_DBG_STATS_GET_RX_FAU_RX_WOL_FRMS(val64
);
4638 val64
= readq(&vp_reg
->tx_vp_reset_discarded_frms
);
4639 hw_stats
->tx_vp_reset_discarded_frms
=
4640 (u16
)VXGE_HW_TX_VP_RESET_DISCARDED_FRMS_GET_TX_VP_RESET_DISCARDED_FRMS(
4647 * __vxge_hw_blockpool_create - Create block pool
4651 __vxge_hw_blockpool_create(struct __vxge_hw_device
*hldev
,
4652 struct __vxge_hw_blockpool
*blockpool
,
4657 struct __vxge_hw_blockpool_entry
*entry
= NULL
;
4659 dma_addr_t dma_addr
;
4660 struct pci_dev
*dma_handle
;
4661 struct pci_dev
*acc_handle
;
4662 enum vxge_hw_status status
= VXGE_HW_OK
;
4664 if (blockpool
== NULL
) {
4665 status
= VXGE_HW_FAIL
;
4666 goto blockpool_create_exit
;
4669 blockpool
->hldev
= hldev
;
4670 blockpool
->block_size
= VXGE_HW_BLOCK_SIZE
;
4671 blockpool
->pool_size
= 0;
4672 blockpool
->pool_max
= pool_max
;
4673 blockpool
->req_out
= 0;
4675 INIT_LIST_HEAD(&blockpool
->free_block_list
);
4676 INIT_LIST_HEAD(&blockpool
->free_entry_list
);
4678 for (i
= 0; i
< pool_size
+ pool_max
; i
++) {
4679 entry
= kzalloc(sizeof(struct __vxge_hw_blockpool_entry
),
4681 if (entry
== NULL
) {
4682 __vxge_hw_blockpool_destroy(blockpool
);
4683 status
= VXGE_HW_ERR_OUT_OF_MEMORY
;
4684 goto blockpool_create_exit
;
4686 list_add(&entry
->item
, &blockpool
->free_entry_list
);
4689 for (i
= 0; i
< pool_size
; i
++) {
4691 memblock
= vxge_os_dma_malloc(
4697 if (memblock
== NULL
) {
4698 __vxge_hw_blockpool_destroy(blockpool
);
4699 status
= VXGE_HW_ERR_OUT_OF_MEMORY
;
4700 goto blockpool_create_exit
;
4703 dma_addr
= pci_map_single(hldev
->pdev
, memblock
,
4704 VXGE_HW_BLOCK_SIZE
, PCI_DMA_BIDIRECTIONAL
);
4706 if (unlikely(pci_dma_mapping_error(hldev
->pdev
,
4709 vxge_os_dma_free(hldev
->pdev
, memblock
, &acc_handle
);
4710 __vxge_hw_blockpool_destroy(blockpool
);
4711 status
= VXGE_HW_ERR_OUT_OF_MEMORY
;
4712 goto blockpool_create_exit
;
4715 if (!list_empty(&blockpool
->free_entry_list
))
4716 entry
= (struct __vxge_hw_blockpool_entry
*)
4717 list_first_entry(&blockpool
->free_entry_list
,
4718 struct __vxge_hw_blockpool_entry
,
4723 kzalloc(sizeof(struct __vxge_hw_blockpool_entry
),
4725 if (entry
!= NULL
) {
4726 list_del(&entry
->item
);
4727 entry
->length
= VXGE_HW_BLOCK_SIZE
;
4728 entry
->memblock
= memblock
;
4729 entry
->dma_addr
= dma_addr
;
4730 entry
->acc_handle
= acc_handle
;
4731 entry
->dma_handle
= dma_handle
;
4732 list_add(&entry
->item
,
4733 &blockpool
->free_block_list
);
4734 blockpool
->pool_size
++;
4736 __vxge_hw_blockpool_destroy(blockpool
);
4737 status
= VXGE_HW_ERR_OUT_OF_MEMORY
;
4738 goto blockpool_create_exit
;
4742 blockpool_create_exit
:
4747 * __vxge_hw_blockpool_destroy - Deallocates the block pool
4750 void __vxge_hw_blockpool_destroy(struct __vxge_hw_blockpool
*blockpool
)
4753 struct __vxge_hw_device
*hldev
;
4754 struct list_head
*p
, *n
;
4757 if (blockpool
== NULL
) {
4762 hldev
= blockpool
->hldev
;
4764 list_for_each_safe(p
, n
, &blockpool
->free_block_list
) {
4766 pci_unmap_single(hldev
->pdev
,
4767 ((struct __vxge_hw_blockpool_entry
*)p
)->dma_addr
,
4768 ((struct __vxge_hw_blockpool_entry
*)p
)->length
,
4769 PCI_DMA_BIDIRECTIONAL
);
4771 vxge_os_dma_free(hldev
->pdev
,
4772 ((struct __vxge_hw_blockpool_entry
*)p
)->memblock
,
4773 &((struct __vxge_hw_blockpool_entry
*) p
)->acc_handle
);
4776 &((struct __vxge_hw_blockpool_entry
*)p
)->item
);
4778 blockpool
->pool_size
--;
4781 list_for_each_safe(p
, n
, &blockpool
->free_entry_list
) {
4783 &((struct __vxge_hw_blockpool_entry
*)p
)->item
);
4792 * __vxge_hw_blockpool_blocks_add - Request additional blocks
4795 void __vxge_hw_blockpool_blocks_add(struct __vxge_hw_blockpool
*blockpool
)
4799 if ((blockpool
->pool_size
+ blockpool
->req_out
) <
4800 VXGE_HW_MIN_DMA_BLOCK_POOL_SIZE
) {
4801 nreq
= VXGE_HW_INCR_DMA_BLOCK_POOL_SIZE
;
4802 blockpool
->req_out
+= nreq
;
4805 for (i
= 0; i
< nreq
; i
++)
4806 vxge_os_dma_malloc_async(
4807 ((struct __vxge_hw_device
*)blockpool
->hldev
)->pdev
,
4808 blockpool
->hldev
, VXGE_HW_BLOCK_SIZE
);
4812 * __vxge_hw_blockpool_blocks_remove - Free additional blocks
4815 void __vxge_hw_blockpool_blocks_remove(struct __vxge_hw_blockpool
*blockpool
)
4817 struct list_head
*p
, *n
;
4819 list_for_each_safe(p
, n
, &blockpool
->free_block_list
) {
4821 if (blockpool
->pool_size
< blockpool
->pool_max
)
4825 ((struct __vxge_hw_device
*)blockpool
->hldev
)->pdev
,
4826 ((struct __vxge_hw_blockpool_entry
*)p
)->dma_addr
,
4827 ((struct __vxge_hw_blockpool_entry
*)p
)->length
,
4828 PCI_DMA_BIDIRECTIONAL
);
4831 ((struct __vxge_hw_device
*)blockpool
->hldev
)->pdev
,
4832 ((struct __vxge_hw_blockpool_entry
*)p
)->memblock
,
4833 &((struct __vxge_hw_blockpool_entry
*)p
)->acc_handle
);
4835 list_del(&((struct __vxge_hw_blockpool_entry
*)p
)->item
);
4837 list_add(p
, &blockpool
->free_entry_list
);
4839 blockpool
->pool_size
--;
4845 * vxge_hw_blockpool_block_add - callback for vxge_os_dma_malloc_async
4846 * Adds a block to block pool
4848 void vxge_hw_blockpool_block_add(
4849 struct __vxge_hw_device
*devh
,
4852 struct pci_dev
*dma_h
,
4853 struct pci_dev
*acc_handle
)
4855 struct __vxge_hw_blockpool
*blockpool
;
4856 struct __vxge_hw_blockpool_entry
*entry
= NULL
;
4857 dma_addr_t dma_addr
;
4858 enum vxge_hw_status status
= VXGE_HW_OK
;
4861 blockpool
= &devh
->block_pool
;
4863 if (block_addr
== NULL
) {
4864 blockpool
->req_out
--;
4865 status
= VXGE_HW_FAIL
;
4869 dma_addr
= pci_map_single(devh
->pdev
, block_addr
, length
,
4870 PCI_DMA_BIDIRECTIONAL
);
4872 if (unlikely(pci_dma_mapping_error(devh
->pdev
, dma_addr
))) {
4874 vxge_os_dma_free(devh
->pdev
, block_addr
, &acc_handle
);
4875 blockpool
->req_out
--;
4876 status
= VXGE_HW_FAIL
;
4881 if (!list_empty(&blockpool
->free_entry_list
))
4882 entry
= (struct __vxge_hw_blockpool_entry
*)
4883 list_first_entry(&blockpool
->free_entry_list
,
4884 struct __vxge_hw_blockpool_entry
,
4888 entry
= (struct __vxge_hw_blockpool_entry
*)
4889 vmalloc(sizeof(struct __vxge_hw_blockpool_entry
));
4891 list_del(&entry
->item
);
4893 if (entry
!= NULL
) {
4894 entry
->length
= length
;
4895 entry
->memblock
= block_addr
;
4896 entry
->dma_addr
= dma_addr
;
4897 entry
->acc_handle
= acc_handle
;
4898 entry
->dma_handle
= dma_h
;
4899 list_add(&entry
->item
, &blockpool
->free_block_list
);
4900 blockpool
->pool_size
++;
4901 status
= VXGE_HW_OK
;
4903 status
= VXGE_HW_ERR_OUT_OF_MEMORY
;
4905 blockpool
->req_out
--;
4907 req_out
= blockpool
->req_out
;
4913 * __vxge_hw_blockpool_malloc - Allocate a memory block from pool
4914 * Allocates a block of memory of given size, either from block pool
4915 * or by calling vxge_os_dma_malloc()
4918 __vxge_hw_blockpool_malloc(struct __vxge_hw_device
*devh
, u32 size
,
4919 struct vxge_hw_mempool_dma
*dma_object
)
4921 struct __vxge_hw_blockpool_entry
*entry
= NULL
;
4922 struct __vxge_hw_blockpool
*blockpool
;
4923 void *memblock
= NULL
;
4924 enum vxge_hw_status status
= VXGE_HW_OK
;
4926 blockpool
= &devh
->block_pool
;
4928 if (size
!= blockpool
->block_size
) {
4930 memblock
= vxge_os_dma_malloc(devh
->pdev
, size
,
4931 &dma_object
->handle
,
4932 &dma_object
->acc_handle
);
4934 if (memblock
== NULL
) {
4935 status
= VXGE_HW_ERR_OUT_OF_MEMORY
;
4939 dma_object
->addr
= pci_map_single(devh
->pdev
, memblock
, size
,
4940 PCI_DMA_BIDIRECTIONAL
);
4942 if (unlikely(pci_dma_mapping_error(devh
->pdev
,
4943 dma_object
->addr
))) {
4944 vxge_os_dma_free(devh
->pdev
, memblock
,
4945 &dma_object
->acc_handle
);
4946 status
= VXGE_HW_ERR_OUT_OF_MEMORY
;
4952 if (!list_empty(&blockpool
->free_block_list
))
4953 entry
= (struct __vxge_hw_blockpool_entry
*)
4954 list_first_entry(&blockpool
->free_block_list
,
4955 struct __vxge_hw_blockpool_entry
,
4958 if (entry
!= NULL
) {
4959 list_del(&entry
->item
);
4960 dma_object
->addr
= entry
->dma_addr
;
4961 dma_object
->handle
= entry
->dma_handle
;
4962 dma_object
->acc_handle
= entry
->acc_handle
;
4963 memblock
= entry
->memblock
;
4965 list_add(&entry
->item
,
4966 &blockpool
->free_entry_list
);
4967 blockpool
->pool_size
--;
4970 if (memblock
!= NULL
)
4971 __vxge_hw_blockpool_blocks_add(blockpool
);
4978 * __vxge_hw_blockpool_free - Frees the memory allcoated with
4979 __vxge_hw_blockpool_malloc
4982 __vxge_hw_blockpool_free(struct __vxge_hw_device
*devh
,
4983 void *memblock
, u32 size
,
4984 struct vxge_hw_mempool_dma
*dma_object
)
4986 struct __vxge_hw_blockpool_entry
*entry
= NULL
;
4987 struct __vxge_hw_blockpool
*blockpool
;
4988 enum vxge_hw_status status
= VXGE_HW_OK
;
4990 blockpool
= &devh
->block_pool
;
4992 if (size
!= blockpool
->block_size
) {
4993 pci_unmap_single(devh
->pdev
, dma_object
->addr
, size
,
4994 PCI_DMA_BIDIRECTIONAL
);
4995 vxge_os_dma_free(devh
->pdev
, memblock
, &dma_object
->acc_handle
);
4998 if (!list_empty(&blockpool
->free_entry_list
))
4999 entry
= (struct __vxge_hw_blockpool_entry
*)
5000 list_first_entry(&blockpool
->free_entry_list
,
5001 struct __vxge_hw_blockpool_entry
,
5005 entry
= (struct __vxge_hw_blockpool_entry
*)
5007 struct __vxge_hw_blockpool_entry
));
5009 list_del(&entry
->item
);
5011 if (entry
!= NULL
) {
5012 entry
->length
= size
;
5013 entry
->memblock
= memblock
;
5014 entry
->dma_addr
= dma_object
->addr
;
5015 entry
->acc_handle
= dma_object
->acc_handle
;
5016 entry
->dma_handle
= dma_object
->handle
;
5017 list_add(&entry
->item
,
5018 &blockpool
->free_block_list
);
5019 blockpool
->pool_size
++;
5020 status
= VXGE_HW_OK
;
5022 status
= VXGE_HW_ERR_OUT_OF_MEMORY
;
5024 if (status
== VXGE_HW_OK
)
5025 __vxge_hw_blockpool_blocks_remove(blockpool
);
5030 * __vxge_hw_blockpool_block_allocate - Allocates a block from block pool
5031 * This function allocates a block from block pool or from the system
5033 struct __vxge_hw_blockpool_entry
*
5034 __vxge_hw_blockpool_block_allocate(struct __vxge_hw_device
*devh
, u32 size
)
5036 struct __vxge_hw_blockpool_entry
*entry
= NULL
;
5037 struct __vxge_hw_blockpool
*blockpool
;
5039 blockpool
= &devh
->block_pool
;
5041 if (size
== blockpool
->block_size
) {
5043 if (!list_empty(&blockpool
->free_block_list
))
5044 entry
= (struct __vxge_hw_blockpool_entry
*)
5045 list_first_entry(&blockpool
->free_block_list
,
5046 struct __vxge_hw_blockpool_entry
,
5049 if (entry
!= NULL
) {
5050 list_del(&entry
->item
);
5051 blockpool
->pool_size
--;
5056 __vxge_hw_blockpool_blocks_add(blockpool
);
5062 * __vxge_hw_blockpool_block_free - Frees a block from block pool
5064 * @entry: Entry of block to be freed
5066 * This function frees a block from block pool
5069 __vxge_hw_blockpool_block_free(struct __vxge_hw_device
*devh
,
5070 struct __vxge_hw_blockpool_entry
*entry
)
5072 struct __vxge_hw_blockpool
*blockpool
;
5074 blockpool
= &devh
->block_pool
;
5076 if (entry
->length
== blockpool
->block_size
) {
5077 list_add(&entry
->item
, &blockpool
->free_block_list
);
5078 blockpool
->pool_size
++;
5081 __vxge_hw_blockpool_blocks_remove(blockpool
);