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-traffic.c: Driver for Exar Corp's X3100 Series 10GbE PCIe I/O
11 * Virtualized Server Adapter.
12 * Copyright(c) 2002-2010 Exar Corp.
13 ******************************************************************************/
14 #include <linux/etherdevice.h>
15 #include <linux/prefetch.h>
17 #include "vxge-traffic.h"
18 #include "vxge-config.h"
19 #include "vxge-main.h"
22 * vxge_hw_vpath_intr_enable - Enable vpath interrupts.
23 * @vp: Virtual Path handle.
25 * Enable vpath interrupts. The function is to be executed the last in
26 * vpath initialization sequence.
28 * See also: vxge_hw_vpath_intr_disable()
30 enum vxge_hw_status
vxge_hw_vpath_intr_enable(struct __vxge_hw_vpath_handle
*vp
)
34 struct __vxge_hw_virtualpath
*vpath
;
35 struct vxge_hw_vpath_reg __iomem
*vp_reg
;
36 enum vxge_hw_status status
= VXGE_HW_OK
;
38 status
= VXGE_HW_ERR_INVALID_HANDLE
;
44 if (vpath
->vp_open
== VXGE_HW_VP_NOT_OPEN
) {
45 status
= VXGE_HW_ERR_VPATH_NOT_OPEN
;
49 vp_reg
= vpath
->vp_reg
;
51 writeq(VXGE_HW_INTR_MASK_ALL
, &vp_reg
->kdfcctl_errors_reg
);
53 __vxge_hw_pio_mem_write32_upper((u32
)VXGE_HW_INTR_MASK_ALL
,
54 &vp_reg
->general_errors_reg
);
56 __vxge_hw_pio_mem_write32_upper((u32
)VXGE_HW_INTR_MASK_ALL
,
57 &vp_reg
->pci_config_errors_reg
);
59 __vxge_hw_pio_mem_write32_upper((u32
)VXGE_HW_INTR_MASK_ALL
,
60 &vp_reg
->mrpcim_to_vpath_alarm_reg
);
62 __vxge_hw_pio_mem_write32_upper((u32
)VXGE_HW_INTR_MASK_ALL
,
63 &vp_reg
->srpcim_to_vpath_alarm_reg
);
65 __vxge_hw_pio_mem_write32_upper((u32
)VXGE_HW_INTR_MASK_ALL
,
66 &vp_reg
->vpath_ppif_int_status
);
68 __vxge_hw_pio_mem_write32_upper((u32
)VXGE_HW_INTR_MASK_ALL
,
69 &vp_reg
->srpcim_msg_to_vpath_reg
);
71 __vxge_hw_pio_mem_write32_upper((u32
)VXGE_HW_INTR_MASK_ALL
,
72 &vp_reg
->vpath_pcipif_int_status
);
74 __vxge_hw_pio_mem_write32_upper((u32
)VXGE_HW_INTR_MASK_ALL
,
75 &vp_reg
->prc_alarm_reg
);
77 __vxge_hw_pio_mem_write32_upper((u32
)VXGE_HW_INTR_MASK_ALL
,
78 &vp_reg
->wrdma_alarm_status
);
80 __vxge_hw_pio_mem_write32_upper((u32
)VXGE_HW_INTR_MASK_ALL
,
81 &vp_reg
->asic_ntwk_vp_err_reg
);
83 __vxge_hw_pio_mem_write32_upper((u32
)VXGE_HW_INTR_MASK_ALL
,
84 &vp_reg
->xgmac_vp_int_status
);
86 val64
= readq(&vp_reg
->vpath_general_int_status
);
88 /* Mask unwanted interrupts */
90 __vxge_hw_pio_mem_write32_upper((u32
)VXGE_HW_INTR_MASK_ALL
,
91 &vp_reg
->vpath_pcipif_int_mask
);
93 __vxge_hw_pio_mem_write32_upper((u32
)VXGE_HW_INTR_MASK_ALL
,
94 &vp_reg
->srpcim_msg_to_vpath_mask
);
96 __vxge_hw_pio_mem_write32_upper((u32
)VXGE_HW_INTR_MASK_ALL
,
97 &vp_reg
->srpcim_to_vpath_alarm_mask
);
99 __vxge_hw_pio_mem_write32_upper((u32
)VXGE_HW_INTR_MASK_ALL
,
100 &vp_reg
->mrpcim_to_vpath_alarm_mask
);
102 __vxge_hw_pio_mem_write32_upper((u32
)VXGE_HW_INTR_MASK_ALL
,
103 &vp_reg
->pci_config_errors_mask
);
105 /* Unmask the individual interrupts */
107 writeq((u32
)vxge_bVALn((VXGE_HW_GENERAL_ERRORS_REG_DBLGEN_FIFO1_OVRFLOW
|
108 VXGE_HW_GENERAL_ERRORS_REG_DBLGEN_FIFO2_OVRFLOW
|
109 VXGE_HW_GENERAL_ERRORS_REG_STATSB_DROP_TIMEOUT_REQ
|
110 VXGE_HW_GENERAL_ERRORS_REG_STATSB_PIF_CHAIN_ERR
), 0, 32),
111 &vp_reg
->general_errors_mask
);
113 __vxge_hw_pio_mem_write32_upper(
114 (u32
)vxge_bVALn((VXGE_HW_KDFCCTL_ERRORS_REG_KDFCCTL_FIFO1_OVRWR
|
115 VXGE_HW_KDFCCTL_ERRORS_REG_KDFCCTL_FIFO2_OVRWR
|
116 VXGE_HW_KDFCCTL_ERRORS_REG_KDFCCTL_FIFO1_POISON
|
117 VXGE_HW_KDFCCTL_ERRORS_REG_KDFCCTL_FIFO2_POISON
|
118 VXGE_HW_KDFCCTL_ERRORS_REG_KDFCCTL_FIFO1_DMA_ERR
|
119 VXGE_HW_KDFCCTL_ERRORS_REG_KDFCCTL_FIFO2_DMA_ERR
), 0, 32),
120 &vp_reg
->kdfcctl_errors_mask
);
122 __vxge_hw_pio_mem_write32_upper(0, &vp_reg
->vpath_ppif_int_mask
);
124 __vxge_hw_pio_mem_write32_upper(
125 (u32
)vxge_bVALn(VXGE_HW_PRC_ALARM_REG_PRC_RING_BUMP
, 0, 32),
126 &vp_reg
->prc_alarm_mask
);
128 __vxge_hw_pio_mem_write32_upper(0, &vp_reg
->wrdma_alarm_mask
);
129 __vxge_hw_pio_mem_write32_upper(0, &vp_reg
->xgmac_vp_int_mask
);
131 if (vpath
->hldev
->first_vp_id
!= vpath
->vp_id
)
132 __vxge_hw_pio_mem_write32_upper((u32
)VXGE_HW_INTR_MASK_ALL
,
133 &vp_reg
->asic_ntwk_vp_err_mask
);
135 __vxge_hw_pio_mem_write32_upper((u32
)vxge_bVALn((
136 VXGE_HW_ASIC_NTWK_VP_ERR_REG_XMACJ_NTWK_REAFFIRMED_FAULT
|
137 VXGE_HW_ASIC_NTWK_VP_ERR_REG_XMACJ_NTWK_REAFFIRMED_OK
), 0, 32),
138 &vp_reg
->asic_ntwk_vp_err_mask
);
140 __vxge_hw_pio_mem_write32_upper(0,
141 &vp_reg
->vpath_general_int_mask
);
148 * vxge_hw_vpath_intr_disable - Disable vpath interrupts.
149 * @vp: Virtual Path handle.
151 * Disable vpath interrupts. The function is to be executed the last in
152 * vpath initialization sequence.
154 * See also: vxge_hw_vpath_intr_enable()
156 enum vxge_hw_status
vxge_hw_vpath_intr_disable(
157 struct __vxge_hw_vpath_handle
*vp
)
161 struct __vxge_hw_virtualpath
*vpath
;
162 enum vxge_hw_status status
= VXGE_HW_OK
;
163 struct vxge_hw_vpath_reg __iomem
*vp_reg
;
165 status
= VXGE_HW_ERR_INVALID_HANDLE
;
171 if (vpath
->vp_open
== VXGE_HW_VP_NOT_OPEN
) {
172 status
= VXGE_HW_ERR_VPATH_NOT_OPEN
;
175 vp_reg
= vpath
->vp_reg
;
177 __vxge_hw_pio_mem_write32_upper(
178 (u32
)VXGE_HW_INTR_MASK_ALL
,
179 &vp_reg
->vpath_general_int_mask
);
181 val64
= VXGE_HW_TIM_CLR_INT_EN_VP(1 << (16 - vpath
->vp_id
));
183 writeq(VXGE_HW_INTR_MASK_ALL
, &vp_reg
->kdfcctl_errors_mask
);
185 __vxge_hw_pio_mem_write32_upper((u32
)VXGE_HW_INTR_MASK_ALL
,
186 &vp_reg
->general_errors_mask
);
188 __vxge_hw_pio_mem_write32_upper((u32
)VXGE_HW_INTR_MASK_ALL
,
189 &vp_reg
->pci_config_errors_mask
);
191 __vxge_hw_pio_mem_write32_upper((u32
)VXGE_HW_INTR_MASK_ALL
,
192 &vp_reg
->mrpcim_to_vpath_alarm_mask
);
194 __vxge_hw_pio_mem_write32_upper((u32
)VXGE_HW_INTR_MASK_ALL
,
195 &vp_reg
->srpcim_to_vpath_alarm_mask
);
197 __vxge_hw_pio_mem_write32_upper((u32
)VXGE_HW_INTR_MASK_ALL
,
198 &vp_reg
->vpath_ppif_int_mask
);
200 __vxge_hw_pio_mem_write32_upper((u32
)VXGE_HW_INTR_MASK_ALL
,
201 &vp_reg
->srpcim_msg_to_vpath_mask
);
203 __vxge_hw_pio_mem_write32_upper((u32
)VXGE_HW_INTR_MASK_ALL
,
204 &vp_reg
->vpath_pcipif_int_mask
);
206 __vxge_hw_pio_mem_write32_upper((u32
)VXGE_HW_INTR_MASK_ALL
,
207 &vp_reg
->wrdma_alarm_mask
);
209 __vxge_hw_pio_mem_write32_upper((u32
)VXGE_HW_INTR_MASK_ALL
,
210 &vp_reg
->prc_alarm_mask
);
212 __vxge_hw_pio_mem_write32_upper((u32
)VXGE_HW_INTR_MASK_ALL
,
213 &vp_reg
->xgmac_vp_int_mask
);
215 __vxge_hw_pio_mem_write32_upper((u32
)VXGE_HW_INTR_MASK_ALL
,
216 &vp_reg
->asic_ntwk_vp_err_mask
);
222 void vxge_hw_vpath_tti_ci_set(struct __vxge_hw_fifo
*fifo
)
224 struct vxge_hw_vpath_reg __iomem
*vp_reg
;
225 struct vxge_hw_vp_config
*config
;
228 if (fifo
->config
->enable
!= VXGE_HW_FIFO_ENABLE
)
231 vp_reg
= fifo
->vp_reg
;
232 config
= container_of(fifo
->config
, struct vxge_hw_vp_config
, fifo
);
234 if (config
->tti
.timer_ci_en
!= VXGE_HW_TIM_TIMER_CI_ENABLE
) {
235 config
->tti
.timer_ci_en
= VXGE_HW_TIM_TIMER_CI_ENABLE
;
236 val64
= readq(&vp_reg
->tim_cfg1_int_num
[VXGE_HW_VPATH_INTR_TX
]);
237 val64
|= VXGE_HW_TIM_CFG1_INT_NUM_TIMER_CI
;
238 fifo
->tim_tti_cfg1_saved
= val64
;
239 writeq(val64
, &vp_reg
->tim_cfg1_int_num
[VXGE_HW_VPATH_INTR_TX
]);
243 void vxge_hw_vpath_dynamic_rti_ci_set(struct __vxge_hw_ring
*ring
)
245 u64 val64
= ring
->tim_rti_cfg1_saved
;
247 val64
|= VXGE_HW_TIM_CFG1_INT_NUM_TIMER_CI
;
248 ring
->tim_rti_cfg1_saved
= val64
;
249 writeq(val64
, &ring
->vp_reg
->tim_cfg1_int_num
[VXGE_HW_VPATH_INTR_RX
]);
252 void vxge_hw_vpath_dynamic_tti_rtimer_set(struct __vxge_hw_fifo
*fifo
)
254 u64 val64
= fifo
->tim_tti_cfg3_saved
;
255 u64 timer
= (fifo
->rtimer
* 1000) / 272;
257 val64
&= ~VXGE_HW_TIM_CFG3_INT_NUM_RTIMER_VAL(0x3ffffff);
259 val64
|= VXGE_HW_TIM_CFG3_INT_NUM_RTIMER_VAL(timer
) |
260 VXGE_HW_TIM_CFG3_INT_NUM_RTIMER_EVENT_SF(5);
262 writeq(val64
, &fifo
->vp_reg
->tim_cfg3_int_num
[VXGE_HW_VPATH_INTR_TX
]);
263 /* tti_cfg3_saved is not updated again because it is
264 * initialized at one place only - init time.
268 void vxge_hw_vpath_dynamic_rti_rtimer_set(struct __vxge_hw_ring
*ring
)
270 u64 val64
= ring
->tim_rti_cfg3_saved
;
271 u64 timer
= (ring
->rtimer
* 1000) / 272;
273 val64
&= ~VXGE_HW_TIM_CFG3_INT_NUM_RTIMER_VAL(0x3ffffff);
275 val64
|= VXGE_HW_TIM_CFG3_INT_NUM_RTIMER_VAL(timer
) |
276 VXGE_HW_TIM_CFG3_INT_NUM_RTIMER_EVENT_SF(4);
278 writeq(val64
, &ring
->vp_reg
->tim_cfg3_int_num
[VXGE_HW_VPATH_INTR_RX
]);
279 /* rti_cfg3_saved is not updated again because it is
280 * initialized at one place only - init time.
285 * vxge_hw_channel_msix_mask - Mask MSIX Vector.
286 * @channeh: Channel for rx or tx handle
289 * The function masks the msix interrupt for the given msix_id
293 void vxge_hw_channel_msix_mask(struct __vxge_hw_channel
*channel
, int msix_id
)
296 __vxge_hw_pio_mem_write32_upper(
297 (u32
)vxge_bVALn(vxge_mBIT(msix_id
>> 2), 0, 32),
298 &channel
->common_reg
->set_msix_mask_vect
[msix_id
%4]);
302 * vxge_hw_channel_msix_unmask - Unmask the MSIX Vector.
303 * @channeh: Channel for rx or tx handle
306 * The function unmasks the msix interrupt for the given msix_id
311 vxge_hw_channel_msix_unmask(struct __vxge_hw_channel
*channel
, int msix_id
)
314 __vxge_hw_pio_mem_write32_upper(
315 (u32
)vxge_bVALn(vxge_mBIT(msix_id
>> 2), 0, 32),
316 &channel
->common_reg
->clear_msix_mask_vect
[msix_id
%4]);
320 * vxge_hw_channel_msix_clear - Unmask the MSIX Vector.
321 * @channel: Channel for rx or tx handle
324 * The function unmasks the msix interrupt for the given msix_id
325 * if configured in MSIX oneshot mode
329 void vxge_hw_channel_msix_clear(struct __vxge_hw_channel
*channel
, int msix_id
)
331 __vxge_hw_pio_mem_write32_upper(
332 (u32
) vxge_bVALn(vxge_mBIT(msix_id
>> 2), 0, 32),
333 &channel
->common_reg
->clr_msix_one_shot_vec
[msix_id
% 4]);
337 * vxge_hw_device_set_intr_type - Updates the configuration
338 * with new interrupt type.
339 * @hldev: HW device handle.
340 * @intr_mode: New interrupt type
342 u32
vxge_hw_device_set_intr_type(struct __vxge_hw_device
*hldev
, u32 intr_mode
)
345 if ((intr_mode
!= VXGE_HW_INTR_MODE_IRQLINE
) &&
346 (intr_mode
!= VXGE_HW_INTR_MODE_MSIX
) &&
347 (intr_mode
!= VXGE_HW_INTR_MODE_MSIX_ONE_SHOT
) &&
348 (intr_mode
!= VXGE_HW_INTR_MODE_DEF
))
349 intr_mode
= VXGE_HW_INTR_MODE_IRQLINE
;
351 hldev
->config
.intr_mode
= intr_mode
;
356 * vxge_hw_device_intr_enable - Enable interrupts.
357 * @hldev: HW device handle.
358 * @op: One of the enum vxge_hw_device_intr enumerated values specifying
359 * the type(s) of interrupts to enable.
361 * Enable Titan interrupts. The function is to be executed the last in
362 * Titan initialization sequence.
364 * See also: vxge_hw_device_intr_disable()
366 void vxge_hw_device_intr_enable(struct __vxge_hw_device
*hldev
)
372 vxge_hw_device_mask_all(hldev
);
374 for (i
= 0; i
< VXGE_HW_MAX_VIRTUAL_PATHS
; i
++) {
376 if (!(hldev
->vpaths_deployed
& vxge_mBIT(i
)))
379 vxge_hw_vpath_intr_enable(
380 VXGE_HW_VIRTUAL_PATH_HANDLE(&hldev
->virtual_paths
[i
]));
383 if (hldev
->config
.intr_mode
== VXGE_HW_INTR_MODE_IRQLINE
) {
384 val64
= hldev
->tim_int_mask0
[VXGE_HW_VPATH_INTR_TX
] |
385 hldev
->tim_int_mask0
[VXGE_HW_VPATH_INTR_RX
];
388 writeq(val64
, &hldev
->common_reg
->tim_int_status0
);
390 writeq(~val64
, &hldev
->common_reg
->tim_int_mask0
);
393 val32
= hldev
->tim_int_mask1
[VXGE_HW_VPATH_INTR_TX
] |
394 hldev
->tim_int_mask1
[VXGE_HW_VPATH_INTR_RX
];
397 __vxge_hw_pio_mem_write32_upper(val32
,
398 &hldev
->common_reg
->tim_int_status1
);
400 __vxge_hw_pio_mem_write32_upper(~val32
,
401 &hldev
->common_reg
->tim_int_mask1
);
405 val64
= readq(&hldev
->common_reg
->titan_general_int_status
);
407 vxge_hw_device_unmask_all(hldev
);
411 * vxge_hw_device_intr_disable - Disable Titan interrupts.
412 * @hldev: HW device handle.
413 * @op: One of the enum vxge_hw_device_intr enumerated values specifying
414 * the type(s) of interrupts to disable.
416 * Disable Titan interrupts.
418 * See also: vxge_hw_device_intr_enable()
420 void vxge_hw_device_intr_disable(struct __vxge_hw_device
*hldev
)
424 vxge_hw_device_mask_all(hldev
);
426 /* mask all the tim interrupts */
427 writeq(VXGE_HW_INTR_MASK_ALL
, &hldev
->common_reg
->tim_int_mask0
);
428 __vxge_hw_pio_mem_write32_upper(VXGE_HW_DEFAULT_32
,
429 &hldev
->common_reg
->tim_int_mask1
);
431 for (i
= 0; i
< VXGE_HW_MAX_VIRTUAL_PATHS
; i
++) {
433 if (!(hldev
->vpaths_deployed
& vxge_mBIT(i
)))
436 vxge_hw_vpath_intr_disable(
437 VXGE_HW_VIRTUAL_PATH_HANDLE(&hldev
->virtual_paths
[i
]));
442 * vxge_hw_device_mask_all - Mask all device interrupts.
443 * @hldev: HW device handle.
445 * Mask all device interrupts.
447 * See also: vxge_hw_device_unmask_all()
449 void vxge_hw_device_mask_all(struct __vxge_hw_device
*hldev
)
453 val64
= VXGE_HW_TITAN_MASK_ALL_INT_ALARM
|
454 VXGE_HW_TITAN_MASK_ALL_INT_TRAFFIC
;
456 __vxge_hw_pio_mem_write32_upper((u32
)vxge_bVALn(val64
, 0, 32),
457 &hldev
->common_reg
->titan_mask_all_int
);
461 * vxge_hw_device_unmask_all - Unmask all device interrupts.
462 * @hldev: HW device handle.
464 * Unmask all device interrupts.
466 * See also: vxge_hw_device_mask_all()
468 void vxge_hw_device_unmask_all(struct __vxge_hw_device
*hldev
)
472 if (hldev
->config
.intr_mode
== VXGE_HW_INTR_MODE_IRQLINE
)
473 val64
= VXGE_HW_TITAN_MASK_ALL_INT_TRAFFIC
;
475 __vxge_hw_pio_mem_write32_upper((u32
)vxge_bVALn(val64
, 0, 32),
476 &hldev
->common_reg
->titan_mask_all_int
);
480 * vxge_hw_device_flush_io - Flush io writes.
481 * @hldev: HW device handle.
483 * The function performs a read operation to flush io writes.
487 void vxge_hw_device_flush_io(struct __vxge_hw_device
*hldev
)
491 val32
= readl(&hldev
->common_reg
->titan_general_int_status
);
495 * __vxge_hw_device_handle_error - Handle error
498 * @type: Error type. Please see enum vxge_hw_event{}
502 static enum vxge_hw_status
503 __vxge_hw_device_handle_error(struct __vxge_hw_device
*hldev
, u32 vp_id
,
504 enum vxge_hw_event type
)
507 case VXGE_HW_EVENT_UNKNOWN
:
509 case VXGE_HW_EVENT_RESET_START
:
510 case VXGE_HW_EVENT_RESET_COMPLETE
:
511 case VXGE_HW_EVENT_LINK_DOWN
:
512 case VXGE_HW_EVENT_LINK_UP
:
514 case VXGE_HW_EVENT_ALARM_CLEARED
:
516 case VXGE_HW_EVENT_ECCERR
:
517 case VXGE_HW_EVENT_MRPCIM_ECCERR
:
519 case VXGE_HW_EVENT_FIFO_ERR
:
520 case VXGE_HW_EVENT_VPATH_ERR
:
521 case VXGE_HW_EVENT_CRITICAL_ERR
:
522 case VXGE_HW_EVENT_SERR
:
524 case VXGE_HW_EVENT_SRPCIM_SERR
:
525 case VXGE_HW_EVENT_MRPCIM_SERR
:
527 case VXGE_HW_EVENT_SLOT_FREEZE
:
535 if (hldev
->uld_callbacks
->crit_err
)
536 hldev
->uld_callbacks
->crit_err(hldev
,
544 * __vxge_hw_device_handle_link_down_ind
545 * @hldev: HW device handle.
547 * Link down indication handler. The function is invoked by HW when
548 * Titan indicates that the link is down.
550 static enum vxge_hw_status
551 __vxge_hw_device_handle_link_down_ind(struct __vxge_hw_device
*hldev
)
554 * If the previous link state is not down, return.
556 if (hldev
->link_state
== VXGE_HW_LINK_DOWN
)
559 hldev
->link_state
= VXGE_HW_LINK_DOWN
;
562 if (hldev
->uld_callbacks
->link_down
)
563 hldev
->uld_callbacks
->link_down(hldev
);
569 * __vxge_hw_device_handle_link_up_ind
570 * @hldev: HW device handle.
572 * Link up indication handler. The function is invoked by HW when
573 * Titan indicates that the link is up for programmable amount of time.
575 static enum vxge_hw_status
576 __vxge_hw_device_handle_link_up_ind(struct __vxge_hw_device
*hldev
)
579 * If the previous link state is not down, return.
581 if (hldev
->link_state
== VXGE_HW_LINK_UP
)
584 hldev
->link_state
= VXGE_HW_LINK_UP
;
587 if (hldev
->uld_callbacks
->link_up
)
588 hldev
->uld_callbacks
->link_up(hldev
);
594 * __vxge_hw_vpath_alarm_process - Process Alarms.
595 * @vpath: Virtual Path.
596 * @skip_alarms: Do not clear the alarms
598 * Process vpath alarms.
601 static enum vxge_hw_status
602 __vxge_hw_vpath_alarm_process(struct __vxge_hw_virtualpath
*vpath
,
608 struct __vxge_hw_device
*hldev
= NULL
;
609 enum vxge_hw_event alarm_event
= VXGE_HW_EVENT_UNKNOWN
;
611 struct vxge_hw_vpath_stats_sw_info
*sw_stats
;
612 struct vxge_hw_vpath_reg __iomem
*vp_reg
;
615 alarm_event
= VXGE_HW_SET_LEVEL(VXGE_HW_EVENT_UNKNOWN
,
620 hldev
= vpath
->hldev
;
621 vp_reg
= vpath
->vp_reg
;
622 alarm_status
= readq(&vp_reg
->vpath_general_int_status
);
624 if (alarm_status
== VXGE_HW_ALL_FOXES
) {
625 alarm_event
= VXGE_HW_SET_LEVEL(VXGE_HW_EVENT_SLOT_FREEZE
,
630 sw_stats
= vpath
->sw_stats
;
632 if (alarm_status
& ~(
633 VXGE_HW_VPATH_GENERAL_INT_STATUS_PIC_INT
|
634 VXGE_HW_VPATH_GENERAL_INT_STATUS_PCI_INT
|
635 VXGE_HW_VPATH_GENERAL_INT_STATUS_WRDMA_INT
|
636 VXGE_HW_VPATH_GENERAL_INT_STATUS_XMAC_INT
)) {
637 sw_stats
->error_stats
.unknown_alarms
++;
639 alarm_event
= VXGE_HW_SET_LEVEL(VXGE_HW_EVENT_UNKNOWN
,
644 if (alarm_status
& VXGE_HW_VPATH_GENERAL_INT_STATUS_XMAC_INT
) {
646 val64
= readq(&vp_reg
->xgmac_vp_int_status
);
649 VXGE_HW_XGMAC_VP_INT_STATUS_ASIC_NTWK_VP_ERR_ASIC_NTWK_VP_INT
) {
651 val64
= readq(&vp_reg
->asic_ntwk_vp_err_reg
);
654 VXGE_HW_ASIC_NW_VP_ERR_REG_XMACJ_STN_FLT
) &&
656 VXGE_HW_ASIC_NW_VP_ERR_REG_XMACJ_STN_OK
))) ||
658 VXGE_HW_ASIC_NW_VP_ERR_REG_XMACJ_STN_FLT_OCCURR
) &&
660 VXGE_HW_ASIC_NW_VP_ERR_REG_XMACJ_STN_OK_OCCURR
)
662 sw_stats
->error_stats
.network_sustained_fault
++;
665 VXGE_HW_ASIC_NW_VP_ERR_REG_XMACJ_STN_FLT
,
666 &vp_reg
->asic_ntwk_vp_err_mask
);
668 __vxge_hw_device_handle_link_down_ind(hldev
);
669 alarm_event
= VXGE_HW_SET_LEVEL(
670 VXGE_HW_EVENT_LINK_DOWN
, alarm_event
);
674 VXGE_HW_ASIC_NW_VP_ERR_REG_XMACJ_STN_OK
) &&
676 VXGE_HW_ASIC_NW_VP_ERR_REG_XMACJ_STN_FLT
))) ||
678 VXGE_HW_ASIC_NW_VP_ERR_REG_XMACJ_STN_OK_OCCURR
) &&
680 VXGE_HW_ASIC_NW_VP_ERR_REG_XMACJ_STN_FLT_OCCURR
)
683 sw_stats
->error_stats
.network_sustained_ok
++;
686 VXGE_HW_ASIC_NW_VP_ERR_REG_XMACJ_STN_OK
,
687 &vp_reg
->asic_ntwk_vp_err_mask
);
689 __vxge_hw_device_handle_link_up_ind(hldev
);
690 alarm_event
= VXGE_HW_SET_LEVEL(
691 VXGE_HW_EVENT_LINK_UP
, alarm_event
);
694 writeq(VXGE_HW_INTR_MASK_ALL
,
695 &vp_reg
->asic_ntwk_vp_err_reg
);
697 alarm_event
= VXGE_HW_SET_LEVEL(
698 VXGE_HW_EVENT_ALARM_CLEARED
, alarm_event
);
705 if (alarm_status
& VXGE_HW_VPATH_GENERAL_INT_STATUS_PIC_INT
) {
707 pic_status
= readq(&vp_reg
->vpath_ppif_int_status
);
710 VXGE_HW_VPATH_PPIF_INT_STATUS_GENERAL_ERRORS_GENERAL_INT
) {
712 val64
= readq(&vp_reg
->general_errors_reg
);
713 mask64
= readq(&vp_reg
->general_errors_mask
);
716 VXGE_HW_GENERAL_ERRORS_REG_INI_SERR_DET
) &
718 sw_stats
->error_stats
.ini_serr_det
++;
720 alarm_event
= VXGE_HW_SET_LEVEL(
721 VXGE_HW_EVENT_SERR
, alarm_event
);
725 VXGE_HW_GENERAL_ERRORS_REG_DBLGEN_FIFO0_OVRFLOW
) &
727 sw_stats
->error_stats
.dblgen_fifo0_overflow
++;
729 alarm_event
= VXGE_HW_SET_LEVEL(
730 VXGE_HW_EVENT_FIFO_ERR
, alarm_event
);
734 VXGE_HW_GENERAL_ERRORS_REG_STATSB_PIF_CHAIN_ERR
) &
736 sw_stats
->error_stats
.statsb_pif_chain_error
++;
739 VXGE_HW_GENERAL_ERRORS_REG_STATSB_DROP_TIMEOUT_REQ
) &
741 sw_stats
->error_stats
.statsb_drop_timeout
++;
744 VXGE_HW_GENERAL_ERRORS_REG_TGT_ILLEGAL_ACCESS
) &
746 sw_stats
->error_stats
.target_illegal_access
++;
749 writeq(VXGE_HW_INTR_MASK_ALL
,
750 &vp_reg
->general_errors_reg
);
751 alarm_event
= VXGE_HW_SET_LEVEL(
752 VXGE_HW_EVENT_ALARM_CLEARED
,
758 VXGE_HW_VPATH_PPIF_INT_STATUS_KDFCCTL_ERRORS_KDFCCTL_INT
) {
760 val64
= readq(&vp_reg
->kdfcctl_errors_reg
);
761 mask64
= readq(&vp_reg
->kdfcctl_errors_mask
);
764 VXGE_HW_KDFCCTL_ERRORS_REG_KDFCCTL_FIFO0_OVRWR
) &
766 sw_stats
->error_stats
.kdfcctl_fifo0_overwrite
++;
768 alarm_event
= VXGE_HW_SET_LEVEL(
769 VXGE_HW_EVENT_FIFO_ERR
,
774 VXGE_HW_KDFCCTL_ERRORS_REG_KDFCCTL_FIFO0_POISON
) &
776 sw_stats
->error_stats
.kdfcctl_fifo0_poison
++;
778 alarm_event
= VXGE_HW_SET_LEVEL(
779 VXGE_HW_EVENT_FIFO_ERR
,
784 VXGE_HW_KDFCCTL_ERRORS_REG_KDFCCTL_FIFO0_DMA_ERR
) &
786 sw_stats
->error_stats
.kdfcctl_fifo0_dma_error
++;
788 alarm_event
= VXGE_HW_SET_LEVEL(
789 VXGE_HW_EVENT_FIFO_ERR
,
794 writeq(VXGE_HW_INTR_MASK_ALL
,
795 &vp_reg
->kdfcctl_errors_reg
);
796 alarm_event
= VXGE_HW_SET_LEVEL(
797 VXGE_HW_EVENT_ALARM_CLEARED
,
804 if (alarm_status
& VXGE_HW_VPATH_GENERAL_INT_STATUS_WRDMA_INT
) {
806 val64
= readq(&vp_reg
->wrdma_alarm_status
);
808 if (val64
& VXGE_HW_WRDMA_ALARM_STATUS_PRC_ALARM_PRC_INT
) {
810 val64
= readq(&vp_reg
->prc_alarm_reg
);
811 mask64
= readq(&vp_reg
->prc_alarm_mask
);
813 if ((val64
& VXGE_HW_PRC_ALARM_REG_PRC_RING_BUMP
)&
815 sw_stats
->error_stats
.prc_ring_bumps
++;
817 if ((val64
& VXGE_HW_PRC_ALARM_REG_PRC_RXDCM_SC_ERR
) &
819 sw_stats
->error_stats
.prc_rxdcm_sc_err
++;
821 alarm_event
= VXGE_HW_SET_LEVEL(
822 VXGE_HW_EVENT_VPATH_ERR
,
826 if ((val64
& VXGE_HW_PRC_ALARM_REG_PRC_RXDCM_SC_ABORT
)
828 sw_stats
->error_stats
.prc_rxdcm_sc_abort
++;
830 alarm_event
= VXGE_HW_SET_LEVEL(
831 VXGE_HW_EVENT_VPATH_ERR
,
835 if ((val64
& VXGE_HW_PRC_ALARM_REG_PRC_QUANTA_SIZE_ERR
)
837 sw_stats
->error_stats
.prc_quanta_size_err
++;
839 alarm_event
= VXGE_HW_SET_LEVEL(
840 VXGE_HW_EVENT_VPATH_ERR
,
845 writeq(VXGE_HW_INTR_MASK_ALL
,
846 &vp_reg
->prc_alarm_reg
);
847 alarm_event
= VXGE_HW_SET_LEVEL(
848 VXGE_HW_EVENT_ALARM_CLEARED
,
854 hldev
->stats
.sw_dev_err_stats
.vpath_alarms
++;
856 if ((alarm_event
== VXGE_HW_EVENT_ALARM_CLEARED
) ||
857 (alarm_event
== VXGE_HW_EVENT_UNKNOWN
))
860 __vxge_hw_device_handle_error(hldev
, vpath
->vp_id
, alarm_event
);
862 if (alarm_event
== VXGE_HW_EVENT_SERR
)
863 return VXGE_HW_ERR_CRITICAL
;
865 return (alarm_event
== VXGE_HW_EVENT_SLOT_FREEZE
) ?
866 VXGE_HW_ERR_SLOT_FREEZE
:
867 (alarm_event
== VXGE_HW_EVENT_FIFO_ERR
) ? VXGE_HW_ERR_FIFO
:
872 * vxge_hw_device_begin_irq - Begin IRQ processing.
873 * @hldev: HW device handle.
874 * @skip_alarms: Do not clear the alarms
875 * @reason: "Reason" for the interrupt, the value of Titan's
876 * general_int_status register.
878 * The function performs two actions, It first checks whether (shared IRQ) the
879 * interrupt was raised by the device. Next, it masks the device interrupts.
882 * vxge_hw_device_begin_irq() does not flush MMIO writes through the
883 * bridge. Therefore, two back-to-back interrupts are potentially possible.
885 * Returns: 0, if the interrupt is not "ours" (note that in this case the
886 * device remain enabled).
887 * Otherwise, vxge_hw_device_begin_irq() returns 64bit general adapter
890 enum vxge_hw_status
vxge_hw_device_begin_irq(struct __vxge_hw_device
*hldev
,
891 u32 skip_alarms
, u64
*reason
)
897 enum vxge_hw_status ret
= VXGE_HW_OK
;
899 val64
= readq(&hldev
->common_reg
->titan_general_int_status
);
901 if (unlikely(!val64
)) {
902 /* not Titan interrupt */
904 ret
= VXGE_HW_ERR_WRONG_IRQ
;
908 if (unlikely(val64
== VXGE_HW_ALL_FOXES
)) {
910 adapter_status
= readq(&hldev
->common_reg
->adapter_status
);
912 if (adapter_status
== VXGE_HW_ALL_FOXES
) {
914 __vxge_hw_device_handle_error(hldev
,
915 NULL_VPID
, VXGE_HW_EVENT_SLOT_FREEZE
);
917 ret
= VXGE_HW_ERR_SLOT_FREEZE
;
922 hldev
->stats
.sw_dev_info_stats
.total_intr_cnt
++;
926 vpath_mask
= hldev
->vpaths_deployed
>>
927 (64 - VXGE_HW_MAX_VIRTUAL_PATHS
);
930 VXGE_HW_TITAN_GENERAL_INT_STATUS_VPATH_TRAFFIC_INT(vpath_mask
)) {
931 hldev
->stats
.sw_dev_info_stats
.traffic_intr_cnt
++;
936 hldev
->stats
.sw_dev_info_stats
.not_traffic_intr_cnt
++;
939 VXGE_HW_TITAN_GENERAL_INT_STATUS_VPATH_ALARM_INT
)) {
941 enum vxge_hw_status error_level
= VXGE_HW_OK
;
943 hldev
->stats
.sw_dev_err_stats
.vpath_alarms
++;
945 for (i
= 0; i
< VXGE_HW_MAX_VIRTUAL_PATHS
; i
++) {
947 if (!(hldev
->vpaths_deployed
& vxge_mBIT(i
)))
950 ret
= __vxge_hw_vpath_alarm_process(
951 &hldev
->virtual_paths
[i
], skip_alarms
);
953 error_level
= VXGE_HW_SET_LEVEL(ret
, error_level
);
955 if (unlikely((ret
== VXGE_HW_ERR_CRITICAL
) ||
956 (ret
== VXGE_HW_ERR_SLOT_FREEZE
)))
967 * vxge_hw_device_clear_tx_rx - Acknowledge (that is, clear) the
968 * condition that has caused the Tx and RX interrupt.
971 * Acknowledge (that is, clear) the condition that has caused
972 * the Tx and Rx interrupt.
973 * See also: vxge_hw_device_begin_irq(),
974 * vxge_hw_device_mask_tx_rx(), vxge_hw_device_unmask_tx_rx().
976 void vxge_hw_device_clear_tx_rx(struct __vxge_hw_device
*hldev
)
979 if ((hldev
->tim_int_mask0
[VXGE_HW_VPATH_INTR_TX
] != 0) ||
980 (hldev
->tim_int_mask0
[VXGE_HW_VPATH_INTR_RX
] != 0)) {
981 writeq((hldev
->tim_int_mask0
[VXGE_HW_VPATH_INTR_TX
] |
982 hldev
->tim_int_mask0
[VXGE_HW_VPATH_INTR_RX
]),
983 &hldev
->common_reg
->tim_int_status0
);
986 if ((hldev
->tim_int_mask1
[VXGE_HW_VPATH_INTR_TX
] != 0) ||
987 (hldev
->tim_int_mask1
[VXGE_HW_VPATH_INTR_RX
] != 0)) {
988 __vxge_hw_pio_mem_write32_upper(
989 (hldev
->tim_int_mask1
[VXGE_HW_VPATH_INTR_TX
] |
990 hldev
->tim_int_mask1
[VXGE_HW_VPATH_INTR_RX
]),
991 &hldev
->common_reg
->tim_int_status1
);
996 * vxge_hw_channel_dtr_alloc - Allocate a dtr from the channel
998 * @dtrh: Buffer to return the DTR pointer
1000 * Allocates a dtr from the reserve array. If the reserve array is empty,
1001 * it swaps the reserve and free arrays.
1004 static enum vxge_hw_status
1005 vxge_hw_channel_dtr_alloc(struct __vxge_hw_channel
*channel
, void **dtrh
)
1009 if (channel
->reserve_ptr
- channel
->reserve_top
> 0) {
1011 *dtrh
= channel
->reserve_arr
[--channel
->reserve_ptr
];
1016 /* switch between empty and full arrays */
1018 /* the idea behind such a design is that by having free and reserved
1019 * arrays separated we basically separated irq and non-irq parts.
1020 * i.e. no additional lock need to be done when we free a resource */
1022 if (channel
->length
- channel
->free_ptr
> 0) {
1024 tmp_arr
= channel
->reserve_arr
;
1025 channel
->reserve_arr
= channel
->free_arr
;
1026 channel
->free_arr
= tmp_arr
;
1027 channel
->reserve_ptr
= channel
->length
;
1028 channel
->reserve_top
= channel
->free_ptr
;
1029 channel
->free_ptr
= channel
->length
;
1031 channel
->stats
->reserve_free_swaps_cnt
++;
1033 goto _alloc_after_swap
;
1036 channel
->stats
->full_cnt
++;
1039 return VXGE_HW_INF_OUT_OF_DESCRIPTORS
;
1043 * vxge_hw_channel_dtr_post - Post a dtr to the channel
1044 * @channelh: Channel
1045 * @dtrh: DTR pointer
1047 * Posts a dtr to work array.
1051 vxge_hw_channel_dtr_post(struct __vxge_hw_channel
*channel
, void *dtrh
)
1053 vxge_assert(channel
->work_arr
[channel
->post_index
] == NULL
);
1055 channel
->work_arr
[channel
->post_index
++] = dtrh
;
1058 if (channel
->post_index
== channel
->length
)
1059 channel
->post_index
= 0;
1063 * vxge_hw_channel_dtr_try_complete - Returns next completed dtr
1065 * @dtr: Buffer to return the next completed DTR pointer
1067 * Returns the next completed dtr with out removing it from work array
1071 vxge_hw_channel_dtr_try_complete(struct __vxge_hw_channel
*channel
, void **dtrh
)
1073 vxge_assert(channel
->compl_index
< channel
->length
);
1075 *dtrh
= channel
->work_arr
[channel
->compl_index
];
1080 * vxge_hw_channel_dtr_complete - Removes next completed dtr from the work array
1081 * @channel: Channel handle
1083 * Removes the next completed dtr from work array
1086 void vxge_hw_channel_dtr_complete(struct __vxge_hw_channel
*channel
)
1088 channel
->work_arr
[channel
->compl_index
] = NULL
;
1091 if (++channel
->compl_index
== channel
->length
)
1092 channel
->compl_index
= 0;
1094 channel
->stats
->total_compl_cnt
++;
1098 * vxge_hw_channel_dtr_free - Frees a dtr
1099 * @channel: Channel handle
1102 * Returns the dtr to free array
1105 void vxge_hw_channel_dtr_free(struct __vxge_hw_channel
*channel
, void *dtrh
)
1107 channel
->free_arr
[--channel
->free_ptr
] = dtrh
;
1111 * vxge_hw_channel_dtr_count
1112 * @channel: Channel handle. Obtained via vxge_hw_channel_open().
1114 * Retrieve number of DTRs available. This function can not be called
1115 * from data path. ring_initial_replenishi() is the only user.
1117 int vxge_hw_channel_dtr_count(struct __vxge_hw_channel
*channel
)
1119 return (channel
->reserve_ptr
- channel
->reserve_top
) +
1120 (channel
->length
- channel
->free_ptr
);
1124 * vxge_hw_ring_rxd_reserve - Reserve ring descriptor.
1125 * @ring: Handle to the ring object used for receive
1126 * @rxdh: Reserved descriptor. On success HW fills this "out" parameter
1127 * with a valid handle.
1129 * Reserve Rx descriptor for the subsequent filling-in driver
1130 * and posting on the corresponding channel (@channelh)
1131 * via vxge_hw_ring_rxd_post().
1133 * Returns: VXGE_HW_OK - success.
1134 * VXGE_HW_INF_OUT_OF_DESCRIPTORS - Currently no descriptors available.
1137 enum vxge_hw_status
vxge_hw_ring_rxd_reserve(struct __vxge_hw_ring
*ring
,
1140 enum vxge_hw_status status
;
1141 struct __vxge_hw_channel
*channel
;
1143 channel
= &ring
->channel
;
1145 status
= vxge_hw_channel_dtr_alloc(channel
, rxdh
);
1147 if (status
== VXGE_HW_OK
) {
1148 struct vxge_hw_ring_rxd_1
*rxdp
=
1149 (struct vxge_hw_ring_rxd_1
*)*rxdh
;
1151 rxdp
->control_0
= rxdp
->control_1
= 0;
1158 * vxge_hw_ring_rxd_free - Free descriptor.
1159 * @ring: Handle to the ring object used for receive
1160 * @rxdh: Descriptor handle.
1162 * Free the reserved descriptor. This operation is "symmetrical" to
1163 * vxge_hw_ring_rxd_reserve. The "free-ing" completes the descriptor's
1166 * After free-ing (see vxge_hw_ring_rxd_free()) the descriptor again can
1169 * - reserved (vxge_hw_ring_rxd_reserve);
1171 * - posted (vxge_hw_ring_rxd_post);
1173 * - completed (vxge_hw_ring_rxd_next_completed);
1175 * - and recycled again (vxge_hw_ring_rxd_free).
1177 * For alternative state transitions and more details please refer to
1181 void vxge_hw_ring_rxd_free(struct __vxge_hw_ring
*ring
, void *rxdh
)
1183 struct __vxge_hw_channel
*channel
;
1185 channel
= &ring
->channel
;
1187 vxge_hw_channel_dtr_free(channel
, rxdh
);
1192 * vxge_hw_ring_rxd_pre_post - Prepare rxd and post
1193 * @ring: Handle to the ring object used for receive
1194 * @rxdh: Descriptor handle.
1196 * This routine prepares a rxd and posts
1198 void vxge_hw_ring_rxd_pre_post(struct __vxge_hw_ring
*ring
, void *rxdh
)
1200 struct __vxge_hw_channel
*channel
;
1202 channel
= &ring
->channel
;
1204 vxge_hw_channel_dtr_post(channel
, rxdh
);
1208 * vxge_hw_ring_rxd_post_post - Process rxd after post.
1209 * @ring: Handle to the ring object used for receive
1210 * @rxdh: Descriptor handle.
1212 * Processes rxd after post
1214 void vxge_hw_ring_rxd_post_post(struct __vxge_hw_ring
*ring
, void *rxdh
)
1216 struct vxge_hw_ring_rxd_1
*rxdp
= (struct vxge_hw_ring_rxd_1
*)rxdh
;
1217 struct __vxge_hw_channel
*channel
;
1219 channel
= &ring
->channel
;
1221 rxdp
->control_0
= VXGE_HW_RING_RXD_LIST_OWN_ADAPTER
;
1223 if (ring
->stats
->common_stats
.usage_cnt
> 0)
1224 ring
->stats
->common_stats
.usage_cnt
--;
1228 * vxge_hw_ring_rxd_post - Post descriptor on the ring.
1229 * @ring: Handle to the ring object used for receive
1230 * @rxdh: Descriptor obtained via vxge_hw_ring_rxd_reserve().
1232 * Post descriptor on the ring.
1233 * Prior to posting the descriptor should be filled in accordance with
1234 * Host/Titan interface specification for a given service (LL, etc.).
1237 void vxge_hw_ring_rxd_post(struct __vxge_hw_ring
*ring
, void *rxdh
)
1239 struct vxge_hw_ring_rxd_1
*rxdp
= (struct vxge_hw_ring_rxd_1
*)rxdh
;
1240 struct __vxge_hw_channel
*channel
;
1242 channel
= &ring
->channel
;
1245 rxdp
->control_0
= VXGE_HW_RING_RXD_LIST_OWN_ADAPTER
;
1247 vxge_hw_channel_dtr_post(channel
, rxdh
);
1249 if (ring
->stats
->common_stats
.usage_cnt
> 0)
1250 ring
->stats
->common_stats
.usage_cnt
--;
1254 * vxge_hw_ring_rxd_post_post_wmb - Process rxd after post with memory barrier.
1255 * @ring: Handle to the ring object used for receive
1256 * @rxdh: Descriptor handle.
1258 * Processes rxd after post with memory barrier.
1260 void vxge_hw_ring_rxd_post_post_wmb(struct __vxge_hw_ring
*ring
, void *rxdh
)
1263 vxge_hw_ring_rxd_post_post(ring
, rxdh
);
1267 * vxge_hw_ring_rxd_next_completed - Get the _next_ completed descriptor.
1268 * @ring: Handle to the ring object used for receive
1269 * @rxdh: Descriptor handle. Returned by HW.
1270 * @t_code: Transfer code, as per Titan User Guide,
1271 * Receive Descriptor Format. Returned by HW.
1273 * Retrieve the _next_ completed descriptor.
1274 * HW uses ring callback (*vxge_hw_ring_callback_f) to notifiy
1275 * driver of new completed descriptors. After that
1276 * the driver can use vxge_hw_ring_rxd_next_completed to retrieve the rest
1277 * completions (the very first completion is passed by HW via
1278 * vxge_hw_ring_callback_f).
1280 * Implementation-wise, the driver is free to call
1281 * vxge_hw_ring_rxd_next_completed either immediately from inside the
1282 * ring callback, or in a deferred fashion and separate (from HW)
1285 * Non-zero @t_code means failure to fill-in receive buffer(s)
1286 * of the descriptor.
1287 * For instance, parity error detected during the data transfer.
1288 * In this case Titan will complete the descriptor and indicate
1289 * for the host that the received data is not to be used.
1290 * For details please refer to Titan User Guide.
1292 * Returns: VXGE_HW_OK - success.
1293 * VXGE_HW_INF_NO_MORE_COMPLETED_DESCRIPTORS - No completed descriptors
1294 * are currently available for processing.
1296 * See also: vxge_hw_ring_callback_f{},
1297 * vxge_hw_fifo_rxd_next_completed(), enum vxge_hw_status{}.
1299 enum vxge_hw_status
vxge_hw_ring_rxd_next_completed(
1300 struct __vxge_hw_ring
*ring
, void **rxdh
, u8
*t_code
)
1302 struct __vxge_hw_channel
*channel
;
1303 struct vxge_hw_ring_rxd_1
*rxdp
;
1304 enum vxge_hw_status status
= VXGE_HW_OK
;
1307 channel
= &ring
->channel
;
1309 vxge_hw_channel_dtr_try_complete(channel
, rxdh
);
1313 status
= VXGE_HW_INF_NO_MORE_COMPLETED_DESCRIPTORS
;
1317 control_0
= rxdp
->control_0
;
1318 own
= control_0
& VXGE_HW_RING_RXD_LIST_OWN_ADAPTER
;
1319 *t_code
= (u8
)VXGE_HW_RING_RXD_T_CODE_GET(control_0
);
1321 /* check whether it is not the end */
1322 if (!own
|| *t_code
== VXGE_HW_RING_T_CODE_FRM_DROP
) {
1324 vxge_assert((rxdp
)->host_control
!=
1328 vxge_hw_channel_dtr_complete(channel
);
1330 vxge_assert(*t_code
!= VXGE_HW_RING_RXD_T_CODE_UNUSED
);
1332 ring
->stats
->common_stats
.usage_cnt
++;
1333 if (ring
->stats
->common_stats
.usage_max
<
1334 ring
->stats
->common_stats
.usage_cnt
)
1335 ring
->stats
->common_stats
.usage_max
=
1336 ring
->stats
->common_stats
.usage_cnt
;
1338 status
= VXGE_HW_OK
;
1342 /* reset it. since we don't want to return
1343 * garbage to the driver */
1345 status
= VXGE_HW_INF_NO_MORE_COMPLETED_DESCRIPTORS
;
1351 * vxge_hw_ring_handle_tcode - Handle transfer code.
1352 * @ring: Handle to the ring object used for receive
1353 * @rxdh: Descriptor handle.
1354 * @t_code: One of the enumerated (and documented in the Titan user guide)
1357 * Handle descriptor's transfer code. The latter comes with each completed
1360 * Returns: one of the enum vxge_hw_status{} enumerated types.
1361 * VXGE_HW_OK - for success.
1362 * VXGE_HW_ERR_CRITICAL - when encounters critical error.
1364 enum vxge_hw_status
vxge_hw_ring_handle_tcode(
1365 struct __vxge_hw_ring
*ring
, void *rxdh
, u8 t_code
)
1367 struct __vxge_hw_channel
*channel
;
1368 enum vxge_hw_status status
= VXGE_HW_OK
;
1370 channel
= &ring
->channel
;
1372 /* If the t_code is not supported and if the
1373 * t_code is other than 0x5 (unparseable packet
1374 * such as unknown UPV6 header), Drop it !!!
1377 if (t_code
== VXGE_HW_RING_T_CODE_OK
||
1378 t_code
== VXGE_HW_RING_T_CODE_L3_PKT_ERR
) {
1379 status
= VXGE_HW_OK
;
1383 if (t_code
> VXGE_HW_RING_T_CODE_MULTI_ERR
) {
1384 status
= VXGE_HW_ERR_INVALID_TCODE
;
1388 ring
->stats
->rxd_t_code_err_cnt
[t_code
]++;
1394 * __vxge_hw_non_offload_db_post - Post non offload doorbell
1397 * @txdl_ptr: The starting location of the TxDL in host memory
1398 * @num_txds: The highest TxD in this TxDL (0 to 255 means 1 to 256)
1399 * @no_snoop: No snoop flags
1401 * This function posts a non-offload doorbell to doorbell FIFO
1404 static void __vxge_hw_non_offload_db_post(struct __vxge_hw_fifo
*fifo
,
1405 u64 txdl_ptr
, u32 num_txds
, u32 no_snoop
)
1407 struct __vxge_hw_channel
*channel
;
1409 channel
= &fifo
->channel
;
1411 writeq(VXGE_HW_NODBW_TYPE(VXGE_HW_NODBW_TYPE_NODBW
) |
1412 VXGE_HW_NODBW_LAST_TXD_NUMBER(num_txds
) |
1413 VXGE_HW_NODBW_GET_NO_SNOOP(no_snoop
),
1414 &fifo
->nofl_db
->control_0
);
1418 writeq(txdl_ptr
, &fifo
->nofl_db
->txdl_ptr
);
1424 * vxge_hw_fifo_free_txdl_count_get - returns the number of txdls available in
1426 * @fifoh: Handle to the fifo object used for non offload send
1428 u32
vxge_hw_fifo_free_txdl_count_get(struct __vxge_hw_fifo
*fifoh
)
1430 return vxge_hw_channel_dtr_count(&fifoh
->channel
);
1434 * vxge_hw_fifo_txdl_reserve - Reserve fifo descriptor.
1435 * @fifoh: Handle to the fifo object used for non offload send
1436 * @txdlh: Reserved descriptor. On success HW fills this "out" parameter
1437 * with a valid handle.
1438 * @txdl_priv: Buffer to return the pointer to per txdl space
1440 * Reserve a single TxDL (that is, fifo descriptor)
1441 * for the subsequent filling-in by driver)
1442 * and posting on the corresponding channel (@channelh)
1443 * via vxge_hw_fifo_txdl_post().
1445 * Note: it is the responsibility of driver to reserve multiple descriptors
1446 * for lengthy (e.g., LSO) transmit operation. A single fifo descriptor
1447 * carries up to configured number (fifo.max_frags) of contiguous buffers.
1449 * Returns: VXGE_HW_OK - success;
1450 * VXGE_HW_INF_OUT_OF_DESCRIPTORS - Currently no descriptors available
1453 enum vxge_hw_status
vxge_hw_fifo_txdl_reserve(
1454 struct __vxge_hw_fifo
*fifo
,
1455 void **txdlh
, void **txdl_priv
)
1457 struct __vxge_hw_channel
*channel
;
1458 enum vxge_hw_status status
;
1461 channel
= &fifo
->channel
;
1463 status
= vxge_hw_channel_dtr_alloc(channel
, txdlh
);
1465 if (status
== VXGE_HW_OK
) {
1466 struct vxge_hw_fifo_txd
*txdp
=
1467 (struct vxge_hw_fifo_txd
*)*txdlh
;
1468 struct __vxge_hw_fifo_txdl_priv
*priv
;
1470 priv
= __vxge_hw_fifo_txdl_priv(fifo
, txdp
);
1472 /* reset the TxDL's private */
1473 priv
->align_dma_offset
= 0;
1474 priv
->align_vaddr_start
= priv
->align_vaddr
;
1475 priv
->align_used_frags
= 0;
1477 priv
->alloc_frags
= fifo
->config
->max_frags
;
1478 priv
->next_txdl_priv
= NULL
;
1480 *txdl_priv
= (void *)(size_t)txdp
->host_control
;
1482 for (i
= 0; i
< fifo
->config
->max_frags
; i
++) {
1483 txdp
= ((struct vxge_hw_fifo_txd
*)*txdlh
) + i
;
1484 txdp
->control_0
= txdp
->control_1
= 0;
1492 * vxge_hw_fifo_txdl_buffer_set - Set transmit buffer pointer in the
1494 * @fifo: Handle to the fifo object used for non offload send
1495 * @txdlh: Descriptor handle.
1496 * @frag_idx: Index of the data buffer in the caller's scatter-gather list
1498 * @dma_pointer: DMA address of the data buffer referenced by @frag_idx.
1499 * @size: Size of the data buffer (in bytes).
1501 * This API is part of the preparation of the transmit descriptor for posting
1502 * (via vxge_hw_fifo_txdl_post()). The related "preparation" APIs include
1503 * vxge_hw_fifo_txdl_mss_set() and vxge_hw_fifo_txdl_cksum_set_bits().
1504 * All three APIs fill in the fields of the fifo descriptor,
1505 * in accordance with the Titan specification.
1508 void vxge_hw_fifo_txdl_buffer_set(struct __vxge_hw_fifo
*fifo
,
1509 void *txdlh
, u32 frag_idx
,
1510 dma_addr_t dma_pointer
, u32 size
)
1512 struct __vxge_hw_fifo_txdl_priv
*txdl_priv
;
1513 struct vxge_hw_fifo_txd
*txdp
, *txdp_last
;
1514 struct __vxge_hw_channel
*channel
;
1516 channel
= &fifo
->channel
;
1518 txdl_priv
= __vxge_hw_fifo_txdl_priv(fifo
, txdlh
);
1519 txdp
= (struct vxge_hw_fifo_txd
*)txdlh
+ txdl_priv
->frags
;
1522 txdp
->control_0
= txdp
->control_1
= 0;
1524 txdp
->control_0
|= VXGE_HW_FIFO_TXD_GATHER_CODE(
1525 VXGE_HW_FIFO_TXD_GATHER_CODE_FIRST
);
1526 txdp
->control_1
|= fifo
->interrupt_type
;
1527 txdp
->control_1
|= VXGE_HW_FIFO_TXD_INT_NUMBER(
1529 if (txdl_priv
->frags
) {
1530 txdp_last
= (struct vxge_hw_fifo_txd
*)txdlh
+
1531 (txdl_priv
->frags
- 1);
1532 txdp_last
->control_0
|= VXGE_HW_FIFO_TXD_GATHER_CODE(
1533 VXGE_HW_FIFO_TXD_GATHER_CODE_LAST
);
1537 vxge_assert(frag_idx
< txdl_priv
->alloc_frags
);
1539 txdp
->buffer_pointer
= (u64
)dma_pointer
;
1540 txdp
->control_0
|= VXGE_HW_FIFO_TXD_BUFFER_SIZE(size
);
1541 fifo
->stats
->total_buffers
++;
1546 * vxge_hw_fifo_txdl_post - Post descriptor on the fifo channel.
1547 * @fifo: Handle to the fifo object used for non offload send
1548 * @txdlh: Descriptor obtained via vxge_hw_fifo_txdl_reserve()
1549 * @frags: Number of contiguous buffers that are part of a single
1550 * transmit operation.
1552 * Post descriptor on the 'fifo' type channel for transmission.
1553 * Prior to posting the descriptor should be filled in accordance with
1554 * Host/Titan interface specification for a given service (LL, etc.).
1557 void vxge_hw_fifo_txdl_post(struct __vxge_hw_fifo
*fifo
, void *txdlh
)
1559 struct __vxge_hw_fifo_txdl_priv
*txdl_priv
;
1560 struct vxge_hw_fifo_txd
*txdp_last
;
1561 struct vxge_hw_fifo_txd
*txdp_first
;
1562 struct __vxge_hw_channel
*channel
;
1564 channel
= &fifo
->channel
;
1566 txdl_priv
= __vxge_hw_fifo_txdl_priv(fifo
, txdlh
);
1569 txdp_last
= (struct vxge_hw_fifo_txd
*)txdlh
+ (txdl_priv
->frags
- 1);
1570 txdp_last
->control_0
|=
1571 VXGE_HW_FIFO_TXD_GATHER_CODE(VXGE_HW_FIFO_TXD_GATHER_CODE_LAST
);
1572 txdp_first
->control_0
|= VXGE_HW_FIFO_TXD_LIST_OWN_ADAPTER
;
1574 vxge_hw_channel_dtr_post(&fifo
->channel
, txdlh
);
1576 __vxge_hw_non_offload_db_post(fifo
,
1577 (u64
)txdl_priv
->dma_addr
,
1578 txdl_priv
->frags
- 1,
1579 fifo
->no_snoop_bits
);
1581 fifo
->stats
->total_posts
++;
1582 fifo
->stats
->common_stats
.usage_cnt
++;
1583 if (fifo
->stats
->common_stats
.usage_max
<
1584 fifo
->stats
->common_stats
.usage_cnt
)
1585 fifo
->stats
->common_stats
.usage_max
=
1586 fifo
->stats
->common_stats
.usage_cnt
;
1590 * vxge_hw_fifo_txdl_next_completed - Retrieve next completed descriptor.
1591 * @fifo: Handle to the fifo object used for non offload send
1592 * @txdlh: Descriptor handle. Returned by HW.
1593 * @t_code: Transfer code, as per Titan User Guide,
1594 * Transmit Descriptor Format.
1597 * Retrieve the _next_ completed descriptor.
1598 * HW uses channel callback (*vxge_hw_channel_callback_f) to notifiy
1599 * driver of new completed descriptors. After that
1600 * the driver can use vxge_hw_fifo_txdl_next_completed to retrieve the rest
1601 * completions (the very first completion is passed by HW via
1602 * vxge_hw_channel_callback_f).
1604 * Implementation-wise, the driver is free to call
1605 * vxge_hw_fifo_txdl_next_completed either immediately from inside the
1606 * channel callback, or in a deferred fashion and separate (from HW)
1609 * Non-zero @t_code means failure to process the descriptor.
1610 * The failure could happen, for instance, when the link is
1611 * down, in which case Titan completes the descriptor because it
1612 * is not able to send the data out.
1614 * For details please refer to Titan User Guide.
1616 * Returns: VXGE_HW_OK - success.
1617 * VXGE_HW_INF_NO_MORE_COMPLETED_DESCRIPTORS - No completed descriptors
1618 * are currently available for processing.
1621 enum vxge_hw_status
vxge_hw_fifo_txdl_next_completed(
1622 struct __vxge_hw_fifo
*fifo
, void **txdlh
,
1623 enum vxge_hw_fifo_tcode
*t_code
)
1625 struct __vxge_hw_channel
*channel
;
1626 struct vxge_hw_fifo_txd
*txdp
;
1627 enum vxge_hw_status status
= VXGE_HW_OK
;
1629 channel
= &fifo
->channel
;
1631 vxge_hw_channel_dtr_try_complete(channel
, txdlh
);
1635 status
= VXGE_HW_INF_NO_MORE_COMPLETED_DESCRIPTORS
;
1639 /* check whether host owns it */
1640 if (!(txdp
->control_0
& VXGE_HW_FIFO_TXD_LIST_OWN_ADAPTER
)) {
1642 vxge_assert(txdp
->host_control
!= 0);
1644 vxge_hw_channel_dtr_complete(channel
);
1646 *t_code
= (u8
)VXGE_HW_FIFO_TXD_T_CODE_GET(txdp
->control_0
);
1648 if (fifo
->stats
->common_stats
.usage_cnt
> 0)
1649 fifo
->stats
->common_stats
.usage_cnt
--;
1651 status
= VXGE_HW_OK
;
1655 /* no more completions */
1657 status
= VXGE_HW_INF_NO_MORE_COMPLETED_DESCRIPTORS
;
1663 * vxge_hw_fifo_handle_tcode - Handle transfer code.
1664 * @fifo: Handle to the fifo object used for non offload send
1665 * @txdlh: Descriptor handle.
1666 * @t_code: One of the enumerated (and documented in the Titan user guide)
1669 * Handle descriptor's transfer code. The latter comes with each completed
1672 * Returns: one of the enum vxge_hw_status{} enumerated types.
1673 * VXGE_HW_OK - for success.
1674 * VXGE_HW_ERR_CRITICAL - when encounters critical error.
1676 enum vxge_hw_status
vxge_hw_fifo_handle_tcode(struct __vxge_hw_fifo
*fifo
,
1678 enum vxge_hw_fifo_tcode t_code
)
1680 struct __vxge_hw_channel
*channel
;
1682 enum vxge_hw_status status
= VXGE_HW_OK
;
1683 channel
= &fifo
->channel
;
1685 if (((t_code
& 0x7) < 0) || ((t_code
& 0x7) > 0x4)) {
1686 status
= VXGE_HW_ERR_INVALID_TCODE
;
1690 fifo
->stats
->txd_t_code_err_cnt
[t_code
]++;
1696 * vxge_hw_fifo_txdl_free - Free descriptor.
1697 * @fifo: Handle to the fifo object used for non offload send
1698 * @txdlh: Descriptor handle.
1700 * Free the reserved descriptor. This operation is "symmetrical" to
1701 * vxge_hw_fifo_txdl_reserve. The "free-ing" completes the descriptor's
1704 * After free-ing (see vxge_hw_fifo_txdl_free()) the descriptor again can
1707 * - reserved (vxge_hw_fifo_txdl_reserve);
1709 * - posted (vxge_hw_fifo_txdl_post);
1711 * - completed (vxge_hw_fifo_txdl_next_completed);
1713 * - and recycled again (vxge_hw_fifo_txdl_free).
1715 * For alternative state transitions and more details please refer to
1719 void vxge_hw_fifo_txdl_free(struct __vxge_hw_fifo
*fifo
, void *txdlh
)
1721 struct __vxge_hw_fifo_txdl_priv
*txdl_priv
;
1723 struct __vxge_hw_channel
*channel
;
1725 channel
= &fifo
->channel
;
1727 txdl_priv
= __vxge_hw_fifo_txdl_priv(fifo
,
1728 (struct vxge_hw_fifo_txd
*)txdlh
);
1730 max_frags
= fifo
->config
->max_frags
;
1732 vxge_hw_channel_dtr_free(channel
, txdlh
);
1736 * vxge_hw_vpath_mac_addr_add - Add the mac address entry for this vpath
1737 * to MAC address table.
1738 * @vp: Vpath handle.
1739 * @macaddr: MAC address to be added for this vpath into the list
1740 * @macaddr_mask: MAC address mask for macaddr
1741 * @duplicate_mode: Duplicate MAC address add mode. Please see
1742 * enum vxge_hw_vpath_mac_addr_add_mode{}
1744 * Adds the given mac address and mac address mask into the list for this
1746 * see also: vxge_hw_vpath_mac_addr_delete, vxge_hw_vpath_mac_addr_get and
1747 * vxge_hw_vpath_mac_addr_get_next
1751 vxge_hw_vpath_mac_addr_add(
1752 struct __vxge_hw_vpath_handle
*vp
,
1753 u8 (macaddr
)[ETH_ALEN
],
1754 u8 (macaddr_mask
)[ETH_ALEN
],
1755 enum vxge_hw_vpath_mac_addr_add_mode duplicate_mode
)
1760 enum vxge_hw_status status
= VXGE_HW_OK
;
1763 status
= VXGE_HW_ERR_INVALID_HANDLE
;
1767 for (i
= 0; i
< ETH_ALEN
; i
++) {
1769 data1
|= (u8
)macaddr
[i
];
1772 data2
|= (u8
)macaddr_mask
[i
];
1775 switch (duplicate_mode
) {
1776 case VXGE_HW_VPATH_MAC_ADDR_ADD_DUPLICATE
:
1779 case VXGE_HW_VPATH_MAC_ADDR_DISCARD_DUPLICATE
:
1782 case VXGE_HW_VPATH_MAC_ADDR_REPLACE_DUPLICATE
:
1790 status
= __vxge_hw_vpath_rts_table_set(vp
,
1791 VXGE_HW_RTS_ACCESS_STEER_CTRL_ACTION_ADD_ENTRY
,
1792 VXGE_HW_RTS_ACCESS_STEER_CTRL_DATA_STRUCT_SEL_DA
,
1794 VXGE_HW_RTS_ACCESS_STEER_DATA0_DA_MAC_ADDR(data1
),
1795 VXGE_HW_RTS_ACCESS_STEER_DATA1_DA_MAC_ADDR_MASK(data2
)|
1796 VXGE_HW_RTS_ACCESS_STEER_DATA1_DA_MAC_ADDR_MODE(i
));
1802 * vxge_hw_vpath_mac_addr_get - Get the first mac address entry for this vpath
1803 * from MAC address table.
1804 * @vp: Vpath handle.
1805 * @macaddr: First MAC address entry for this vpath in the list
1806 * @macaddr_mask: MAC address mask for macaddr
1808 * Returns the first mac address and mac address mask in the list for this
1810 * see also: vxge_hw_vpath_mac_addr_get_next
1814 vxge_hw_vpath_mac_addr_get(
1815 struct __vxge_hw_vpath_handle
*vp
,
1816 u8 (macaddr
)[ETH_ALEN
],
1817 u8 (macaddr_mask
)[ETH_ALEN
])
1822 enum vxge_hw_status status
= VXGE_HW_OK
;
1825 status
= VXGE_HW_ERR_INVALID_HANDLE
;
1829 status
= __vxge_hw_vpath_rts_table_get(vp
,
1830 VXGE_HW_RTS_ACCESS_STEER_CTRL_ACTION_LIST_FIRST_ENTRY
,
1831 VXGE_HW_RTS_ACCESS_STEER_CTRL_DATA_STRUCT_SEL_DA
,
1834 if (status
!= VXGE_HW_OK
)
1837 data1
= VXGE_HW_RTS_ACCESS_STEER_DATA0_GET_DA_MAC_ADDR(data1
);
1839 data2
= VXGE_HW_RTS_ACCESS_STEER_DATA1_GET_DA_MAC_ADDR_MASK(data2
);
1841 for (i
= ETH_ALEN
; i
> 0; i
--) {
1842 macaddr
[i
-1] = (u8
)(data1
& 0xFF);
1845 macaddr_mask
[i
-1] = (u8
)(data2
& 0xFF);
1853 * vxge_hw_vpath_mac_addr_get_next - Get the next mac address entry for this
1855 * from MAC address table.
1856 * @vp: Vpath handle.
1857 * @macaddr: Next MAC address entry for this vpath in the list
1858 * @macaddr_mask: MAC address mask for macaddr
1860 * Returns the next mac address and mac address mask in the list for this
1862 * see also: vxge_hw_vpath_mac_addr_get
1866 vxge_hw_vpath_mac_addr_get_next(
1867 struct __vxge_hw_vpath_handle
*vp
,
1868 u8 (macaddr
)[ETH_ALEN
],
1869 u8 (macaddr_mask
)[ETH_ALEN
])
1874 enum vxge_hw_status status
= VXGE_HW_OK
;
1877 status
= VXGE_HW_ERR_INVALID_HANDLE
;
1881 status
= __vxge_hw_vpath_rts_table_get(vp
,
1882 VXGE_HW_RTS_ACCESS_STEER_CTRL_ACTION_LIST_NEXT_ENTRY
,
1883 VXGE_HW_RTS_ACCESS_STEER_CTRL_DATA_STRUCT_SEL_DA
,
1886 if (status
!= VXGE_HW_OK
)
1889 data1
= VXGE_HW_RTS_ACCESS_STEER_DATA0_GET_DA_MAC_ADDR(data1
);
1891 data2
= VXGE_HW_RTS_ACCESS_STEER_DATA1_GET_DA_MAC_ADDR_MASK(data2
);
1893 for (i
= ETH_ALEN
; i
> 0; i
--) {
1894 macaddr
[i
-1] = (u8
)(data1
& 0xFF);
1897 macaddr_mask
[i
-1] = (u8
)(data2
& 0xFF);
1906 * vxge_hw_vpath_mac_addr_delete - Delete the mac address entry for this vpath
1907 * to MAC address table.
1908 * @vp: Vpath handle.
1909 * @macaddr: MAC address to be added for this vpath into the list
1910 * @macaddr_mask: MAC address mask for macaddr
1912 * Delete the given mac address and mac address mask into the list for this
1914 * see also: vxge_hw_vpath_mac_addr_add, vxge_hw_vpath_mac_addr_get and
1915 * vxge_hw_vpath_mac_addr_get_next
1919 vxge_hw_vpath_mac_addr_delete(
1920 struct __vxge_hw_vpath_handle
*vp
,
1921 u8 (macaddr
)[ETH_ALEN
],
1922 u8 (macaddr_mask
)[ETH_ALEN
])
1927 enum vxge_hw_status status
= VXGE_HW_OK
;
1930 status
= VXGE_HW_ERR_INVALID_HANDLE
;
1934 for (i
= 0; i
< ETH_ALEN
; i
++) {
1936 data1
|= (u8
)macaddr
[i
];
1939 data2
|= (u8
)macaddr_mask
[i
];
1942 status
= __vxge_hw_vpath_rts_table_set(vp
,
1943 VXGE_HW_RTS_ACCESS_STEER_CTRL_ACTION_DELETE_ENTRY
,
1944 VXGE_HW_RTS_ACCESS_STEER_CTRL_DATA_STRUCT_SEL_DA
,
1946 VXGE_HW_RTS_ACCESS_STEER_DATA0_DA_MAC_ADDR(data1
),
1947 VXGE_HW_RTS_ACCESS_STEER_DATA1_DA_MAC_ADDR_MASK(data2
));
1953 * vxge_hw_vpath_vid_add - Add the vlan id entry for this vpath
1955 * @vp: Vpath handle.
1956 * @vid: vlan id to be added for this vpath into the list
1958 * Adds the given vlan id into the list for this vpath.
1959 * see also: vxge_hw_vpath_vid_delete
1963 vxge_hw_vpath_vid_add(struct __vxge_hw_vpath_handle
*vp
, u64 vid
)
1965 enum vxge_hw_status status
= VXGE_HW_OK
;
1968 status
= VXGE_HW_ERR_INVALID_HANDLE
;
1972 status
= __vxge_hw_vpath_rts_table_set(vp
,
1973 VXGE_HW_RTS_ACCESS_STEER_CTRL_ACTION_ADD_ENTRY
,
1974 VXGE_HW_RTS_ACCESS_STEER_CTRL_DATA_STRUCT_SEL_VID
,
1975 0, VXGE_HW_RTS_ACCESS_STEER_DATA0_VLAN_ID(vid
), 0);
1981 * vxge_hw_vpath_vid_delete - Delete the vlan id entry for this vpath
1983 * @vp: Vpath handle.
1984 * @vid: vlan id to be added for this vpath into the list
1986 * Adds the given vlan id into the list for this vpath.
1987 * see also: vxge_hw_vpath_vid_add
1991 vxge_hw_vpath_vid_delete(struct __vxge_hw_vpath_handle
*vp
, u64 vid
)
1993 enum vxge_hw_status status
= VXGE_HW_OK
;
1996 status
= VXGE_HW_ERR_INVALID_HANDLE
;
2000 status
= __vxge_hw_vpath_rts_table_set(vp
,
2001 VXGE_HW_RTS_ACCESS_STEER_CTRL_ACTION_DELETE_ENTRY
,
2002 VXGE_HW_RTS_ACCESS_STEER_CTRL_DATA_STRUCT_SEL_VID
,
2003 0, VXGE_HW_RTS_ACCESS_STEER_DATA0_VLAN_ID(vid
), 0);
2009 * vxge_hw_vpath_promisc_enable - Enable promiscuous mode.
2010 * @vp: Vpath handle.
2012 * Enable promiscuous mode of Titan-e operation.
2014 * See also: vxge_hw_vpath_promisc_disable().
2016 enum vxge_hw_status
vxge_hw_vpath_promisc_enable(
2017 struct __vxge_hw_vpath_handle
*vp
)
2020 struct __vxge_hw_virtualpath
*vpath
;
2021 enum vxge_hw_status status
= VXGE_HW_OK
;
2023 if ((vp
== NULL
) || (vp
->vpath
->ringh
== NULL
)) {
2024 status
= VXGE_HW_ERR_INVALID_HANDLE
;
2030 /* Enable promiscuous mode for function 0 only */
2031 if (!(vpath
->hldev
->access_rights
&
2032 VXGE_HW_DEVICE_ACCESS_RIGHT_MRPCIM
))
2035 val64
= readq(&vpath
->vp_reg
->rxmac_vcfg0
);
2037 if (!(val64
& VXGE_HW_RXMAC_VCFG0_UCAST_ALL_ADDR_EN
)) {
2039 val64
|= VXGE_HW_RXMAC_VCFG0_UCAST_ALL_ADDR_EN
|
2040 VXGE_HW_RXMAC_VCFG0_MCAST_ALL_ADDR_EN
|
2041 VXGE_HW_RXMAC_VCFG0_BCAST_EN
|
2042 VXGE_HW_RXMAC_VCFG0_ALL_VID_EN
;
2044 writeq(val64
, &vpath
->vp_reg
->rxmac_vcfg0
);
2051 * vxge_hw_vpath_promisc_disable - Disable promiscuous mode.
2052 * @vp: Vpath handle.
2054 * Disable promiscuous mode of Titan-e operation.
2056 * See also: vxge_hw_vpath_promisc_enable().
2058 enum vxge_hw_status
vxge_hw_vpath_promisc_disable(
2059 struct __vxge_hw_vpath_handle
*vp
)
2062 struct __vxge_hw_virtualpath
*vpath
;
2063 enum vxge_hw_status status
= VXGE_HW_OK
;
2065 if ((vp
== NULL
) || (vp
->vpath
->ringh
== NULL
)) {
2066 status
= VXGE_HW_ERR_INVALID_HANDLE
;
2072 val64
= readq(&vpath
->vp_reg
->rxmac_vcfg0
);
2074 if (val64
& VXGE_HW_RXMAC_VCFG0_UCAST_ALL_ADDR_EN
) {
2076 val64
&= ~(VXGE_HW_RXMAC_VCFG0_UCAST_ALL_ADDR_EN
|
2077 VXGE_HW_RXMAC_VCFG0_MCAST_ALL_ADDR_EN
|
2078 VXGE_HW_RXMAC_VCFG0_ALL_VID_EN
);
2080 writeq(val64
, &vpath
->vp_reg
->rxmac_vcfg0
);
2087 * vxge_hw_vpath_bcast_enable - Enable broadcast
2088 * @vp: Vpath handle.
2090 * Enable receiving broadcasts.
2092 enum vxge_hw_status
vxge_hw_vpath_bcast_enable(
2093 struct __vxge_hw_vpath_handle
*vp
)
2096 struct __vxge_hw_virtualpath
*vpath
;
2097 enum vxge_hw_status status
= VXGE_HW_OK
;
2099 if ((vp
== NULL
) || (vp
->vpath
->ringh
== NULL
)) {
2100 status
= VXGE_HW_ERR_INVALID_HANDLE
;
2106 val64
= readq(&vpath
->vp_reg
->rxmac_vcfg0
);
2108 if (!(val64
& VXGE_HW_RXMAC_VCFG0_BCAST_EN
)) {
2109 val64
|= VXGE_HW_RXMAC_VCFG0_BCAST_EN
;
2110 writeq(val64
, &vpath
->vp_reg
->rxmac_vcfg0
);
2117 * vxge_hw_vpath_mcast_enable - Enable multicast addresses.
2118 * @vp: Vpath handle.
2120 * Enable Titan-e multicast addresses.
2121 * Returns: VXGE_HW_OK on success.
2124 enum vxge_hw_status
vxge_hw_vpath_mcast_enable(
2125 struct __vxge_hw_vpath_handle
*vp
)
2128 struct __vxge_hw_virtualpath
*vpath
;
2129 enum vxge_hw_status status
= VXGE_HW_OK
;
2131 if ((vp
== NULL
) || (vp
->vpath
->ringh
== NULL
)) {
2132 status
= VXGE_HW_ERR_INVALID_HANDLE
;
2138 val64
= readq(&vpath
->vp_reg
->rxmac_vcfg0
);
2140 if (!(val64
& VXGE_HW_RXMAC_VCFG0_MCAST_ALL_ADDR_EN
)) {
2141 val64
|= VXGE_HW_RXMAC_VCFG0_MCAST_ALL_ADDR_EN
;
2142 writeq(val64
, &vpath
->vp_reg
->rxmac_vcfg0
);
2149 * vxge_hw_vpath_mcast_disable - Disable multicast addresses.
2150 * @vp: Vpath handle.
2152 * Disable Titan-e multicast addresses.
2153 * Returns: VXGE_HW_OK - success.
2154 * VXGE_HW_ERR_INVALID_HANDLE - Invalid handle
2158 vxge_hw_vpath_mcast_disable(struct __vxge_hw_vpath_handle
*vp
)
2161 struct __vxge_hw_virtualpath
*vpath
;
2162 enum vxge_hw_status status
= VXGE_HW_OK
;
2164 if ((vp
== NULL
) || (vp
->vpath
->ringh
== NULL
)) {
2165 status
= VXGE_HW_ERR_INVALID_HANDLE
;
2171 val64
= readq(&vpath
->vp_reg
->rxmac_vcfg0
);
2173 if (val64
& VXGE_HW_RXMAC_VCFG0_MCAST_ALL_ADDR_EN
) {
2174 val64
&= ~VXGE_HW_RXMAC_VCFG0_MCAST_ALL_ADDR_EN
;
2175 writeq(val64
, &vpath
->vp_reg
->rxmac_vcfg0
);
2182 * vxge_hw_vpath_alarm_process - Process Alarms.
2183 * @vpath: Virtual Path.
2184 * @skip_alarms: Do not clear the alarms
2186 * Process vpath alarms.
2189 enum vxge_hw_status
vxge_hw_vpath_alarm_process(
2190 struct __vxge_hw_vpath_handle
*vp
,
2193 enum vxge_hw_status status
= VXGE_HW_OK
;
2196 status
= VXGE_HW_ERR_INVALID_HANDLE
;
2200 status
= __vxge_hw_vpath_alarm_process(vp
->vpath
, skip_alarms
);
2206 * vxge_hw_vpath_msix_set - Associate MSIX vectors with TIM interrupts and
2208 * @vp: Virtual Path handle.
2209 * @tim_msix_id: MSIX vectors associated with VXGE_HW_MAX_INTR_PER_VP number of
2210 * interrupts(Can be repeated). If fifo or ring are not enabled
2211 * the MSIX vector for that should be set to 0
2212 * @alarm_msix_id: MSIX vector for alarm.
2214 * This API will associate a given MSIX vector numbers with the four TIM
2215 * interrupts and alarm interrupt.
2218 vxge_hw_vpath_msix_set(struct __vxge_hw_vpath_handle
*vp
, int *tim_msix_id
,
2222 struct __vxge_hw_virtualpath
*vpath
= vp
->vpath
;
2223 struct vxge_hw_vpath_reg __iomem
*vp_reg
= vpath
->vp_reg
;
2224 u32 vp_id
= vp
->vpath
->vp_id
;
2226 val64
= VXGE_HW_INTERRUPT_CFG0_GROUP0_MSIX_FOR_TXTI(
2227 (vp_id
* 4) + tim_msix_id
[0]) |
2228 VXGE_HW_INTERRUPT_CFG0_GROUP1_MSIX_FOR_TXTI(
2229 (vp_id
* 4) + tim_msix_id
[1]);
2231 writeq(val64
, &vp_reg
->interrupt_cfg0
);
2233 writeq(VXGE_HW_INTERRUPT_CFG2_ALARM_MAP_TO_MSG(
2234 (vpath
->hldev
->first_vp_id
* 4) + alarm_msix_id
),
2235 &vp_reg
->interrupt_cfg2
);
2237 if (vpath
->hldev
->config
.intr_mode
==
2238 VXGE_HW_INTR_MODE_MSIX_ONE_SHOT
) {
2239 __vxge_hw_pio_mem_write32_upper((u32
)vxge_bVALn(
2240 VXGE_HW_ONE_SHOT_VECT0_EN_ONE_SHOT_VECT0_EN
,
2241 0, 32), &vp_reg
->one_shot_vect0_en
);
2242 __vxge_hw_pio_mem_write32_upper((u32
)vxge_bVALn(
2243 VXGE_HW_ONE_SHOT_VECT1_EN_ONE_SHOT_VECT1_EN
,
2244 0, 32), &vp_reg
->one_shot_vect1_en
);
2245 __vxge_hw_pio_mem_write32_upper((u32
)vxge_bVALn(
2246 VXGE_HW_ONE_SHOT_VECT2_EN_ONE_SHOT_VECT2_EN
,
2247 0, 32), &vp_reg
->one_shot_vect2_en
);
2252 * vxge_hw_vpath_msix_mask - Mask MSIX Vector.
2253 * @vp: Virtual Path handle.
2256 * The function masks the msix interrupt for the given msix_id
2259 * Otherwise, VXGE_HW_ERR_WRONG_IRQ if the msix index is out of range
2264 vxge_hw_vpath_msix_mask(struct __vxge_hw_vpath_handle
*vp
, int msix_id
)
2266 struct __vxge_hw_device
*hldev
= vp
->vpath
->hldev
;
2267 __vxge_hw_pio_mem_write32_upper(
2268 (u32
) vxge_bVALn(vxge_mBIT(msix_id
>> 2), 0, 32),
2269 &hldev
->common_reg
->set_msix_mask_vect
[msix_id
% 4]);
2273 * vxge_hw_vpath_msix_clear - Clear MSIX Vector.
2274 * @vp: Virtual Path handle.
2277 * The function clears the msix interrupt for the given msix_id
2280 * Otherwise, VXGE_HW_ERR_WRONG_IRQ if the msix index is out of range
2284 void vxge_hw_vpath_msix_clear(struct __vxge_hw_vpath_handle
*vp
, int msix_id
)
2286 struct __vxge_hw_device
*hldev
= vp
->vpath
->hldev
;
2288 if ((hldev
->config
.intr_mode
== VXGE_HW_INTR_MODE_MSIX_ONE_SHOT
))
2289 __vxge_hw_pio_mem_write32_upper(
2290 (u32
) vxge_bVALn(vxge_mBIT((msix_id
>> 2)), 0, 32),
2291 &hldev
->common_reg
->clr_msix_one_shot_vec
[msix_id
% 4]);
2293 __vxge_hw_pio_mem_write32_upper(
2294 (u32
) vxge_bVALn(vxge_mBIT((msix_id
>> 2)), 0, 32),
2295 &hldev
->common_reg
->clear_msix_mask_vect
[msix_id
% 4]);
2299 * vxge_hw_vpath_msix_unmask - Unmask the MSIX Vector.
2300 * @vp: Virtual Path handle.
2303 * The function unmasks the msix interrupt for the given msix_id
2306 * Otherwise, VXGE_HW_ERR_WRONG_IRQ if the msix index is out of range
2311 vxge_hw_vpath_msix_unmask(struct __vxge_hw_vpath_handle
*vp
, int msix_id
)
2313 struct __vxge_hw_device
*hldev
= vp
->vpath
->hldev
;
2314 __vxge_hw_pio_mem_write32_upper(
2315 (u32
)vxge_bVALn(vxge_mBIT(msix_id
>> 2), 0, 32),
2316 &hldev
->common_reg
->clear_msix_mask_vect
[msix_id
%4]);
2320 * vxge_hw_vpath_inta_mask_tx_rx - Mask Tx and Rx interrupts.
2321 * @vp: Virtual Path handle.
2323 * Mask Tx and Rx vpath interrupts.
2325 * See also: vxge_hw_vpath_inta_mask_tx_rx()
2327 void vxge_hw_vpath_inta_mask_tx_rx(struct __vxge_hw_vpath_handle
*vp
)
2329 u64 tim_int_mask0
[4] = {[0 ...3] = 0};
2330 u32 tim_int_mask1
[4] = {[0 ...3] = 0};
2332 struct __vxge_hw_device
*hldev
= vp
->vpath
->hldev
;
2334 VXGE_HW_DEVICE_TIM_INT_MASK_SET(tim_int_mask0
,
2335 tim_int_mask1
, vp
->vpath
->vp_id
);
2337 val64
= readq(&hldev
->common_reg
->tim_int_mask0
);
2339 if ((tim_int_mask0
[VXGE_HW_VPATH_INTR_TX
] != 0) ||
2340 (tim_int_mask0
[VXGE_HW_VPATH_INTR_RX
] != 0)) {
2341 writeq((tim_int_mask0
[VXGE_HW_VPATH_INTR_TX
] |
2342 tim_int_mask0
[VXGE_HW_VPATH_INTR_RX
] | val64
),
2343 &hldev
->common_reg
->tim_int_mask0
);
2346 val64
= readl(&hldev
->common_reg
->tim_int_mask1
);
2348 if ((tim_int_mask1
[VXGE_HW_VPATH_INTR_TX
] != 0) ||
2349 (tim_int_mask1
[VXGE_HW_VPATH_INTR_RX
] != 0)) {
2350 __vxge_hw_pio_mem_write32_upper(
2351 (tim_int_mask1
[VXGE_HW_VPATH_INTR_TX
] |
2352 tim_int_mask1
[VXGE_HW_VPATH_INTR_RX
] | val64
),
2353 &hldev
->common_reg
->tim_int_mask1
);
2358 * vxge_hw_vpath_inta_unmask_tx_rx - Unmask Tx and Rx interrupts.
2359 * @vp: Virtual Path handle.
2361 * Unmask Tx and Rx vpath interrupts.
2363 * See also: vxge_hw_vpath_inta_mask_tx_rx()
2365 void vxge_hw_vpath_inta_unmask_tx_rx(struct __vxge_hw_vpath_handle
*vp
)
2367 u64 tim_int_mask0
[4] = {[0 ...3] = 0};
2368 u32 tim_int_mask1
[4] = {[0 ...3] = 0};
2370 struct __vxge_hw_device
*hldev
= vp
->vpath
->hldev
;
2372 VXGE_HW_DEVICE_TIM_INT_MASK_SET(tim_int_mask0
,
2373 tim_int_mask1
, vp
->vpath
->vp_id
);
2375 val64
= readq(&hldev
->common_reg
->tim_int_mask0
);
2377 if ((tim_int_mask0
[VXGE_HW_VPATH_INTR_TX
] != 0) ||
2378 (tim_int_mask0
[VXGE_HW_VPATH_INTR_RX
] != 0)) {
2379 writeq((~(tim_int_mask0
[VXGE_HW_VPATH_INTR_TX
] |
2380 tim_int_mask0
[VXGE_HW_VPATH_INTR_RX
])) & val64
,
2381 &hldev
->common_reg
->tim_int_mask0
);
2384 if ((tim_int_mask1
[VXGE_HW_VPATH_INTR_TX
] != 0) ||
2385 (tim_int_mask1
[VXGE_HW_VPATH_INTR_RX
] != 0)) {
2386 __vxge_hw_pio_mem_write32_upper(
2387 (~(tim_int_mask1
[VXGE_HW_VPATH_INTR_TX
] |
2388 tim_int_mask1
[VXGE_HW_VPATH_INTR_RX
])) & val64
,
2389 &hldev
->common_reg
->tim_int_mask1
);
2394 * vxge_hw_vpath_poll_rx - Poll Rx Virtual Path for completed
2395 * descriptors and process the same.
2396 * @ring: Handle to the ring object used for receive
2398 * The function polls the Rx for the completed descriptors and calls
2399 * the driver via supplied completion callback.
2401 * Returns: VXGE_HW_OK, if the polling is completed successful.
2402 * VXGE_HW_COMPLETIONS_REMAIN: There are still more completed
2403 * descriptors available which are yet to be processed.
2405 * See also: vxge_hw_vpath_poll_rx()
2407 enum vxge_hw_status
vxge_hw_vpath_poll_rx(struct __vxge_hw_ring
*ring
)
2410 enum vxge_hw_status status
= VXGE_HW_OK
;
2417 status
= vxge_hw_ring_rxd_next_completed(ring
, &first_rxdh
, &t_code
);
2418 if (status
== VXGE_HW_OK
)
2419 ring
->callback(ring
, first_rxdh
,
2420 t_code
, ring
->channel
.userdata
);
2422 if (ring
->cmpl_cnt
!= 0) {
2423 ring
->doorbell_cnt
+= ring
->cmpl_cnt
;
2424 if (ring
->doorbell_cnt
>= ring
->rxds_limit
) {
2426 * Each RxD is of 4 qwords, update the number of
2427 * qwords replenished
2429 new_count
= (ring
->doorbell_cnt
* 4);
2431 /* For each block add 4 more qwords */
2432 ring
->total_db_cnt
+= ring
->doorbell_cnt
;
2433 if (ring
->total_db_cnt
>= ring
->rxds_per_block
) {
2435 /* Reset total count */
2436 ring
->total_db_cnt
%= ring
->rxds_per_block
;
2438 writeq(VXGE_HW_PRC_RXD_DOORBELL_NEW_QW_CNT(new_count
),
2439 &ring
->vp_reg
->prc_rxd_doorbell
);
2441 readl(&ring
->common_reg
->titan_general_int_status
);
2442 ring
->doorbell_cnt
= 0;
2450 * vxge_hw_vpath_poll_tx - Poll Tx for completed descriptors and process
2452 * @fifo: Handle to the fifo object used for non offload send
2454 * The function polls the Tx for the completed descriptors and calls
2455 * the driver via supplied completion callback.
2457 * Returns: VXGE_HW_OK, if the polling is completed successful.
2458 * VXGE_HW_COMPLETIONS_REMAIN: There are still more completed
2459 * descriptors available which are yet to be processed.
2461 enum vxge_hw_status
vxge_hw_vpath_poll_tx(struct __vxge_hw_fifo
*fifo
,
2462 struct sk_buff
***skb_ptr
, int nr_skb
,
2465 enum vxge_hw_fifo_tcode t_code
;
2467 enum vxge_hw_status status
= VXGE_HW_OK
;
2468 struct __vxge_hw_channel
*channel
;
2470 channel
= &fifo
->channel
;
2472 status
= vxge_hw_fifo_txdl_next_completed(fifo
,
2473 &first_txdlh
, &t_code
);
2474 if (status
== VXGE_HW_OK
)
2475 if (fifo
->callback(fifo
, first_txdlh
, t_code
,
2476 channel
->userdata
, skb_ptr
, nr_skb
, more
) != VXGE_HW_OK
)
2477 status
= VXGE_HW_COMPLETIONS_REMAIN
;