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)
32 struct __vxge_hw_virtualpath *vpath;
33 struct vxge_hw_vpath_reg __iomem *vp_reg;
34 enum vxge_hw_status status = VXGE_HW_OK;
36 status = VXGE_HW_ERR_INVALID_HANDLE;
42 if (vpath->vp_open == VXGE_HW_VP_NOT_OPEN) {
43 status = VXGE_HW_ERR_VPATH_NOT_OPEN;
47 vp_reg = vpath->vp_reg;
49 writeq(VXGE_HW_INTR_MASK_ALL, &vp_reg->kdfcctl_errors_reg);
51 __vxge_hw_pio_mem_write32_upper((u32)VXGE_HW_INTR_MASK_ALL,
52 &vp_reg->general_errors_reg);
54 __vxge_hw_pio_mem_write32_upper((u32)VXGE_HW_INTR_MASK_ALL,
55 &vp_reg->pci_config_errors_reg);
57 __vxge_hw_pio_mem_write32_upper((u32)VXGE_HW_INTR_MASK_ALL,
58 &vp_reg->mrpcim_to_vpath_alarm_reg);
60 __vxge_hw_pio_mem_write32_upper((u32)VXGE_HW_INTR_MASK_ALL,
61 &vp_reg->srpcim_to_vpath_alarm_reg);
63 __vxge_hw_pio_mem_write32_upper((u32)VXGE_HW_INTR_MASK_ALL,
64 &vp_reg->vpath_ppif_int_status);
66 __vxge_hw_pio_mem_write32_upper((u32)VXGE_HW_INTR_MASK_ALL,
67 &vp_reg->srpcim_msg_to_vpath_reg);
69 __vxge_hw_pio_mem_write32_upper((u32)VXGE_HW_INTR_MASK_ALL,
70 &vp_reg->vpath_pcipif_int_status);
72 __vxge_hw_pio_mem_write32_upper((u32)VXGE_HW_INTR_MASK_ALL,
73 &vp_reg->prc_alarm_reg);
75 __vxge_hw_pio_mem_write32_upper((u32)VXGE_HW_INTR_MASK_ALL,
76 &vp_reg->wrdma_alarm_status);
78 __vxge_hw_pio_mem_write32_upper((u32)VXGE_HW_INTR_MASK_ALL,
79 &vp_reg->asic_ntwk_vp_err_reg);
81 __vxge_hw_pio_mem_write32_upper((u32)VXGE_HW_INTR_MASK_ALL,
82 &vp_reg->xgmac_vp_int_status);
84 readq(&vp_reg->vpath_general_int_status);
86 /* Mask unwanted interrupts */
88 __vxge_hw_pio_mem_write32_upper((u32)VXGE_HW_INTR_MASK_ALL,
89 &vp_reg->vpath_pcipif_int_mask);
91 __vxge_hw_pio_mem_write32_upper((u32)VXGE_HW_INTR_MASK_ALL,
92 &vp_reg->srpcim_msg_to_vpath_mask);
94 __vxge_hw_pio_mem_write32_upper((u32)VXGE_HW_INTR_MASK_ALL,
95 &vp_reg->srpcim_to_vpath_alarm_mask);
97 __vxge_hw_pio_mem_write32_upper((u32)VXGE_HW_INTR_MASK_ALL,
98 &vp_reg->mrpcim_to_vpath_alarm_mask);
100 __vxge_hw_pio_mem_write32_upper((u32)VXGE_HW_INTR_MASK_ALL,
101 &vp_reg->pci_config_errors_mask);
103 /* Unmask the individual interrupts */
105 writeq((u32)vxge_bVALn((VXGE_HW_GENERAL_ERRORS_REG_DBLGEN_FIFO1_OVRFLOW|
106 VXGE_HW_GENERAL_ERRORS_REG_DBLGEN_FIFO2_OVRFLOW|
107 VXGE_HW_GENERAL_ERRORS_REG_STATSB_DROP_TIMEOUT_REQ|
108 VXGE_HW_GENERAL_ERRORS_REG_STATSB_PIF_CHAIN_ERR), 0, 32),
109 &vp_reg->general_errors_mask);
111 __vxge_hw_pio_mem_write32_upper(
112 (u32)vxge_bVALn((VXGE_HW_KDFCCTL_ERRORS_REG_KDFCCTL_FIFO1_OVRWR|
113 VXGE_HW_KDFCCTL_ERRORS_REG_KDFCCTL_FIFO2_OVRWR|
114 VXGE_HW_KDFCCTL_ERRORS_REG_KDFCCTL_FIFO1_POISON|
115 VXGE_HW_KDFCCTL_ERRORS_REG_KDFCCTL_FIFO2_POISON|
116 VXGE_HW_KDFCCTL_ERRORS_REG_KDFCCTL_FIFO1_DMA_ERR|
117 VXGE_HW_KDFCCTL_ERRORS_REG_KDFCCTL_FIFO2_DMA_ERR), 0, 32),
118 &vp_reg->kdfcctl_errors_mask);
120 __vxge_hw_pio_mem_write32_upper(0, &vp_reg->vpath_ppif_int_mask);
122 __vxge_hw_pio_mem_write32_upper(
123 (u32)vxge_bVALn(VXGE_HW_PRC_ALARM_REG_PRC_RING_BUMP, 0, 32),
124 &vp_reg->prc_alarm_mask);
126 __vxge_hw_pio_mem_write32_upper(0, &vp_reg->wrdma_alarm_mask);
127 __vxge_hw_pio_mem_write32_upper(0, &vp_reg->xgmac_vp_int_mask);
129 if (vpath->hldev->first_vp_id != vpath->vp_id)
130 __vxge_hw_pio_mem_write32_upper((u32)VXGE_HW_INTR_MASK_ALL,
131 &vp_reg->asic_ntwk_vp_err_mask);
133 __vxge_hw_pio_mem_write32_upper((u32)vxge_bVALn((
134 VXGE_HW_ASIC_NTWK_VP_ERR_REG_XMACJ_NTWK_REAFFIRMED_FAULT |
135 VXGE_HW_ASIC_NTWK_VP_ERR_REG_XMACJ_NTWK_REAFFIRMED_OK), 0, 32),
136 &vp_reg->asic_ntwk_vp_err_mask);
138 __vxge_hw_pio_mem_write32_upper(0,
139 &vp_reg->vpath_general_int_mask);
146 * vxge_hw_vpath_intr_disable - Disable vpath interrupts.
147 * @vp: Virtual Path handle.
149 * Disable vpath interrupts. The function is to be executed the last in
150 * vpath initialization sequence.
152 * See also: vxge_hw_vpath_intr_enable()
154 enum vxge_hw_status vxge_hw_vpath_intr_disable(
155 struct __vxge_hw_vpath_handle *vp)
157 struct __vxge_hw_virtualpath *vpath;
158 enum vxge_hw_status status = VXGE_HW_OK;
159 struct vxge_hw_vpath_reg __iomem *vp_reg;
161 status = VXGE_HW_ERR_INVALID_HANDLE;
167 if (vpath->vp_open == VXGE_HW_VP_NOT_OPEN) {
168 status = VXGE_HW_ERR_VPATH_NOT_OPEN;
171 vp_reg = vpath->vp_reg;
173 __vxge_hw_pio_mem_write32_upper(
174 (u32)VXGE_HW_INTR_MASK_ALL,
175 &vp_reg->vpath_general_int_mask);
177 writeq(VXGE_HW_INTR_MASK_ALL, &vp_reg->kdfcctl_errors_mask);
179 __vxge_hw_pio_mem_write32_upper((u32)VXGE_HW_INTR_MASK_ALL,
180 &vp_reg->general_errors_mask);
182 __vxge_hw_pio_mem_write32_upper((u32)VXGE_HW_INTR_MASK_ALL,
183 &vp_reg->pci_config_errors_mask);
185 __vxge_hw_pio_mem_write32_upper((u32)VXGE_HW_INTR_MASK_ALL,
186 &vp_reg->mrpcim_to_vpath_alarm_mask);
188 __vxge_hw_pio_mem_write32_upper((u32)VXGE_HW_INTR_MASK_ALL,
189 &vp_reg->srpcim_to_vpath_alarm_mask);
191 __vxge_hw_pio_mem_write32_upper((u32)VXGE_HW_INTR_MASK_ALL,
192 &vp_reg->vpath_ppif_int_mask);
194 __vxge_hw_pio_mem_write32_upper((u32)VXGE_HW_INTR_MASK_ALL,
195 &vp_reg->srpcim_msg_to_vpath_mask);
197 __vxge_hw_pio_mem_write32_upper((u32)VXGE_HW_INTR_MASK_ALL,
198 &vp_reg->vpath_pcipif_int_mask);
200 __vxge_hw_pio_mem_write32_upper((u32)VXGE_HW_INTR_MASK_ALL,
201 &vp_reg->wrdma_alarm_mask);
203 __vxge_hw_pio_mem_write32_upper((u32)VXGE_HW_INTR_MASK_ALL,
204 &vp_reg->prc_alarm_mask);
206 __vxge_hw_pio_mem_write32_upper((u32)VXGE_HW_INTR_MASK_ALL,
207 &vp_reg->xgmac_vp_int_mask);
209 __vxge_hw_pio_mem_write32_upper((u32)VXGE_HW_INTR_MASK_ALL,
210 &vp_reg->asic_ntwk_vp_err_mask);
216 void vxge_hw_vpath_tti_ci_set(struct __vxge_hw_fifo *fifo)
218 struct vxge_hw_vpath_reg __iomem *vp_reg;
219 struct vxge_hw_vp_config *config;
222 if (fifo->config->enable != VXGE_HW_FIFO_ENABLE)
225 vp_reg = fifo->vp_reg;
226 config = container_of(fifo->config, struct vxge_hw_vp_config, fifo);
228 if (config->tti.timer_ci_en != VXGE_HW_TIM_TIMER_CI_ENABLE) {
229 config->tti.timer_ci_en = VXGE_HW_TIM_TIMER_CI_ENABLE;
230 val64 = readq(&vp_reg->tim_cfg1_int_num[VXGE_HW_VPATH_INTR_TX]);
231 val64 |= VXGE_HW_TIM_CFG1_INT_NUM_TIMER_CI;
232 fifo->tim_tti_cfg1_saved = val64;
233 writeq(val64, &vp_reg->tim_cfg1_int_num[VXGE_HW_VPATH_INTR_TX]);
237 void vxge_hw_vpath_dynamic_rti_ci_set(struct __vxge_hw_ring *ring)
239 u64 val64 = ring->tim_rti_cfg1_saved;
241 val64 |= VXGE_HW_TIM_CFG1_INT_NUM_TIMER_CI;
242 ring->tim_rti_cfg1_saved = val64;
243 writeq(val64, &ring->vp_reg->tim_cfg1_int_num[VXGE_HW_VPATH_INTR_RX]);
246 void vxge_hw_vpath_dynamic_tti_rtimer_set(struct __vxge_hw_fifo *fifo)
248 u64 val64 = fifo->tim_tti_cfg3_saved;
249 u64 timer = (fifo->rtimer * 1000) / 272;
251 val64 &= ~VXGE_HW_TIM_CFG3_INT_NUM_RTIMER_VAL(0x3ffffff);
253 val64 |= VXGE_HW_TIM_CFG3_INT_NUM_RTIMER_VAL(timer) |
254 VXGE_HW_TIM_CFG3_INT_NUM_RTIMER_EVENT_SF(5);
256 writeq(val64, &fifo->vp_reg->tim_cfg3_int_num[VXGE_HW_VPATH_INTR_TX]);
257 /* tti_cfg3_saved is not updated again because it is
258 * initialized at one place only - init time.
262 void vxge_hw_vpath_dynamic_rti_rtimer_set(struct __vxge_hw_ring *ring)
264 u64 val64 = ring->tim_rti_cfg3_saved;
265 u64 timer = (ring->rtimer * 1000) / 272;
267 val64 &= ~VXGE_HW_TIM_CFG3_INT_NUM_RTIMER_VAL(0x3ffffff);
269 val64 |= VXGE_HW_TIM_CFG3_INT_NUM_RTIMER_VAL(timer) |
270 VXGE_HW_TIM_CFG3_INT_NUM_RTIMER_EVENT_SF(4);
272 writeq(val64, &ring->vp_reg->tim_cfg3_int_num[VXGE_HW_VPATH_INTR_RX]);
273 /* rti_cfg3_saved is not updated again because it is
274 * initialized at one place only - init time.
279 * vxge_hw_channel_msix_mask - Mask MSIX Vector.
280 * @channeh: Channel for rx or tx handle
283 * The function masks the msix interrupt for the given msix_id
287 void vxge_hw_channel_msix_mask(struct __vxge_hw_channel *channel, int msix_id)
290 __vxge_hw_pio_mem_write32_upper(
291 (u32)vxge_bVALn(vxge_mBIT(msix_id >> 2), 0, 32),
292 &channel->common_reg->set_msix_mask_vect[msix_id%4]);
296 * vxge_hw_channel_msix_unmask - Unmask the MSIX Vector.
297 * @channeh: Channel for rx or tx handle
300 * The function unmasks the msix interrupt for the given msix_id
305 vxge_hw_channel_msix_unmask(struct __vxge_hw_channel *channel, int msix_id)
308 __vxge_hw_pio_mem_write32_upper(
309 (u32)vxge_bVALn(vxge_mBIT(msix_id >> 2), 0, 32),
310 &channel->common_reg->clear_msix_mask_vect[msix_id%4]);
314 * vxge_hw_channel_msix_clear - Unmask the MSIX Vector.
315 * @channel: Channel for rx or tx handle
318 * The function unmasks the msix interrupt for the given msix_id
319 * if configured in MSIX oneshot mode
323 void vxge_hw_channel_msix_clear(struct __vxge_hw_channel *channel, int msix_id)
325 __vxge_hw_pio_mem_write32_upper(
326 (u32) vxge_bVALn(vxge_mBIT(msix_id >> 2), 0, 32),
327 &channel->common_reg->clr_msix_one_shot_vec[msix_id % 4]);
331 * vxge_hw_device_set_intr_type - Updates the configuration
332 * with new interrupt type.
333 * @hldev: HW device handle.
334 * @intr_mode: New interrupt type
336 u32 vxge_hw_device_set_intr_type(struct __vxge_hw_device *hldev, u32 intr_mode)
339 if ((intr_mode != VXGE_HW_INTR_MODE_IRQLINE) &&
340 (intr_mode != VXGE_HW_INTR_MODE_MSIX) &&
341 (intr_mode != VXGE_HW_INTR_MODE_MSIX_ONE_SHOT) &&
342 (intr_mode != VXGE_HW_INTR_MODE_DEF))
343 intr_mode = VXGE_HW_INTR_MODE_IRQLINE;
345 hldev->config.intr_mode = intr_mode;
350 * vxge_hw_device_intr_enable - Enable interrupts.
351 * @hldev: HW device handle.
352 * @op: One of the enum vxge_hw_device_intr enumerated values specifying
353 * the type(s) of interrupts to enable.
355 * Enable Titan interrupts. The function is to be executed the last in
356 * Titan initialization sequence.
358 * See also: vxge_hw_device_intr_disable()
360 void vxge_hw_device_intr_enable(struct __vxge_hw_device *hldev)
366 vxge_hw_device_mask_all(hldev);
368 for (i = 0; i < VXGE_HW_MAX_VIRTUAL_PATHS; i++) {
370 if (!(hldev->vpaths_deployed & vxge_mBIT(i)))
373 vxge_hw_vpath_intr_enable(
374 VXGE_HW_VIRTUAL_PATH_HANDLE(&hldev->virtual_paths[i]));
377 if (hldev->config.intr_mode == VXGE_HW_INTR_MODE_IRQLINE) {
378 val64 = hldev->tim_int_mask0[VXGE_HW_VPATH_INTR_TX] |
379 hldev->tim_int_mask0[VXGE_HW_VPATH_INTR_RX];
382 writeq(val64, &hldev->common_reg->tim_int_status0);
384 writeq(~val64, &hldev->common_reg->tim_int_mask0);
387 val32 = hldev->tim_int_mask1[VXGE_HW_VPATH_INTR_TX] |
388 hldev->tim_int_mask1[VXGE_HW_VPATH_INTR_RX];
391 __vxge_hw_pio_mem_write32_upper(val32,
392 &hldev->common_reg->tim_int_status1);
394 __vxge_hw_pio_mem_write32_upper(~val32,
395 &hldev->common_reg->tim_int_mask1);
399 val64 = readq(&hldev->common_reg->titan_general_int_status);
401 vxge_hw_device_unmask_all(hldev);
405 * vxge_hw_device_intr_disable - Disable Titan interrupts.
406 * @hldev: HW device handle.
407 * @op: One of the enum vxge_hw_device_intr enumerated values specifying
408 * the type(s) of interrupts to disable.
410 * Disable Titan interrupts.
412 * See also: vxge_hw_device_intr_enable()
414 void vxge_hw_device_intr_disable(struct __vxge_hw_device *hldev)
418 vxge_hw_device_mask_all(hldev);
420 /* mask all the tim interrupts */
421 writeq(VXGE_HW_INTR_MASK_ALL, &hldev->common_reg->tim_int_mask0);
422 __vxge_hw_pio_mem_write32_upper(VXGE_HW_DEFAULT_32,
423 &hldev->common_reg->tim_int_mask1);
425 for (i = 0; i < VXGE_HW_MAX_VIRTUAL_PATHS; i++) {
427 if (!(hldev->vpaths_deployed & vxge_mBIT(i)))
430 vxge_hw_vpath_intr_disable(
431 VXGE_HW_VIRTUAL_PATH_HANDLE(&hldev->virtual_paths[i]));
436 * vxge_hw_device_mask_all - Mask all device interrupts.
437 * @hldev: HW device handle.
439 * Mask all device interrupts.
441 * See also: vxge_hw_device_unmask_all()
443 void vxge_hw_device_mask_all(struct __vxge_hw_device *hldev)
447 val64 = VXGE_HW_TITAN_MASK_ALL_INT_ALARM |
448 VXGE_HW_TITAN_MASK_ALL_INT_TRAFFIC;
450 __vxge_hw_pio_mem_write32_upper((u32)vxge_bVALn(val64, 0, 32),
451 &hldev->common_reg->titan_mask_all_int);
455 * vxge_hw_device_unmask_all - Unmask all device interrupts.
456 * @hldev: HW device handle.
458 * Unmask all device interrupts.
460 * See also: vxge_hw_device_mask_all()
462 void vxge_hw_device_unmask_all(struct __vxge_hw_device *hldev)
466 if (hldev->config.intr_mode == VXGE_HW_INTR_MODE_IRQLINE)
467 val64 = VXGE_HW_TITAN_MASK_ALL_INT_TRAFFIC;
469 __vxge_hw_pio_mem_write32_upper((u32)vxge_bVALn(val64, 0, 32),
470 &hldev->common_reg->titan_mask_all_int);
474 * vxge_hw_device_flush_io - Flush io writes.
475 * @hldev: HW device handle.
477 * The function performs a read operation to flush io writes.
481 void vxge_hw_device_flush_io(struct __vxge_hw_device *hldev)
483 readl(&hldev->common_reg->titan_general_int_status);
487 * __vxge_hw_device_handle_error - Handle error
490 * @type: Error type. Please see enum vxge_hw_event{}
494 static enum vxge_hw_status
495 __vxge_hw_device_handle_error(struct __vxge_hw_device *hldev, u32 vp_id,
496 enum vxge_hw_event type)
499 case VXGE_HW_EVENT_UNKNOWN:
501 case VXGE_HW_EVENT_RESET_START:
502 case VXGE_HW_EVENT_RESET_COMPLETE:
503 case VXGE_HW_EVENT_LINK_DOWN:
504 case VXGE_HW_EVENT_LINK_UP:
506 case VXGE_HW_EVENT_ALARM_CLEARED:
508 case VXGE_HW_EVENT_ECCERR:
509 case VXGE_HW_EVENT_MRPCIM_ECCERR:
511 case VXGE_HW_EVENT_FIFO_ERR:
512 case VXGE_HW_EVENT_VPATH_ERR:
513 case VXGE_HW_EVENT_CRITICAL_ERR:
514 case VXGE_HW_EVENT_SERR:
516 case VXGE_HW_EVENT_SRPCIM_SERR:
517 case VXGE_HW_EVENT_MRPCIM_SERR:
519 case VXGE_HW_EVENT_SLOT_FREEZE:
527 if (hldev->uld_callbacks->crit_err)
528 hldev->uld_callbacks->crit_err(hldev,
536 * __vxge_hw_device_handle_link_down_ind
537 * @hldev: HW device handle.
539 * Link down indication handler. The function is invoked by HW when
540 * Titan indicates that the link is down.
542 static enum vxge_hw_status
543 __vxge_hw_device_handle_link_down_ind(struct __vxge_hw_device *hldev)
546 * If the previous link state is not down, return.
548 if (hldev->link_state == VXGE_HW_LINK_DOWN)
551 hldev->link_state = VXGE_HW_LINK_DOWN;
554 if (hldev->uld_callbacks->link_down)
555 hldev->uld_callbacks->link_down(hldev);
561 * __vxge_hw_device_handle_link_up_ind
562 * @hldev: HW device handle.
564 * Link up indication handler. The function is invoked by HW when
565 * Titan indicates that the link is up for programmable amount of time.
567 static enum vxge_hw_status
568 __vxge_hw_device_handle_link_up_ind(struct __vxge_hw_device *hldev)
571 * If the previous link state is not down, return.
573 if (hldev->link_state == VXGE_HW_LINK_UP)
576 hldev->link_state = VXGE_HW_LINK_UP;
579 if (hldev->uld_callbacks->link_up)
580 hldev->uld_callbacks->link_up(hldev);
586 * __vxge_hw_vpath_alarm_process - Process Alarms.
587 * @vpath: Virtual Path.
588 * @skip_alarms: Do not clear the alarms
590 * Process vpath alarms.
593 static enum vxge_hw_status
594 __vxge_hw_vpath_alarm_process(struct __vxge_hw_virtualpath *vpath,
600 struct __vxge_hw_device *hldev = NULL;
601 enum vxge_hw_event alarm_event = VXGE_HW_EVENT_UNKNOWN;
603 struct vxge_hw_vpath_stats_sw_info *sw_stats;
604 struct vxge_hw_vpath_reg __iomem *vp_reg;
607 alarm_event = VXGE_HW_SET_LEVEL(VXGE_HW_EVENT_UNKNOWN,
612 hldev = vpath->hldev;
613 vp_reg = vpath->vp_reg;
614 alarm_status = readq(&vp_reg->vpath_general_int_status);
616 if (alarm_status == VXGE_HW_ALL_FOXES) {
617 alarm_event = VXGE_HW_SET_LEVEL(VXGE_HW_EVENT_SLOT_FREEZE,
622 sw_stats = vpath->sw_stats;
624 if (alarm_status & ~(
625 VXGE_HW_VPATH_GENERAL_INT_STATUS_PIC_INT |
626 VXGE_HW_VPATH_GENERAL_INT_STATUS_PCI_INT |
627 VXGE_HW_VPATH_GENERAL_INT_STATUS_WRDMA_INT |
628 VXGE_HW_VPATH_GENERAL_INT_STATUS_XMAC_INT)) {
629 sw_stats->error_stats.unknown_alarms++;
631 alarm_event = VXGE_HW_SET_LEVEL(VXGE_HW_EVENT_UNKNOWN,
636 if (alarm_status & VXGE_HW_VPATH_GENERAL_INT_STATUS_XMAC_INT) {
638 val64 = readq(&vp_reg->xgmac_vp_int_status);
641 VXGE_HW_XGMAC_VP_INT_STATUS_ASIC_NTWK_VP_ERR_ASIC_NTWK_VP_INT) {
643 val64 = readq(&vp_reg->asic_ntwk_vp_err_reg);
646 VXGE_HW_ASIC_NW_VP_ERR_REG_XMACJ_STN_FLT) &&
648 VXGE_HW_ASIC_NW_VP_ERR_REG_XMACJ_STN_OK))) ||
650 VXGE_HW_ASIC_NW_VP_ERR_REG_XMACJ_STN_FLT_OCCURR) &&
652 VXGE_HW_ASIC_NW_VP_ERR_REG_XMACJ_STN_OK_OCCURR)
654 sw_stats->error_stats.network_sustained_fault++;
657 VXGE_HW_ASIC_NW_VP_ERR_REG_XMACJ_STN_FLT,
658 &vp_reg->asic_ntwk_vp_err_mask);
660 __vxge_hw_device_handle_link_down_ind(hldev);
661 alarm_event = VXGE_HW_SET_LEVEL(
662 VXGE_HW_EVENT_LINK_DOWN, alarm_event);
666 VXGE_HW_ASIC_NW_VP_ERR_REG_XMACJ_STN_OK) &&
668 VXGE_HW_ASIC_NW_VP_ERR_REG_XMACJ_STN_FLT))) ||
670 VXGE_HW_ASIC_NW_VP_ERR_REG_XMACJ_STN_OK_OCCURR) &&
672 VXGE_HW_ASIC_NW_VP_ERR_REG_XMACJ_STN_FLT_OCCURR)
675 sw_stats->error_stats.network_sustained_ok++;
678 VXGE_HW_ASIC_NW_VP_ERR_REG_XMACJ_STN_OK,
679 &vp_reg->asic_ntwk_vp_err_mask);
681 __vxge_hw_device_handle_link_up_ind(hldev);
682 alarm_event = VXGE_HW_SET_LEVEL(
683 VXGE_HW_EVENT_LINK_UP, alarm_event);
686 writeq(VXGE_HW_INTR_MASK_ALL,
687 &vp_reg->asic_ntwk_vp_err_reg);
689 alarm_event = VXGE_HW_SET_LEVEL(
690 VXGE_HW_EVENT_ALARM_CLEARED, alarm_event);
697 if (alarm_status & VXGE_HW_VPATH_GENERAL_INT_STATUS_PIC_INT) {
699 pic_status = readq(&vp_reg->vpath_ppif_int_status);
702 VXGE_HW_VPATH_PPIF_INT_STATUS_GENERAL_ERRORS_GENERAL_INT) {
704 val64 = readq(&vp_reg->general_errors_reg);
705 mask64 = readq(&vp_reg->general_errors_mask);
708 VXGE_HW_GENERAL_ERRORS_REG_INI_SERR_DET) &
710 sw_stats->error_stats.ini_serr_det++;
712 alarm_event = VXGE_HW_SET_LEVEL(
713 VXGE_HW_EVENT_SERR, alarm_event);
717 VXGE_HW_GENERAL_ERRORS_REG_DBLGEN_FIFO0_OVRFLOW) &
719 sw_stats->error_stats.dblgen_fifo0_overflow++;
721 alarm_event = VXGE_HW_SET_LEVEL(
722 VXGE_HW_EVENT_FIFO_ERR, alarm_event);
726 VXGE_HW_GENERAL_ERRORS_REG_STATSB_PIF_CHAIN_ERR) &
728 sw_stats->error_stats.statsb_pif_chain_error++;
731 VXGE_HW_GENERAL_ERRORS_REG_STATSB_DROP_TIMEOUT_REQ) &
733 sw_stats->error_stats.statsb_drop_timeout++;
736 VXGE_HW_GENERAL_ERRORS_REG_TGT_ILLEGAL_ACCESS) &
738 sw_stats->error_stats.target_illegal_access++;
741 writeq(VXGE_HW_INTR_MASK_ALL,
742 &vp_reg->general_errors_reg);
743 alarm_event = VXGE_HW_SET_LEVEL(
744 VXGE_HW_EVENT_ALARM_CLEARED,
750 VXGE_HW_VPATH_PPIF_INT_STATUS_KDFCCTL_ERRORS_KDFCCTL_INT) {
752 val64 = readq(&vp_reg->kdfcctl_errors_reg);
753 mask64 = readq(&vp_reg->kdfcctl_errors_mask);
756 VXGE_HW_KDFCCTL_ERRORS_REG_KDFCCTL_FIFO0_OVRWR) &
758 sw_stats->error_stats.kdfcctl_fifo0_overwrite++;
760 alarm_event = VXGE_HW_SET_LEVEL(
761 VXGE_HW_EVENT_FIFO_ERR,
766 VXGE_HW_KDFCCTL_ERRORS_REG_KDFCCTL_FIFO0_POISON) &
768 sw_stats->error_stats.kdfcctl_fifo0_poison++;
770 alarm_event = VXGE_HW_SET_LEVEL(
771 VXGE_HW_EVENT_FIFO_ERR,
776 VXGE_HW_KDFCCTL_ERRORS_REG_KDFCCTL_FIFO0_DMA_ERR) &
778 sw_stats->error_stats.kdfcctl_fifo0_dma_error++;
780 alarm_event = VXGE_HW_SET_LEVEL(
781 VXGE_HW_EVENT_FIFO_ERR,
786 writeq(VXGE_HW_INTR_MASK_ALL,
787 &vp_reg->kdfcctl_errors_reg);
788 alarm_event = VXGE_HW_SET_LEVEL(
789 VXGE_HW_EVENT_ALARM_CLEARED,
796 if (alarm_status & VXGE_HW_VPATH_GENERAL_INT_STATUS_WRDMA_INT) {
798 val64 = readq(&vp_reg->wrdma_alarm_status);
800 if (val64 & VXGE_HW_WRDMA_ALARM_STATUS_PRC_ALARM_PRC_INT) {
802 val64 = readq(&vp_reg->prc_alarm_reg);
803 mask64 = readq(&vp_reg->prc_alarm_mask);
805 if ((val64 & VXGE_HW_PRC_ALARM_REG_PRC_RING_BUMP)&
807 sw_stats->error_stats.prc_ring_bumps++;
809 if ((val64 & VXGE_HW_PRC_ALARM_REG_PRC_RXDCM_SC_ERR) &
811 sw_stats->error_stats.prc_rxdcm_sc_err++;
813 alarm_event = VXGE_HW_SET_LEVEL(
814 VXGE_HW_EVENT_VPATH_ERR,
818 if ((val64 & VXGE_HW_PRC_ALARM_REG_PRC_RXDCM_SC_ABORT)
820 sw_stats->error_stats.prc_rxdcm_sc_abort++;
822 alarm_event = VXGE_HW_SET_LEVEL(
823 VXGE_HW_EVENT_VPATH_ERR,
827 if ((val64 & VXGE_HW_PRC_ALARM_REG_PRC_QUANTA_SIZE_ERR)
829 sw_stats->error_stats.prc_quanta_size_err++;
831 alarm_event = VXGE_HW_SET_LEVEL(
832 VXGE_HW_EVENT_VPATH_ERR,
837 writeq(VXGE_HW_INTR_MASK_ALL,
838 &vp_reg->prc_alarm_reg);
839 alarm_event = VXGE_HW_SET_LEVEL(
840 VXGE_HW_EVENT_ALARM_CLEARED,
846 hldev->stats.sw_dev_err_stats.vpath_alarms++;
848 if ((alarm_event == VXGE_HW_EVENT_ALARM_CLEARED) ||
849 (alarm_event == VXGE_HW_EVENT_UNKNOWN))
852 __vxge_hw_device_handle_error(hldev, vpath->vp_id, alarm_event);
854 if (alarm_event == VXGE_HW_EVENT_SERR)
855 return VXGE_HW_ERR_CRITICAL;
857 return (alarm_event == VXGE_HW_EVENT_SLOT_FREEZE) ?
858 VXGE_HW_ERR_SLOT_FREEZE :
859 (alarm_event == VXGE_HW_EVENT_FIFO_ERR) ? VXGE_HW_ERR_FIFO :
864 * vxge_hw_device_begin_irq - Begin IRQ processing.
865 * @hldev: HW device handle.
866 * @skip_alarms: Do not clear the alarms
867 * @reason: "Reason" for the interrupt, the value of Titan's
868 * general_int_status register.
870 * The function performs two actions, It first checks whether (shared IRQ) the
871 * interrupt was raised by the device. Next, it masks the device interrupts.
874 * vxge_hw_device_begin_irq() does not flush MMIO writes through the
875 * bridge. Therefore, two back-to-back interrupts are potentially possible.
877 * Returns: 0, if the interrupt is not "ours" (note that in this case the
878 * device remain enabled).
879 * Otherwise, vxge_hw_device_begin_irq() returns 64bit general adapter
882 enum vxge_hw_status vxge_hw_device_begin_irq(struct __vxge_hw_device *hldev,
883 u32 skip_alarms, u64 *reason)
889 enum vxge_hw_status ret = VXGE_HW_OK;
891 val64 = readq(&hldev->common_reg->titan_general_int_status);
893 if (unlikely(!val64)) {
894 /* not Titan interrupt */
896 ret = VXGE_HW_ERR_WRONG_IRQ;
900 if (unlikely(val64 == VXGE_HW_ALL_FOXES)) {
902 adapter_status = readq(&hldev->common_reg->adapter_status);
904 if (adapter_status == VXGE_HW_ALL_FOXES) {
906 __vxge_hw_device_handle_error(hldev,
907 NULL_VPID, VXGE_HW_EVENT_SLOT_FREEZE);
909 ret = VXGE_HW_ERR_SLOT_FREEZE;
914 hldev->stats.sw_dev_info_stats.total_intr_cnt++;
918 vpath_mask = hldev->vpaths_deployed >>
919 (64 - VXGE_HW_MAX_VIRTUAL_PATHS);
922 VXGE_HW_TITAN_GENERAL_INT_STATUS_VPATH_TRAFFIC_INT(vpath_mask)) {
923 hldev->stats.sw_dev_info_stats.traffic_intr_cnt++;
928 hldev->stats.sw_dev_info_stats.not_traffic_intr_cnt++;
931 VXGE_HW_TITAN_GENERAL_INT_STATUS_VPATH_ALARM_INT)) {
933 enum vxge_hw_status error_level = VXGE_HW_OK;
935 hldev->stats.sw_dev_err_stats.vpath_alarms++;
937 for (i = 0; i < VXGE_HW_MAX_VIRTUAL_PATHS; i++) {
939 if (!(hldev->vpaths_deployed & vxge_mBIT(i)))
942 ret = __vxge_hw_vpath_alarm_process(
943 &hldev->virtual_paths[i], skip_alarms);
945 error_level = VXGE_HW_SET_LEVEL(ret, error_level);
947 if (unlikely((ret == VXGE_HW_ERR_CRITICAL) ||
948 (ret == VXGE_HW_ERR_SLOT_FREEZE)))
959 * vxge_hw_device_clear_tx_rx - Acknowledge (that is, clear) the
960 * condition that has caused the Tx and RX interrupt.
963 * Acknowledge (that is, clear) the condition that has caused
964 * the Tx and Rx interrupt.
965 * See also: vxge_hw_device_begin_irq(),
966 * vxge_hw_device_mask_tx_rx(), vxge_hw_device_unmask_tx_rx().
968 void vxge_hw_device_clear_tx_rx(struct __vxge_hw_device *hldev)
971 if ((hldev->tim_int_mask0[VXGE_HW_VPATH_INTR_TX] != 0) ||
972 (hldev->tim_int_mask0[VXGE_HW_VPATH_INTR_RX] != 0)) {
973 writeq((hldev->tim_int_mask0[VXGE_HW_VPATH_INTR_TX] |
974 hldev->tim_int_mask0[VXGE_HW_VPATH_INTR_RX]),
975 &hldev->common_reg->tim_int_status0);
978 if ((hldev->tim_int_mask1[VXGE_HW_VPATH_INTR_TX] != 0) ||
979 (hldev->tim_int_mask1[VXGE_HW_VPATH_INTR_RX] != 0)) {
980 __vxge_hw_pio_mem_write32_upper(
981 (hldev->tim_int_mask1[VXGE_HW_VPATH_INTR_TX] |
982 hldev->tim_int_mask1[VXGE_HW_VPATH_INTR_RX]),
983 &hldev->common_reg->tim_int_status1);
988 * vxge_hw_channel_dtr_alloc - Allocate a dtr from the channel
990 * @dtrh: Buffer to return the DTR pointer
992 * Allocates a dtr from the reserve array. If the reserve array is empty,
993 * it swaps the reserve and free arrays.
996 static enum vxge_hw_status
997 vxge_hw_channel_dtr_alloc(struct __vxge_hw_channel *channel, void **dtrh)
999 if (channel->reserve_ptr - channel->reserve_top > 0) {
1001 *dtrh = channel->reserve_arr[--channel->reserve_ptr];
1006 /* switch between empty and full arrays */
1008 /* the idea behind such a design is that by having free and reserved
1009 * arrays separated we basically separated irq and non-irq parts.
1010 * i.e. no additional lock need to be done when we free a resource */
1012 if (channel->length - channel->free_ptr > 0) {
1013 swap(channel->reserve_arr, channel->free_arr);
1014 channel->reserve_ptr = channel->length;
1015 channel->reserve_top = channel->free_ptr;
1016 channel->free_ptr = channel->length;
1018 channel->stats->reserve_free_swaps_cnt++;
1020 goto _alloc_after_swap;
1023 channel->stats->full_cnt++;
1026 return VXGE_HW_INF_OUT_OF_DESCRIPTORS;
1030 * vxge_hw_channel_dtr_post - Post a dtr to the channel
1031 * @channelh: Channel
1032 * @dtrh: DTR pointer
1034 * Posts a dtr to work array.
1038 vxge_hw_channel_dtr_post(struct __vxge_hw_channel *channel, void *dtrh)
1040 vxge_assert(channel->work_arr[channel->post_index] == NULL);
1042 channel->work_arr[channel->post_index++] = dtrh;
1045 if (channel->post_index == channel->length)
1046 channel->post_index = 0;
1050 * vxge_hw_channel_dtr_try_complete - Returns next completed dtr
1052 * @dtr: Buffer to return the next completed DTR pointer
1054 * Returns the next completed dtr with out removing it from work array
1058 vxge_hw_channel_dtr_try_complete(struct __vxge_hw_channel *channel, void **dtrh)
1060 vxge_assert(channel->compl_index < channel->length);
1062 *dtrh = channel->work_arr[channel->compl_index];
1067 * vxge_hw_channel_dtr_complete - Removes next completed dtr from the work array
1068 * @channel: Channel handle
1070 * Removes the next completed dtr from work array
1073 void vxge_hw_channel_dtr_complete(struct __vxge_hw_channel *channel)
1075 channel->work_arr[channel->compl_index] = NULL;
1078 if (++channel->compl_index == channel->length)
1079 channel->compl_index = 0;
1081 channel->stats->total_compl_cnt++;
1085 * vxge_hw_channel_dtr_free - Frees a dtr
1086 * @channel: Channel handle
1089 * Returns the dtr to free array
1092 void vxge_hw_channel_dtr_free(struct __vxge_hw_channel *channel, void *dtrh)
1094 channel->free_arr[--channel->free_ptr] = dtrh;
1098 * vxge_hw_channel_dtr_count
1099 * @channel: Channel handle. Obtained via vxge_hw_channel_open().
1101 * Retrieve number of DTRs available. This function can not be called
1102 * from data path. ring_initial_replenishi() is the only user.
1104 int vxge_hw_channel_dtr_count(struct __vxge_hw_channel *channel)
1106 return (channel->reserve_ptr - channel->reserve_top) +
1107 (channel->length - channel->free_ptr);
1111 * vxge_hw_ring_rxd_reserve - Reserve ring descriptor.
1112 * @ring: Handle to the ring object used for receive
1113 * @rxdh: Reserved descriptor. On success HW fills this "out" parameter
1114 * with a valid handle.
1116 * Reserve Rx descriptor for the subsequent filling-in driver
1117 * and posting on the corresponding channel (@channelh)
1118 * via vxge_hw_ring_rxd_post().
1120 * Returns: VXGE_HW_OK - success.
1121 * VXGE_HW_INF_OUT_OF_DESCRIPTORS - Currently no descriptors available.
1124 enum vxge_hw_status vxge_hw_ring_rxd_reserve(struct __vxge_hw_ring *ring,
1127 enum vxge_hw_status status;
1128 struct __vxge_hw_channel *channel;
1130 channel = &ring->channel;
1132 status = vxge_hw_channel_dtr_alloc(channel, rxdh);
1134 if (status == VXGE_HW_OK) {
1135 struct vxge_hw_ring_rxd_1 *rxdp =
1136 (struct vxge_hw_ring_rxd_1 *)*rxdh;
1138 rxdp->control_0 = rxdp->control_1 = 0;
1145 * vxge_hw_ring_rxd_free - Free descriptor.
1146 * @ring: Handle to the ring object used for receive
1147 * @rxdh: Descriptor handle.
1149 * Free the reserved descriptor. This operation is "symmetrical" to
1150 * vxge_hw_ring_rxd_reserve. The "free-ing" completes the descriptor's
1153 * After free-ing (see vxge_hw_ring_rxd_free()) the descriptor again can
1156 * - reserved (vxge_hw_ring_rxd_reserve);
1158 * - posted (vxge_hw_ring_rxd_post);
1160 * - completed (vxge_hw_ring_rxd_next_completed);
1162 * - and recycled again (vxge_hw_ring_rxd_free).
1164 * For alternative state transitions and more details please refer to
1168 void vxge_hw_ring_rxd_free(struct __vxge_hw_ring *ring, void *rxdh)
1170 struct __vxge_hw_channel *channel;
1172 channel = &ring->channel;
1174 vxge_hw_channel_dtr_free(channel, rxdh);
1179 * vxge_hw_ring_rxd_pre_post - Prepare rxd and post
1180 * @ring: Handle to the ring object used for receive
1181 * @rxdh: Descriptor handle.
1183 * This routine prepares a rxd and posts
1185 void vxge_hw_ring_rxd_pre_post(struct __vxge_hw_ring *ring, void *rxdh)
1187 struct __vxge_hw_channel *channel;
1189 channel = &ring->channel;
1191 vxge_hw_channel_dtr_post(channel, rxdh);
1195 * vxge_hw_ring_rxd_post_post - Process rxd after post.
1196 * @ring: Handle to the ring object used for receive
1197 * @rxdh: Descriptor handle.
1199 * Processes rxd after post
1201 void vxge_hw_ring_rxd_post_post(struct __vxge_hw_ring *ring, void *rxdh)
1203 struct vxge_hw_ring_rxd_1 *rxdp = (struct vxge_hw_ring_rxd_1 *)rxdh;
1205 rxdp->control_0 = VXGE_HW_RING_RXD_LIST_OWN_ADAPTER;
1207 if (ring->stats->common_stats.usage_cnt > 0)
1208 ring->stats->common_stats.usage_cnt--;
1212 * vxge_hw_ring_rxd_post - Post descriptor on the ring.
1213 * @ring: Handle to the ring object used for receive
1214 * @rxdh: Descriptor obtained via vxge_hw_ring_rxd_reserve().
1216 * Post descriptor on the ring.
1217 * Prior to posting the descriptor should be filled in accordance with
1218 * Host/Titan interface specification for a given service (LL, etc.).
1221 void vxge_hw_ring_rxd_post(struct __vxge_hw_ring *ring, void *rxdh)
1223 struct vxge_hw_ring_rxd_1 *rxdp = (struct vxge_hw_ring_rxd_1 *)rxdh;
1224 struct __vxge_hw_channel *channel;
1226 channel = &ring->channel;
1229 rxdp->control_0 = VXGE_HW_RING_RXD_LIST_OWN_ADAPTER;
1231 vxge_hw_channel_dtr_post(channel, rxdh);
1233 if (ring->stats->common_stats.usage_cnt > 0)
1234 ring->stats->common_stats.usage_cnt--;
1238 * vxge_hw_ring_rxd_post_post_wmb - Process rxd after post with memory barrier.
1239 * @ring: Handle to the ring object used for receive
1240 * @rxdh: Descriptor handle.
1242 * Processes rxd after post with memory barrier.
1244 void vxge_hw_ring_rxd_post_post_wmb(struct __vxge_hw_ring *ring, void *rxdh)
1247 vxge_hw_ring_rxd_post_post(ring, rxdh);
1251 * vxge_hw_ring_rxd_next_completed - Get the _next_ completed descriptor.
1252 * @ring: Handle to the ring object used for receive
1253 * @rxdh: Descriptor handle. Returned by HW.
1254 * @t_code: Transfer code, as per Titan User Guide,
1255 * Receive Descriptor Format. Returned by HW.
1257 * Retrieve the _next_ completed descriptor.
1258 * HW uses ring callback (*vxge_hw_ring_callback_f) to notifiy
1259 * driver of new completed descriptors. After that
1260 * the driver can use vxge_hw_ring_rxd_next_completed to retrieve the rest
1261 * completions (the very first completion is passed by HW via
1262 * vxge_hw_ring_callback_f).
1264 * Implementation-wise, the driver is free to call
1265 * vxge_hw_ring_rxd_next_completed either immediately from inside the
1266 * ring callback, or in a deferred fashion and separate (from HW)
1269 * Non-zero @t_code means failure to fill-in receive buffer(s)
1270 * of the descriptor.
1271 * For instance, parity error detected during the data transfer.
1272 * In this case Titan will complete the descriptor and indicate
1273 * for the host that the received data is not to be used.
1274 * For details please refer to Titan User Guide.
1276 * Returns: VXGE_HW_OK - success.
1277 * VXGE_HW_INF_NO_MORE_COMPLETED_DESCRIPTORS - No completed descriptors
1278 * are currently available for processing.
1280 * See also: vxge_hw_ring_callback_f{},
1281 * vxge_hw_fifo_rxd_next_completed(), enum vxge_hw_status{}.
1283 enum vxge_hw_status vxge_hw_ring_rxd_next_completed(
1284 struct __vxge_hw_ring *ring, void **rxdh, u8 *t_code)
1286 struct __vxge_hw_channel *channel;
1287 struct vxge_hw_ring_rxd_1 *rxdp;
1288 enum vxge_hw_status status = VXGE_HW_OK;
1291 channel = &ring->channel;
1293 vxge_hw_channel_dtr_try_complete(channel, rxdh);
1297 status = VXGE_HW_INF_NO_MORE_COMPLETED_DESCRIPTORS;
1301 control_0 = rxdp->control_0;
1302 own = control_0 & VXGE_HW_RING_RXD_LIST_OWN_ADAPTER;
1303 *t_code = (u8)VXGE_HW_RING_RXD_T_CODE_GET(control_0);
1305 /* check whether it is not the end */
1306 if (!own || *t_code == VXGE_HW_RING_T_CODE_FRM_DROP) {
1308 vxge_assert((rxdp)->host_control !=
1312 vxge_hw_channel_dtr_complete(channel);
1314 vxge_assert(*t_code != VXGE_HW_RING_RXD_T_CODE_UNUSED);
1316 ring->stats->common_stats.usage_cnt++;
1317 if (ring->stats->common_stats.usage_max <
1318 ring->stats->common_stats.usage_cnt)
1319 ring->stats->common_stats.usage_max =
1320 ring->stats->common_stats.usage_cnt;
1322 status = VXGE_HW_OK;
1326 /* reset it. since we don't want to return
1327 * garbage to the driver */
1329 status = VXGE_HW_INF_NO_MORE_COMPLETED_DESCRIPTORS;
1335 * vxge_hw_ring_handle_tcode - Handle transfer code.
1336 * @ring: Handle to the ring object used for receive
1337 * @rxdh: Descriptor handle.
1338 * @t_code: One of the enumerated (and documented in the Titan user guide)
1341 * Handle descriptor's transfer code. The latter comes with each completed
1344 * Returns: one of the enum vxge_hw_status{} enumerated types.
1345 * VXGE_HW_OK - for success.
1346 * VXGE_HW_ERR_CRITICAL - when encounters critical error.
1348 enum vxge_hw_status vxge_hw_ring_handle_tcode(
1349 struct __vxge_hw_ring *ring, void *rxdh, u8 t_code)
1351 enum vxge_hw_status status = VXGE_HW_OK;
1353 /* If the t_code is not supported and if the
1354 * t_code is other than 0x5 (unparseable packet
1355 * such as unknown UPV6 header), Drop it !!!
1358 if (t_code == VXGE_HW_RING_T_CODE_OK ||
1359 t_code == VXGE_HW_RING_T_CODE_L3_PKT_ERR) {
1360 status = VXGE_HW_OK;
1364 if (t_code > VXGE_HW_RING_T_CODE_MULTI_ERR) {
1365 status = VXGE_HW_ERR_INVALID_TCODE;
1369 ring->stats->rxd_t_code_err_cnt[t_code]++;
1375 * __vxge_hw_non_offload_db_post - Post non offload doorbell
1378 * @txdl_ptr: The starting location of the TxDL in host memory
1379 * @num_txds: The highest TxD in this TxDL (0 to 255 means 1 to 256)
1380 * @no_snoop: No snoop flags
1382 * This function posts a non-offload doorbell to doorbell FIFO
1385 static void __vxge_hw_non_offload_db_post(struct __vxge_hw_fifo *fifo,
1386 u64 txdl_ptr, u32 num_txds, u32 no_snoop)
1388 writeq(VXGE_HW_NODBW_TYPE(VXGE_HW_NODBW_TYPE_NODBW) |
1389 VXGE_HW_NODBW_LAST_TXD_NUMBER(num_txds) |
1390 VXGE_HW_NODBW_GET_NO_SNOOP(no_snoop),
1391 &fifo->nofl_db->control_0);
1395 writeq(txdl_ptr, &fifo->nofl_db->txdl_ptr);
1401 * vxge_hw_fifo_free_txdl_count_get - returns the number of txdls available in
1403 * @fifoh: Handle to the fifo object used for non offload send
1405 u32 vxge_hw_fifo_free_txdl_count_get(struct __vxge_hw_fifo *fifoh)
1407 return vxge_hw_channel_dtr_count(&fifoh->channel);
1411 * vxge_hw_fifo_txdl_reserve - Reserve fifo descriptor.
1412 * @fifoh: Handle to the fifo object used for non offload send
1413 * @txdlh: Reserved descriptor. On success HW fills this "out" parameter
1414 * with a valid handle.
1415 * @txdl_priv: Buffer to return the pointer to per txdl space
1417 * Reserve a single TxDL (that is, fifo descriptor)
1418 * for the subsequent filling-in by driver)
1419 * and posting on the corresponding channel (@channelh)
1420 * via vxge_hw_fifo_txdl_post().
1422 * Note: it is the responsibility of driver to reserve multiple descriptors
1423 * for lengthy (e.g., LSO) transmit operation. A single fifo descriptor
1424 * carries up to configured number (fifo.max_frags) of contiguous buffers.
1426 * Returns: VXGE_HW_OK - success;
1427 * VXGE_HW_INF_OUT_OF_DESCRIPTORS - Currently no descriptors available
1430 enum vxge_hw_status vxge_hw_fifo_txdl_reserve(
1431 struct __vxge_hw_fifo *fifo,
1432 void **txdlh, void **txdl_priv)
1434 struct __vxge_hw_channel *channel;
1435 enum vxge_hw_status status;
1438 channel = &fifo->channel;
1440 status = vxge_hw_channel_dtr_alloc(channel, txdlh);
1442 if (status == VXGE_HW_OK) {
1443 struct vxge_hw_fifo_txd *txdp =
1444 (struct vxge_hw_fifo_txd *)*txdlh;
1445 struct __vxge_hw_fifo_txdl_priv *priv;
1447 priv = __vxge_hw_fifo_txdl_priv(fifo, txdp);
1449 /* reset the TxDL's private */
1450 priv->align_dma_offset = 0;
1451 priv->align_vaddr_start = priv->align_vaddr;
1452 priv->align_used_frags = 0;
1454 priv->alloc_frags = fifo->config->max_frags;
1455 priv->next_txdl_priv = NULL;
1457 *txdl_priv = (void *)(size_t)txdp->host_control;
1459 for (i = 0; i < fifo->config->max_frags; i++) {
1460 txdp = ((struct vxge_hw_fifo_txd *)*txdlh) + i;
1461 txdp->control_0 = txdp->control_1 = 0;
1469 * vxge_hw_fifo_txdl_buffer_set - Set transmit buffer pointer in the
1471 * @fifo: Handle to the fifo object used for non offload send
1472 * @txdlh: Descriptor handle.
1473 * @frag_idx: Index of the data buffer in the caller's scatter-gather list
1475 * @dma_pointer: DMA address of the data buffer referenced by @frag_idx.
1476 * @size: Size of the data buffer (in bytes).
1478 * This API is part of the preparation of the transmit descriptor for posting
1479 * (via vxge_hw_fifo_txdl_post()). The related "preparation" APIs include
1480 * vxge_hw_fifo_txdl_mss_set() and vxge_hw_fifo_txdl_cksum_set_bits().
1481 * All three APIs fill in the fields of the fifo descriptor,
1482 * in accordance with the Titan specification.
1485 void vxge_hw_fifo_txdl_buffer_set(struct __vxge_hw_fifo *fifo,
1486 void *txdlh, u32 frag_idx,
1487 dma_addr_t dma_pointer, u32 size)
1489 struct __vxge_hw_fifo_txdl_priv *txdl_priv;
1490 struct vxge_hw_fifo_txd *txdp, *txdp_last;
1492 txdl_priv = __vxge_hw_fifo_txdl_priv(fifo, txdlh);
1493 txdp = (struct vxge_hw_fifo_txd *)txdlh + txdl_priv->frags;
1496 txdp->control_0 = txdp->control_1 = 0;
1498 txdp->control_0 |= VXGE_HW_FIFO_TXD_GATHER_CODE(
1499 VXGE_HW_FIFO_TXD_GATHER_CODE_FIRST);
1500 txdp->control_1 |= fifo->interrupt_type;
1501 txdp->control_1 |= VXGE_HW_FIFO_TXD_INT_NUMBER(
1503 if (txdl_priv->frags) {
1504 txdp_last = (struct vxge_hw_fifo_txd *)txdlh +
1505 (txdl_priv->frags - 1);
1506 txdp_last->control_0 |= VXGE_HW_FIFO_TXD_GATHER_CODE(
1507 VXGE_HW_FIFO_TXD_GATHER_CODE_LAST);
1511 vxge_assert(frag_idx < txdl_priv->alloc_frags);
1513 txdp->buffer_pointer = (u64)dma_pointer;
1514 txdp->control_0 |= VXGE_HW_FIFO_TXD_BUFFER_SIZE(size);
1515 fifo->stats->total_buffers++;
1520 * vxge_hw_fifo_txdl_post - Post descriptor on the fifo channel.
1521 * @fifo: Handle to the fifo object used for non offload send
1522 * @txdlh: Descriptor obtained via vxge_hw_fifo_txdl_reserve()
1523 * @frags: Number of contiguous buffers that are part of a single
1524 * transmit operation.
1526 * Post descriptor on the 'fifo' type channel for transmission.
1527 * Prior to posting the descriptor should be filled in accordance with
1528 * Host/Titan interface specification for a given service (LL, etc.).
1531 void vxge_hw_fifo_txdl_post(struct __vxge_hw_fifo *fifo, void *txdlh)
1533 struct __vxge_hw_fifo_txdl_priv *txdl_priv;
1534 struct vxge_hw_fifo_txd *txdp_last;
1535 struct vxge_hw_fifo_txd *txdp_first;
1537 txdl_priv = __vxge_hw_fifo_txdl_priv(fifo, txdlh);
1540 txdp_last = (struct vxge_hw_fifo_txd *)txdlh + (txdl_priv->frags - 1);
1541 txdp_last->control_0 |=
1542 VXGE_HW_FIFO_TXD_GATHER_CODE(VXGE_HW_FIFO_TXD_GATHER_CODE_LAST);
1543 txdp_first->control_0 |= VXGE_HW_FIFO_TXD_LIST_OWN_ADAPTER;
1545 vxge_hw_channel_dtr_post(&fifo->channel, txdlh);
1547 __vxge_hw_non_offload_db_post(fifo,
1548 (u64)txdl_priv->dma_addr,
1549 txdl_priv->frags - 1,
1550 fifo->no_snoop_bits);
1552 fifo->stats->total_posts++;
1553 fifo->stats->common_stats.usage_cnt++;
1554 if (fifo->stats->common_stats.usage_max <
1555 fifo->stats->common_stats.usage_cnt)
1556 fifo->stats->common_stats.usage_max =
1557 fifo->stats->common_stats.usage_cnt;
1561 * vxge_hw_fifo_txdl_next_completed - Retrieve next completed descriptor.
1562 * @fifo: Handle to the fifo object used for non offload send
1563 * @txdlh: Descriptor handle. Returned by HW.
1564 * @t_code: Transfer code, as per Titan User Guide,
1565 * Transmit Descriptor Format.
1568 * Retrieve the _next_ completed descriptor.
1569 * HW uses channel callback (*vxge_hw_channel_callback_f) to notifiy
1570 * driver of new completed descriptors. After that
1571 * the driver can use vxge_hw_fifo_txdl_next_completed to retrieve the rest
1572 * completions (the very first completion is passed by HW via
1573 * vxge_hw_channel_callback_f).
1575 * Implementation-wise, the driver is free to call
1576 * vxge_hw_fifo_txdl_next_completed either immediately from inside the
1577 * channel callback, or in a deferred fashion and separate (from HW)
1580 * Non-zero @t_code means failure to process the descriptor.
1581 * The failure could happen, for instance, when the link is
1582 * down, in which case Titan completes the descriptor because it
1583 * is not able to send the data out.
1585 * For details please refer to Titan User Guide.
1587 * Returns: VXGE_HW_OK - success.
1588 * VXGE_HW_INF_NO_MORE_COMPLETED_DESCRIPTORS - No completed descriptors
1589 * are currently available for processing.
1592 enum vxge_hw_status vxge_hw_fifo_txdl_next_completed(
1593 struct __vxge_hw_fifo *fifo, void **txdlh,
1594 enum vxge_hw_fifo_tcode *t_code)
1596 struct __vxge_hw_channel *channel;
1597 struct vxge_hw_fifo_txd *txdp;
1598 enum vxge_hw_status status = VXGE_HW_OK;
1600 channel = &fifo->channel;
1602 vxge_hw_channel_dtr_try_complete(channel, txdlh);
1606 status = VXGE_HW_INF_NO_MORE_COMPLETED_DESCRIPTORS;
1610 /* check whether host owns it */
1611 if (!(txdp->control_0 & VXGE_HW_FIFO_TXD_LIST_OWN_ADAPTER)) {
1613 vxge_assert(txdp->host_control != 0);
1615 vxge_hw_channel_dtr_complete(channel);
1617 *t_code = (u8)VXGE_HW_FIFO_TXD_T_CODE_GET(txdp->control_0);
1619 if (fifo->stats->common_stats.usage_cnt > 0)
1620 fifo->stats->common_stats.usage_cnt--;
1622 status = VXGE_HW_OK;
1626 /* no more completions */
1628 status = VXGE_HW_INF_NO_MORE_COMPLETED_DESCRIPTORS;
1634 * vxge_hw_fifo_handle_tcode - Handle transfer code.
1635 * @fifo: Handle to the fifo object used for non offload send
1636 * @txdlh: Descriptor handle.
1637 * @t_code: One of the enumerated (and documented in the Titan user guide)
1640 * Handle descriptor's transfer code. The latter comes with each completed
1643 * Returns: one of the enum vxge_hw_status{} enumerated types.
1644 * VXGE_HW_OK - for success.
1645 * VXGE_HW_ERR_CRITICAL - when encounters critical error.
1647 enum vxge_hw_status vxge_hw_fifo_handle_tcode(struct __vxge_hw_fifo *fifo,
1649 enum vxge_hw_fifo_tcode t_code)
1651 enum vxge_hw_status status = VXGE_HW_OK;
1653 if (((t_code & 0x7) < 0) || ((t_code & 0x7) > 0x4)) {
1654 status = VXGE_HW_ERR_INVALID_TCODE;
1658 fifo->stats->txd_t_code_err_cnt[t_code]++;
1664 * vxge_hw_fifo_txdl_free - Free descriptor.
1665 * @fifo: Handle to the fifo object used for non offload send
1666 * @txdlh: Descriptor handle.
1668 * Free the reserved descriptor. This operation is "symmetrical" to
1669 * vxge_hw_fifo_txdl_reserve. The "free-ing" completes the descriptor's
1672 * After free-ing (see vxge_hw_fifo_txdl_free()) the descriptor again can
1675 * - reserved (vxge_hw_fifo_txdl_reserve);
1677 * - posted (vxge_hw_fifo_txdl_post);
1679 * - completed (vxge_hw_fifo_txdl_next_completed);
1681 * - and recycled again (vxge_hw_fifo_txdl_free).
1683 * For alternative state transitions and more details please refer to
1687 void vxge_hw_fifo_txdl_free(struct __vxge_hw_fifo *fifo, void *txdlh)
1689 struct __vxge_hw_fifo_txdl_priv *txdl_priv;
1691 struct __vxge_hw_channel *channel;
1693 channel = &fifo->channel;
1695 txdl_priv = __vxge_hw_fifo_txdl_priv(fifo,
1696 (struct vxge_hw_fifo_txd *)txdlh);
1698 max_frags = fifo->config->max_frags;
1700 vxge_hw_channel_dtr_free(channel, txdlh);
1704 * vxge_hw_vpath_mac_addr_add - Add the mac address entry for this vpath
1705 * to MAC address table.
1706 * @vp: Vpath handle.
1707 * @macaddr: MAC address to be added for this vpath into the list
1708 * @macaddr_mask: MAC address mask for macaddr
1709 * @duplicate_mode: Duplicate MAC address add mode. Please see
1710 * enum vxge_hw_vpath_mac_addr_add_mode{}
1712 * Adds the given mac address and mac address mask into the list for this
1714 * see also: vxge_hw_vpath_mac_addr_delete, vxge_hw_vpath_mac_addr_get and
1715 * vxge_hw_vpath_mac_addr_get_next
1719 vxge_hw_vpath_mac_addr_add(
1720 struct __vxge_hw_vpath_handle *vp,
1723 enum vxge_hw_vpath_mac_addr_add_mode duplicate_mode)
1728 enum vxge_hw_status status = VXGE_HW_OK;
1731 status = VXGE_HW_ERR_INVALID_HANDLE;
1735 for (i = 0; i < ETH_ALEN; i++) {
1737 data1 |= (u8)macaddr[i];
1740 data2 |= (u8)macaddr_mask[i];
1743 switch (duplicate_mode) {
1744 case VXGE_HW_VPATH_MAC_ADDR_ADD_DUPLICATE:
1747 case VXGE_HW_VPATH_MAC_ADDR_DISCARD_DUPLICATE:
1750 case VXGE_HW_VPATH_MAC_ADDR_REPLACE_DUPLICATE:
1758 status = __vxge_hw_vpath_rts_table_set(vp,
1759 VXGE_HW_RTS_ACCESS_STEER_CTRL_ACTION_ADD_ENTRY,
1760 VXGE_HW_RTS_ACCESS_STEER_CTRL_DATA_STRUCT_SEL_DA,
1762 VXGE_HW_RTS_ACCESS_STEER_DATA0_DA_MAC_ADDR(data1),
1763 VXGE_HW_RTS_ACCESS_STEER_DATA1_DA_MAC_ADDR_MASK(data2)|
1764 VXGE_HW_RTS_ACCESS_STEER_DATA1_DA_MAC_ADDR_MODE(i));
1770 * vxge_hw_vpath_mac_addr_get - Get the first mac address entry for this vpath
1771 * from MAC address table.
1772 * @vp: Vpath handle.
1773 * @macaddr: First MAC address entry for this vpath in the list
1774 * @macaddr_mask: MAC address mask for macaddr
1776 * Returns the first mac address and mac address mask in the list for this
1778 * see also: vxge_hw_vpath_mac_addr_get_next
1782 vxge_hw_vpath_mac_addr_get(
1783 struct __vxge_hw_vpath_handle *vp,
1790 enum vxge_hw_status status = VXGE_HW_OK;
1793 status = VXGE_HW_ERR_INVALID_HANDLE;
1797 status = __vxge_hw_vpath_rts_table_get(vp,
1798 VXGE_HW_RTS_ACCESS_STEER_CTRL_ACTION_LIST_FIRST_ENTRY,
1799 VXGE_HW_RTS_ACCESS_STEER_CTRL_DATA_STRUCT_SEL_DA,
1802 if (status != VXGE_HW_OK)
1805 data1 = VXGE_HW_RTS_ACCESS_STEER_DATA0_GET_DA_MAC_ADDR(data1);
1807 data2 = VXGE_HW_RTS_ACCESS_STEER_DATA1_GET_DA_MAC_ADDR_MASK(data2);
1809 for (i = ETH_ALEN; i > 0; i--) {
1810 macaddr[i-1] = (u8)(data1 & 0xFF);
1813 macaddr_mask[i-1] = (u8)(data2 & 0xFF);
1821 * vxge_hw_vpath_mac_addr_get_next - Get the next mac address entry for this
1823 * from MAC address table.
1824 * @vp: Vpath handle.
1825 * @macaddr: Next MAC address entry for this vpath in the list
1826 * @macaddr_mask: MAC address mask for macaddr
1828 * Returns the next mac address and mac address mask in the list for this
1830 * see also: vxge_hw_vpath_mac_addr_get
1834 vxge_hw_vpath_mac_addr_get_next(
1835 struct __vxge_hw_vpath_handle *vp,
1842 enum vxge_hw_status status = VXGE_HW_OK;
1845 status = VXGE_HW_ERR_INVALID_HANDLE;
1849 status = __vxge_hw_vpath_rts_table_get(vp,
1850 VXGE_HW_RTS_ACCESS_STEER_CTRL_ACTION_LIST_NEXT_ENTRY,
1851 VXGE_HW_RTS_ACCESS_STEER_CTRL_DATA_STRUCT_SEL_DA,
1854 if (status != VXGE_HW_OK)
1857 data1 = VXGE_HW_RTS_ACCESS_STEER_DATA0_GET_DA_MAC_ADDR(data1);
1859 data2 = VXGE_HW_RTS_ACCESS_STEER_DATA1_GET_DA_MAC_ADDR_MASK(data2);
1861 for (i = ETH_ALEN; i > 0; i--) {
1862 macaddr[i-1] = (u8)(data1 & 0xFF);
1865 macaddr_mask[i-1] = (u8)(data2 & 0xFF);
1874 * vxge_hw_vpath_mac_addr_delete - Delete the mac address entry for this vpath
1875 * to MAC address table.
1876 * @vp: Vpath handle.
1877 * @macaddr: MAC address to be added for this vpath into the list
1878 * @macaddr_mask: MAC address mask for macaddr
1880 * Delete the given mac address and mac address mask into the list for this
1882 * see also: vxge_hw_vpath_mac_addr_add, vxge_hw_vpath_mac_addr_get and
1883 * vxge_hw_vpath_mac_addr_get_next
1887 vxge_hw_vpath_mac_addr_delete(
1888 struct __vxge_hw_vpath_handle *vp,
1895 enum vxge_hw_status status = VXGE_HW_OK;
1898 status = VXGE_HW_ERR_INVALID_HANDLE;
1902 for (i = 0; i < ETH_ALEN; i++) {
1904 data1 |= (u8)macaddr[i];
1907 data2 |= (u8)macaddr_mask[i];
1910 status = __vxge_hw_vpath_rts_table_set(vp,
1911 VXGE_HW_RTS_ACCESS_STEER_CTRL_ACTION_DELETE_ENTRY,
1912 VXGE_HW_RTS_ACCESS_STEER_CTRL_DATA_STRUCT_SEL_DA,
1914 VXGE_HW_RTS_ACCESS_STEER_DATA0_DA_MAC_ADDR(data1),
1915 VXGE_HW_RTS_ACCESS_STEER_DATA1_DA_MAC_ADDR_MASK(data2));
1921 * vxge_hw_vpath_vid_add - Add the vlan id entry for this vpath
1923 * @vp: Vpath handle.
1924 * @vid: vlan id to be added for this vpath into the list
1926 * Adds the given vlan id into the list for this vpath.
1927 * see also: vxge_hw_vpath_vid_delete
1931 vxge_hw_vpath_vid_add(struct __vxge_hw_vpath_handle *vp, u64 vid)
1933 enum vxge_hw_status status = VXGE_HW_OK;
1936 status = VXGE_HW_ERR_INVALID_HANDLE;
1940 status = __vxge_hw_vpath_rts_table_set(vp,
1941 VXGE_HW_RTS_ACCESS_STEER_CTRL_ACTION_ADD_ENTRY,
1942 VXGE_HW_RTS_ACCESS_STEER_CTRL_DATA_STRUCT_SEL_VID,
1943 0, VXGE_HW_RTS_ACCESS_STEER_DATA0_VLAN_ID(vid), 0);
1949 * vxge_hw_vpath_vid_delete - Delete the vlan id entry for this vpath
1951 * @vp: Vpath handle.
1952 * @vid: vlan id to be added for this vpath into the list
1954 * Adds the given vlan id into the list for this vpath.
1955 * see also: vxge_hw_vpath_vid_add
1959 vxge_hw_vpath_vid_delete(struct __vxge_hw_vpath_handle *vp, u64 vid)
1961 enum vxge_hw_status status = VXGE_HW_OK;
1964 status = VXGE_HW_ERR_INVALID_HANDLE;
1968 status = __vxge_hw_vpath_rts_table_set(vp,
1969 VXGE_HW_RTS_ACCESS_STEER_CTRL_ACTION_DELETE_ENTRY,
1970 VXGE_HW_RTS_ACCESS_STEER_CTRL_DATA_STRUCT_SEL_VID,
1971 0, VXGE_HW_RTS_ACCESS_STEER_DATA0_VLAN_ID(vid), 0);
1977 * vxge_hw_vpath_promisc_enable - Enable promiscuous mode.
1978 * @vp: Vpath handle.
1980 * Enable promiscuous mode of Titan-e operation.
1982 * See also: vxge_hw_vpath_promisc_disable().
1984 enum vxge_hw_status vxge_hw_vpath_promisc_enable(
1985 struct __vxge_hw_vpath_handle *vp)
1988 struct __vxge_hw_virtualpath *vpath;
1989 enum vxge_hw_status status = VXGE_HW_OK;
1991 if ((vp == NULL) || (vp->vpath->ringh == NULL)) {
1992 status = VXGE_HW_ERR_INVALID_HANDLE;
1998 /* Enable promiscuous mode for function 0 only */
1999 if (!(vpath->hldev->access_rights &
2000 VXGE_HW_DEVICE_ACCESS_RIGHT_MRPCIM))
2003 val64 = readq(&vpath->vp_reg->rxmac_vcfg0);
2005 if (!(val64 & VXGE_HW_RXMAC_VCFG0_UCAST_ALL_ADDR_EN)) {
2007 val64 |= VXGE_HW_RXMAC_VCFG0_UCAST_ALL_ADDR_EN |
2008 VXGE_HW_RXMAC_VCFG0_MCAST_ALL_ADDR_EN |
2009 VXGE_HW_RXMAC_VCFG0_BCAST_EN |
2010 VXGE_HW_RXMAC_VCFG0_ALL_VID_EN;
2012 writeq(val64, &vpath->vp_reg->rxmac_vcfg0);
2019 * vxge_hw_vpath_promisc_disable - Disable promiscuous mode.
2020 * @vp: Vpath handle.
2022 * Disable promiscuous mode of Titan-e operation.
2024 * See also: vxge_hw_vpath_promisc_enable().
2026 enum vxge_hw_status vxge_hw_vpath_promisc_disable(
2027 struct __vxge_hw_vpath_handle *vp)
2030 struct __vxge_hw_virtualpath *vpath;
2031 enum vxge_hw_status status = VXGE_HW_OK;
2033 if ((vp == NULL) || (vp->vpath->ringh == NULL)) {
2034 status = VXGE_HW_ERR_INVALID_HANDLE;
2040 val64 = readq(&vpath->vp_reg->rxmac_vcfg0);
2042 if (val64 & VXGE_HW_RXMAC_VCFG0_UCAST_ALL_ADDR_EN) {
2044 val64 &= ~(VXGE_HW_RXMAC_VCFG0_UCAST_ALL_ADDR_EN |
2045 VXGE_HW_RXMAC_VCFG0_MCAST_ALL_ADDR_EN |
2046 VXGE_HW_RXMAC_VCFG0_ALL_VID_EN);
2048 writeq(val64, &vpath->vp_reg->rxmac_vcfg0);
2055 * vxge_hw_vpath_bcast_enable - Enable broadcast
2056 * @vp: Vpath handle.
2058 * Enable receiving broadcasts.
2060 enum vxge_hw_status vxge_hw_vpath_bcast_enable(
2061 struct __vxge_hw_vpath_handle *vp)
2064 struct __vxge_hw_virtualpath *vpath;
2065 enum vxge_hw_status status = VXGE_HW_OK;
2067 if ((vp == NULL) || (vp->vpath->ringh == NULL)) {
2068 status = VXGE_HW_ERR_INVALID_HANDLE;
2074 val64 = readq(&vpath->vp_reg->rxmac_vcfg0);
2076 if (!(val64 & VXGE_HW_RXMAC_VCFG0_BCAST_EN)) {
2077 val64 |= VXGE_HW_RXMAC_VCFG0_BCAST_EN;
2078 writeq(val64, &vpath->vp_reg->rxmac_vcfg0);
2085 * vxge_hw_vpath_mcast_enable - Enable multicast addresses.
2086 * @vp: Vpath handle.
2088 * Enable Titan-e multicast addresses.
2089 * Returns: VXGE_HW_OK on success.
2092 enum vxge_hw_status vxge_hw_vpath_mcast_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_MCAST_ALL_ADDR_EN)) {
2109 val64 |= VXGE_HW_RXMAC_VCFG0_MCAST_ALL_ADDR_EN;
2110 writeq(val64, &vpath->vp_reg->rxmac_vcfg0);
2117 * vxge_hw_vpath_mcast_disable - Disable multicast addresses.
2118 * @vp: Vpath handle.
2120 * Disable Titan-e multicast addresses.
2121 * Returns: VXGE_HW_OK - success.
2122 * VXGE_HW_ERR_INVALID_HANDLE - Invalid handle
2126 vxge_hw_vpath_mcast_disable(struct __vxge_hw_vpath_handle *vp)
2129 struct __vxge_hw_virtualpath *vpath;
2130 enum vxge_hw_status status = VXGE_HW_OK;
2132 if ((vp == NULL) || (vp->vpath->ringh == NULL)) {
2133 status = VXGE_HW_ERR_INVALID_HANDLE;
2139 val64 = readq(&vpath->vp_reg->rxmac_vcfg0);
2141 if (val64 & VXGE_HW_RXMAC_VCFG0_MCAST_ALL_ADDR_EN) {
2142 val64 &= ~VXGE_HW_RXMAC_VCFG0_MCAST_ALL_ADDR_EN;
2143 writeq(val64, &vpath->vp_reg->rxmac_vcfg0);
2150 * vxge_hw_vpath_alarm_process - Process Alarms.
2151 * @vpath: Virtual Path.
2152 * @skip_alarms: Do not clear the alarms
2154 * Process vpath alarms.
2157 enum vxge_hw_status vxge_hw_vpath_alarm_process(
2158 struct __vxge_hw_vpath_handle *vp,
2161 enum vxge_hw_status status = VXGE_HW_OK;
2164 status = VXGE_HW_ERR_INVALID_HANDLE;
2168 status = __vxge_hw_vpath_alarm_process(vp->vpath, skip_alarms);
2174 * vxge_hw_vpath_msix_set - Associate MSIX vectors with TIM interrupts and
2176 * @vp: Virtual Path handle.
2177 * @tim_msix_id: MSIX vectors associated with VXGE_HW_MAX_INTR_PER_VP number of
2178 * interrupts(Can be repeated). If fifo or ring are not enabled
2179 * the MSIX vector for that should be set to 0
2180 * @alarm_msix_id: MSIX vector for alarm.
2182 * This API will associate a given MSIX vector numbers with the four TIM
2183 * interrupts and alarm interrupt.
2186 vxge_hw_vpath_msix_set(struct __vxge_hw_vpath_handle *vp, int *tim_msix_id,
2190 struct __vxge_hw_virtualpath *vpath = vp->vpath;
2191 struct vxge_hw_vpath_reg __iomem *vp_reg = vpath->vp_reg;
2192 u32 vp_id = vp->vpath->vp_id;
2194 val64 = VXGE_HW_INTERRUPT_CFG0_GROUP0_MSIX_FOR_TXTI(
2195 (vp_id * 4) + tim_msix_id[0]) |
2196 VXGE_HW_INTERRUPT_CFG0_GROUP1_MSIX_FOR_TXTI(
2197 (vp_id * 4) + tim_msix_id[1]);
2199 writeq(val64, &vp_reg->interrupt_cfg0);
2201 writeq(VXGE_HW_INTERRUPT_CFG2_ALARM_MAP_TO_MSG(
2202 (vpath->hldev->first_vp_id * 4) + alarm_msix_id),
2203 &vp_reg->interrupt_cfg2);
2205 if (vpath->hldev->config.intr_mode ==
2206 VXGE_HW_INTR_MODE_MSIX_ONE_SHOT) {
2207 __vxge_hw_pio_mem_write32_upper((u32)vxge_bVALn(
2208 VXGE_HW_ONE_SHOT_VECT0_EN_ONE_SHOT_VECT0_EN,
2209 0, 32), &vp_reg->one_shot_vect0_en);
2210 __vxge_hw_pio_mem_write32_upper((u32)vxge_bVALn(
2211 VXGE_HW_ONE_SHOT_VECT1_EN_ONE_SHOT_VECT1_EN,
2212 0, 32), &vp_reg->one_shot_vect1_en);
2213 __vxge_hw_pio_mem_write32_upper((u32)vxge_bVALn(
2214 VXGE_HW_ONE_SHOT_VECT2_EN_ONE_SHOT_VECT2_EN,
2215 0, 32), &vp_reg->one_shot_vect2_en);
2220 * vxge_hw_vpath_msix_mask - Mask MSIX Vector.
2221 * @vp: Virtual Path handle.
2224 * The function masks the msix interrupt for the given msix_id
2227 * Otherwise, VXGE_HW_ERR_WRONG_IRQ if the msix index is out of range
2232 vxge_hw_vpath_msix_mask(struct __vxge_hw_vpath_handle *vp, int msix_id)
2234 struct __vxge_hw_device *hldev = vp->vpath->hldev;
2235 __vxge_hw_pio_mem_write32_upper(
2236 (u32) vxge_bVALn(vxge_mBIT(msix_id >> 2), 0, 32),
2237 &hldev->common_reg->set_msix_mask_vect[msix_id % 4]);
2241 * vxge_hw_vpath_msix_clear - Clear MSIX Vector.
2242 * @vp: Virtual Path handle.
2245 * The function clears the msix interrupt for the given msix_id
2248 * Otherwise, VXGE_HW_ERR_WRONG_IRQ if the msix index is out of range
2252 void vxge_hw_vpath_msix_clear(struct __vxge_hw_vpath_handle *vp, int msix_id)
2254 struct __vxge_hw_device *hldev = vp->vpath->hldev;
2256 if ((hldev->config.intr_mode == VXGE_HW_INTR_MODE_MSIX_ONE_SHOT))
2257 __vxge_hw_pio_mem_write32_upper(
2258 (u32) vxge_bVALn(vxge_mBIT((msix_id >> 2)), 0, 32),
2259 &hldev->common_reg->clr_msix_one_shot_vec[msix_id % 4]);
2261 __vxge_hw_pio_mem_write32_upper(
2262 (u32) vxge_bVALn(vxge_mBIT((msix_id >> 2)), 0, 32),
2263 &hldev->common_reg->clear_msix_mask_vect[msix_id % 4]);
2267 * vxge_hw_vpath_msix_unmask - Unmask the MSIX Vector.
2268 * @vp: Virtual Path handle.
2271 * The function unmasks the msix interrupt for the given msix_id
2274 * Otherwise, VXGE_HW_ERR_WRONG_IRQ if the msix index is out of range
2279 vxge_hw_vpath_msix_unmask(struct __vxge_hw_vpath_handle *vp, int msix_id)
2281 struct __vxge_hw_device *hldev = vp->vpath->hldev;
2282 __vxge_hw_pio_mem_write32_upper(
2283 (u32)vxge_bVALn(vxge_mBIT(msix_id >> 2), 0, 32),
2284 &hldev->common_reg->clear_msix_mask_vect[msix_id%4]);
2288 * vxge_hw_vpath_inta_mask_tx_rx - Mask Tx and Rx interrupts.
2289 * @vp: Virtual Path handle.
2291 * Mask Tx and Rx vpath interrupts.
2293 * See also: vxge_hw_vpath_inta_mask_tx_rx()
2295 void vxge_hw_vpath_inta_mask_tx_rx(struct __vxge_hw_vpath_handle *vp)
2297 u64 tim_int_mask0[4] = {[0 ...3] = 0};
2298 u32 tim_int_mask1[4] = {[0 ...3] = 0};
2300 struct __vxge_hw_device *hldev = vp->vpath->hldev;
2302 VXGE_HW_DEVICE_TIM_INT_MASK_SET(tim_int_mask0,
2303 tim_int_mask1, vp->vpath->vp_id);
2305 val64 = readq(&hldev->common_reg->tim_int_mask0);
2307 if ((tim_int_mask0[VXGE_HW_VPATH_INTR_TX] != 0) ||
2308 (tim_int_mask0[VXGE_HW_VPATH_INTR_RX] != 0)) {
2309 writeq((tim_int_mask0[VXGE_HW_VPATH_INTR_TX] |
2310 tim_int_mask0[VXGE_HW_VPATH_INTR_RX] | val64),
2311 &hldev->common_reg->tim_int_mask0);
2314 val64 = readl(&hldev->common_reg->tim_int_mask1);
2316 if ((tim_int_mask1[VXGE_HW_VPATH_INTR_TX] != 0) ||
2317 (tim_int_mask1[VXGE_HW_VPATH_INTR_RX] != 0)) {
2318 __vxge_hw_pio_mem_write32_upper(
2319 (tim_int_mask1[VXGE_HW_VPATH_INTR_TX] |
2320 tim_int_mask1[VXGE_HW_VPATH_INTR_RX] | val64),
2321 &hldev->common_reg->tim_int_mask1);
2326 * vxge_hw_vpath_inta_unmask_tx_rx - Unmask Tx and Rx interrupts.
2327 * @vp: Virtual Path handle.
2329 * Unmask Tx and Rx vpath interrupts.
2331 * See also: vxge_hw_vpath_inta_mask_tx_rx()
2333 void vxge_hw_vpath_inta_unmask_tx_rx(struct __vxge_hw_vpath_handle *vp)
2335 u64 tim_int_mask0[4] = {[0 ...3] = 0};
2336 u32 tim_int_mask1[4] = {[0 ...3] = 0};
2338 struct __vxge_hw_device *hldev = vp->vpath->hldev;
2340 VXGE_HW_DEVICE_TIM_INT_MASK_SET(tim_int_mask0,
2341 tim_int_mask1, vp->vpath->vp_id);
2343 val64 = readq(&hldev->common_reg->tim_int_mask0);
2345 if ((tim_int_mask0[VXGE_HW_VPATH_INTR_TX] != 0) ||
2346 (tim_int_mask0[VXGE_HW_VPATH_INTR_RX] != 0)) {
2347 writeq((~(tim_int_mask0[VXGE_HW_VPATH_INTR_TX] |
2348 tim_int_mask0[VXGE_HW_VPATH_INTR_RX])) & val64,
2349 &hldev->common_reg->tim_int_mask0);
2352 if ((tim_int_mask1[VXGE_HW_VPATH_INTR_TX] != 0) ||
2353 (tim_int_mask1[VXGE_HW_VPATH_INTR_RX] != 0)) {
2354 __vxge_hw_pio_mem_write32_upper(
2355 (~(tim_int_mask1[VXGE_HW_VPATH_INTR_TX] |
2356 tim_int_mask1[VXGE_HW_VPATH_INTR_RX])) & val64,
2357 &hldev->common_reg->tim_int_mask1);
2362 * vxge_hw_vpath_poll_rx - Poll Rx Virtual Path for completed
2363 * descriptors and process the same.
2364 * @ring: Handle to the ring object used for receive
2366 * The function polls the Rx for the completed descriptors and calls
2367 * the driver via supplied completion callback.
2369 * Returns: VXGE_HW_OK, if the polling is completed successful.
2370 * VXGE_HW_COMPLETIONS_REMAIN: There are still more completed
2371 * descriptors available which are yet to be processed.
2373 * See also: vxge_hw_vpath_poll_rx()
2375 enum vxge_hw_status vxge_hw_vpath_poll_rx(struct __vxge_hw_ring *ring)
2378 enum vxge_hw_status status = VXGE_HW_OK;
2384 status = vxge_hw_ring_rxd_next_completed(ring, &first_rxdh, &t_code);
2385 if (status == VXGE_HW_OK)
2386 ring->callback(ring, first_rxdh,
2387 t_code, ring->channel.userdata);
2389 if (ring->cmpl_cnt != 0) {
2390 ring->doorbell_cnt += ring->cmpl_cnt;
2391 if (ring->doorbell_cnt >= ring->rxds_limit) {
2393 * Each RxD is of 4 qwords, update the number of
2394 * qwords replenished
2396 new_count = (ring->doorbell_cnt * 4);
2398 /* For each block add 4 more qwords */
2399 ring->total_db_cnt += ring->doorbell_cnt;
2400 if (ring->total_db_cnt >= ring->rxds_per_block) {
2402 /* Reset total count */
2403 ring->total_db_cnt %= ring->rxds_per_block;
2405 writeq(VXGE_HW_PRC_RXD_DOORBELL_NEW_QW_CNT(new_count),
2406 &ring->vp_reg->prc_rxd_doorbell);
2407 readl(&ring->common_reg->titan_general_int_status);
2408 ring->doorbell_cnt = 0;
2416 * vxge_hw_vpath_poll_tx - Poll Tx for completed descriptors and process
2418 * @fifo: Handle to the fifo object used for non offload send
2420 * The function polls the Tx for the completed descriptors and calls
2421 * the driver via supplied completion callback.
2423 * Returns: VXGE_HW_OK, if the polling is completed successful.
2424 * VXGE_HW_COMPLETIONS_REMAIN: There are still more completed
2425 * descriptors available which are yet to be processed.
2427 enum vxge_hw_status vxge_hw_vpath_poll_tx(struct __vxge_hw_fifo *fifo,
2428 struct sk_buff ***skb_ptr, int nr_skb,
2431 enum vxge_hw_fifo_tcode t_code;
2433 enum vxge_hw_status status = VXGE_HW_OK;
2434 struct __vxge_hw_channel *channel;
2436 channel = &fifo->channel;
2438 status = vxge_hw_fifo_txdl_next_completed(fifo,
2439 &first_txdlh, &t_code);
2440 if (status == VXGE_HW_OK)
2441 if (fifo->callback(fifo, first_txdlh, t_code,
2442 channel->userdata, skb_ptr, nr_skb, more) != VXGE_HW_OK)
2443 status = VXGE_HW_COMPLETIONS_REMAIN;