aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/sfc/falcon.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/sfc/falcon.c')
-rw-r--r--drivers/net/sfc/falcon.c70
1 files changed, 26 insertions, 44 deletions
diff --git a/drivers/net/sfc/falcon.c b/drivers/net/sfc/falcon.c
index 759f55ae4b83..3cb7e613ab30 100644
--- a/drivers/net/sfc/falcon.c
+++ b/drivers/net/sfc/falcon.c
@@ -108,21 +108,6 @@ static int rx_xon_thresh_bytes = -1;
108module_param(rx_xon_thresh_bytes, int, 0644); 108module_param(rx_xon_thresh_bytes, int, 0644);
109MODULE_PARM_DESC(rx_xon_thresh_bytes, "RX fifo XON threshold"); 109MODULE_PARM_DESC(rx_xon_thresh_bytes, "RX fifo XON threshold");
110 110
111/* TX descriptor ring size - min 512 max 4k */
112#define FALCON_TXD_RING_ORDER FFE_AZ_TX_DESCQ_SIZE_1K
113#define FALCON_TXD_RING_SIZE 1024
114#define FALCON_TXD_RING_MASK (FALCON_TXD_RING_SIZE - 1)
115
116/* RX descriptor ring size - min 512 max 4k */
117#define FALCON_RXD_RING_ORDER FFE_AZ_RX_DESCQ_SIZE_1K
118#define FALCON_RXD_RING_SIZE 1024
119#define FALCON_RXD_RING_MASK (FALCON_RXD_RING_SIZE - 1)
120
121/* Event queue size - max 32k */
122#define FALCON_EVQ_ORDER FFE_AZ_EVQ_SIZE_4K
123#define FALCON_EVQ_SIZE 4096
124#define FALCON_EVQ_MASK (FALCON_EVQ_SIZE - 1)
125
126/* If FALCON_MAX_INT_ERRORS internal errors occur within 111/* If FALCON_MAX_INT_ERRORS internal errors occur within
127 * FALCON_INT_ERROR_EXPIRE seconds, we consider the NIC broken and 112 * FALCON_INT_ERROR_EXPIRE seconds, we consider the NIC broken and
128 * disable it. 113 * disable it.
@@ -420,7 +405,7 @@ static inline void falcon_notify_tx_desc(struct efx_tx_queue *tx_queue)
420 unsigned write_ptr; 405 unsigned write_ptr;
421 efx_dword_t reg; 406 efx_dword_t reg;
422 407
423 write_ptr = tx_queue->write_count & FALCON_TXD_RING_MASK; 408 write_ptr = tx_queue->write_count & EFX_TXQ_MASK;
424 EFX_POPULATE_DWORD_1(reg, FRF_AZ_TX_DESC_WPTR_DWORD, write_ptr); 409 EFX_POPULATE_DWORD_1(reg, FRF_AZ_TX_DESC_WPTR_DWORD, write_ptr);
425 efx_writed_page(tx_queue->efx, &reg, 410 efx_writed_page(tx_queue->efx, &reg,
426 FR_AZ_TX_DESC_UPD_DWORD_P0, tx_queue->queue); 411 FR_AZ_TX_DESC_UPD_DWORD_P0, tx_queue->queue);
@@ -441,7 +426,7 @@ void falcon_push_buffers(struct efx_tx_queue *tx_queue)
441 BUG_ON(tx_queue->write_count == tx_queue->insert_count); 426 BUG_ON(tx_queue->write_count == tx_queue->insert_count);
442 427
443 do { 428 do {
444 write_ptr = tx_queue->write_count & FALCON_TXD_RING_MASK; 429 write_ptr = tx_queue->write_count & EFX_TXQ_MASK;
445 buffer = &tx_queue->buffer[write_ptr]; 430 buffer = &tx_queue->buffer[write_ptr];
446 txd = falcon_tx_desc(tx_queue, write_ptr); 431 txd = falcon_tx_desc(tx_queue, write_ptr);
447 ++tx_queue->write_count; 432 ++tx_queue->write_count;
@@ -462,9 +447,10 @@ void falcon_push_buffers(struct efx_tx_queue *tx_queue)
462int falcon_probe_tx(struct efx_tx_queue *tx_queue) 447int falcon_probe_tx(struct efx_tx_queue *tx_queue)
463{ 448{
464 struct efx_nic *efx = tx_queue->efx; 449 struct efx_nic *efx = tx_queue->efx;
450 BUILD_BUG_ON(EFX_TXQ_SIZE < 512 || EFX_TXQ_SIZE > 4096 ||
451 EFX_TXQ_SIZE & EFX_TXQ_MASK);
465 return falcon_alloc_special_buffer(efx, &tx_queue->txd, 452 return falcon_alloc_special_buffer(efx, &tx_queue->txd,
466 FALCON_TXD_RING_SIZE * 453 EFX_TXQ_SIZE * sizeof(efx_qword_t));
467 sizeof(efx_qword_t));
468} 454}
469 455
470void falcon_init_tx(struct efx_tx_queue *tx_queue) 456void falcon_init_tx(struct efx_tx_queue *tx_queue)
@@ -487,7 +473,8 @@ void falcon_init_tx(struct efx_tx_queue *tx_queue)
487 tx_queue->channel->channel, 473 tx_queue->channel->channel,
488 FRF_AZ_TX_DESCQ_OWNER_ID, 0, 474 FRF_AZ_TX_DESCQ_OWNER_ID, 0,
489 FRF_AZ_TX_DESCQ_LABEL, tx_queue->queue, 475 FRF_AZ_TX_DESCQ_LABEL, tx_queue->queue,
490 FRF_AZ_TX_DESCQ_SIZE, FALCON_TXD_RING_ORDER, 476 FRF_AZ_TX_DESCQ_SIZE,
477 __ffs(tx_queue->txd.entries),
491 FRF_AZ_TX_DESCQ_TYPE, 0, 478 FRF_AZ_TX_DESCQ_TYPE, 0,
492 FRF_BZ_TX_NON_IP_DROP_DIS, 1); 479 FRF_BZ_TX_NON_IP_DROP_DIS, 1);
493 480
@@ -592,12 +579,12 @@ void falcon_notify_rx_desc(struct efx_rx_queue *rx_queue)
592 while (rx_queue->notified_count != rx_queue->added_count) { 579 while (rx_queue->notified_count != rx_queue->added_count) {
593 falcon_build_rx_desc(rx_queue, 580 falcon_build_rx_desc(rx_queue,
594 rx_queue->notified_count & 581 rx_queue->notified_count &
595 FALCON_RXD_RING_MASK); 582 EFX_RXQ_MASK);
596 ++rx_queue->notified_count; 583 ++rx_queue->notified_count;
597 } 584 }
598 585
599 wmb(); 586 wmb();
600 write_ptr = rx_queue->added_count & FALCON_RXD_RING_MASK; 587 write_ptr = rx_queue->added_count & EFX_RXQ_MASK;
601 EFX_POPULATE_DWORD_1(reg, FRF_AZ_RX_DESC_WPTR_DWORD, write_ptr); 588 EFX_POPULATE_DWORD_1(reg, FRF_AZ_RX_DESC_WPTR_DWORD, write_ptr);
602 efx_writed_page(rx_queue->efx, &reg, 589 efx_writed_page(rx_queue->efx, &reg,
603 FR_AZ_RX_DESC_UPD_DWORD_P0, rx_queue->queue); 590 FR_AZ_RX_DESC_UPD_DWORD_P0, rx_queue->queue);
@@ -606,9 +593,10 @@ void falcon_notify_rx_desc(struct efx_rx_queue *rx_queue)
606int falcon_probe_rx(struct efx_rx_queue *rx_queue) 593int falcon_probe_rx(struct efx_rx_queue *rx_queue)
607{ 594{
608 struct efx_nic *efx = rx_queue->efx; 595 struct efx_nic *efx = rx_queue->efx;
596 BUILD_BUG_ON(EFX_RXQ_SIZE < 512 || EFX_RXQ_SIZE > 4096 ||
597 EFX_RXQ_SIZE & EFX_RXQ_MASK);
609 return falcon_alloc_special_buffer(efx, &rx_queue->rxd, 598 return falcon_alloc_special_buffer(efx, &rx_queue->rxd,
610 FALCON_RXD_RING_SIZE * 599 EFX_RXQ_SIZE * sizeof(efx_qword_t));
611 sizeof(efx_qword_t));
612} 600}
613 601
614void falcon_init_rx(struct efx_rx_queue *rx_queue) 602void falcon_init_rx(struct efx_rx_queue *rx_queue)
@@ -636,7 +624,8 @@ void falcon_init_rx(struct efx_rx_queue *rx_queue)
636 rx_queue->channel->channel, 624 rx_queue->channel->channel,
637 FRF_AZ_RX_DESCQ_OWNER_ID, 0, 625 FRF_AZ_RX_DESCQ_OWNER_ID, 0,
638 FRF_AZ_RX_DESCQ_LABEL, rx_queue->queue, 626 FRF_AZ_RX_DESCQ_LABEL, rx_queue->queue,
639 FRF_AZ_RX_DESCQ_SIZE, FALCON_RXD_RING_ORDER, 627 FRF_AZ_RX_DESCQ_SIZE,
628 __ffs(rx_queue->rxd.entries),
640 FRF_AZ_RX_DESCQ_TYPE, 0 /* kernel queue */ , 629 FRF_AZ_RX_DESCQ_TYPE, 0 /* kernel queue */ ,
641 /* For >=B0 this is scatter so disable */ 630 /* For >=B0 this is scatter so disable */
642 FRF_AZ_RX_DESCQ_JUMBO, !is_b0, 631 FRF_AZ_RX_DESCQ_JUMBO, !is_b0,
@@ -741,7 +730,7 @@ static void falcon_handle_tx_event(struct efx_channel *channel,
741 tx_queue = &efx->tx_queue[tx_ev_q_label]; 730 tx_queue = &efx->tx_queue[tx_ev_q_label];
742 channel->irq_mod_score += 731 channel->irq_mod_score +=
743 (tx_ev_desc_ptr - tx_queue->read_count) & 732 (tx_ev_desc_ptr - tx_queue->read_count) &
744 efx->type->txd_ring_mask; 733 EFX_TXQ_MASK;
745 efx_xmit_done(tx_queue, tx_ev_desc_ptr); 734 efx_xmit_done(tx_queue, tx_ev_desc_ptr);
746 } else if (EFX_QWORD_FIELD(*event, FSF_AZ_TX_EV_WQ_FF_FULL)) { 735 } else if (EFX_QWORD_FIELD(*event, FSF_AZ_TX_EV_WQ_FF_FULL)) {
747 /* Rewrite the FIFO write pointer */ 736 /* Rewrite the FIFO write pointer */
@@ -848,9 +837,8 @@ static void falcon_handle_rx_bad_index(struct efx_rx_queue *rx_queue,
848 struct efx_nic *efx = rx_queue->efx; 837 struct efx_nic *efx = rx_queue->efx;
849 unsigned expected, dropped; 838 unsigned expected, dropped;
850 839
851 expected = rx_queue->removed_count & FALCON_RXD_RING_MASK; 840 expected = rx_queue->removed_count & EFX_RXQ_MASK;
852 dropped = ((index + FALCON_RXD_RING_SIZE - expected) & 841 dropped = (index - expected) & EFX_RXQ_MASK;
853 FALCON_RXD_RING_MASK);
854 EFX_INFO(efx, "dropped %d events (index=%d expected=%d)\n", 842 EFX_INFO(efx, "dropped %d events (index=%d expected=%d)\n",
855 dropped, index, expected); 843 dropped, index, expected);
856 844
@@ -887,7 +875,7 @@ static void falcon_handle_rx_event(struct efx_channel *channel,
887 rx_queue = &efx->rx_queue[channel->channel]; 875 rx_queue = &efx->rx_queue[channel->channel];
888 876
889 rx_ev_desc_ptr = EFX_QWORD_FIELD(*event, FSF_AZ_RX_EV_DESC_PTR); 877 rx_ev_desc_ptr = EFX_QWORD_FIELD(*event, FSF_AZ_RX_EV_DESC_PTR);
890 expected_ptr = rx_queue->removed_count & FALCON_RXD_RING_MASK; 878 expected_ptr = rx_queue->removed_count & EFX_RXQ_MASK;
891 if (unlikely(rx_ev_desc_ptr != expected_ptr)) 879 if (unlikely(rx_ev_desc_ptr != expected_ptr))
892 falcon_handle_rx_bad_index(rx_queue, rx_ev_desc_ptr); 880 falcon_handle_rx_bad_index(rx_queue, rx_ev_desc_ptr);
893 881
@@ -1075,7 +1063,7 @@ int falcon_process_eventq(struct efx_channel *channel, int rx_quota)
1075 } 1063 }
1076 1064
1077 /* Increment read pointer */ 1065 /* Increment read pointer */
1078 read_ptr = (read_ptr + 1) & FALCON_EVQ_MASK; 1066 read_ptr = (read_ptr + 1) & EFX_EVQ_MASK;
1079 1067
1080 } while (rx_packets < rx_quota); 1068 } while (rx_packets < rx_quota);
1081 1069
@@ -1120,10 +1108,10 @@ void falcon_set_int_moderation(struct efx_channel *channel)
1120int falcon_probe_eventq(struct efx_channel *channel) 1108int falcon_probe_eventq(struct efx_channel *channel)
1121{ 1109{
1122 struct efx_nic *efx = channel->efx; 1110 struct efx_nic *efx = channel->efx;
1123 unsigned int evq_size; 1111 BUILD_BUG_ON(EFX_EVQ_SIZE < 512 || EFX_EVQ_SIZE > 32768 ||
1124 1112 EFX_EVQ_SIZE & EFX_EVQ_MASK);
1125 evq_size = FALCON_EVQ_SIZE * sizeof(efx_qword_t); 1113 return falcon_alloc_special_buffer(efx, &channel->eventq,
1126 return falcon_alloc_special_buffer(efx, &channel->eventq, evq_size); 1114 EFX_EVQ_SIZE * sizeof(efx_qword_t));
1127} 1115}
1128 1116
1129void falcon_init_eventq(struct efx_channel *channel) 1117void falcon_init_eventq(struct efx_channel *channel)
@@ -1144,7 +1132,7 @@ void falcon_init_eventq(struct efx_channel *channel)
1144 /* Push event queue to card */ 1132 /* Push event queue to card */
1145 EFX_POPULATE_OWORD_3(evq_ptr, 1133 EFX_POPULATE_OWORD_3(evq_ptr,
1146 FRF_AZ_EVQ_EN, 1, 1134 FRF_AZ_EVQ_EN, 1,
1147 FRF_AZ_EVQ_SIZE, FALCON_EVQ_ORDER, 1135 FRF_AZ_EVQ_SIZE, __ffs(channel->eventq.entries),
1148 FRF_AZ_EVQ_BUF_BASE_ID, channel->eventq.index); 1136 FRF_AZ_EVQ_BUF_BASE_ID, channel->eventq.index);
1149 efx_writeo_table(efx, &evq_ptr, efx->type->evq_ptr_tbl_base, 1137 efx_writeo_table(efx, &evq_ptr, efx->type->evq_ptr_tbl_base,
1150 channel->channel); 1138 channel->channel);
@@ -1214,7 +1202,7 @@ static void falcon_poll_flush_events(struct efx_nic *efx)
1214 struct efx_tx_queue *tx_queue; 1202 struct efx_tx_queue *tx_queue;
1215 struct efx_rx_queue *rx_queue; 1203 struct efx_rx_queue *rx_queue;
1216 unsigned int read_ptr = channel->eventq_read_ptr; 1204 unsigned int read_ptr = channel->eventq_read_ptr;
1217 unsigned int end_ptr = (read_ptr - 1) & FALCON_EVQ_MASK; 1205 unsigned int end_ptr = (read_ptr - 1) & EFX_EVQ_MASK;
1218 1206
1219 do { 1207 do {
1220 efx_qword_t *event = falcon_event(channel, read_ptr); 1208 efx_qword_t *event = falcon_event(channel, read_ptr);
@@ -1252,7 +1240,7 @@ static void falcon_poll_flush_events(struct efx_nic *efx)
1252 } 1240 }
1253 } 1241 }
1254 1242
1255 read_ptr = (read_ptr + 1) & FALCON_EVQ_MASK; 1243 read_ptr = (read_ptr + 1) & EFX_EVQ_MASK;
1256 } while (read_ptr != end_ptr); 1244 } while (read_ptr != end_ptr);
1257} 1245}
1258 1246
@@ -3160,9 +3148,6 @@ struct efx_nic_type falcon_a_nic_type = {
3160 .buf_tbl_base = FR_AA_BUF_FULL_TBL_KER, 3148 .buf_tbl_base = FR_AA_BUF_FULL_TBL_KER,
3161 .evq_ptr_tbl_base = FR_AA_EVQ_PTR_TBL_KER, 3149 .evq_ptr_tbl_base = FR_AA_EVQ_PTR_TBL_KER,
3162 .evq_rptr_tbl_base = FR_AA_EVQ_RPTR_KER, 3150 .evq_rptr_tbl_base = FR_AA_EVQ_RPTR_KER,
3163 .txd_ring_mask = FALCON_TXD_RING_MASK,
3164 .rxd_ring_mask = FALCON_RXD_RING_MASK,
3165 .evq_size = FALCON_EVQ_SIZE,
3166 .max_dma_mask = FALCON_DMA_MASK, 3151 .max_dma_mask = FALCON_DMA_MASK,
3167 .tx_dma_mask = FALCON_TX_DMA_MASK, 3152 .tx_dma_mask = FALCON_TX_DMA_MASK,
3168 .bug5391_mask = 0xf, 3153 .bug5391_mask = 0xf,
@@ -3184,9 +3169,6 @@ struct efx_nic_type falcon_b_nic_type = {
3184 .buf_tbl_base = FR_BZ_BUF_FULL_TBL, 3169 .buf_tbl_base = FR_BZ_BUF_FULL_TBL,
3185 .evq_ptr_tbl_base = FR_BZ_EVQ_PTR_TBL, 3170 .evq_ptr_tbl_base = FR_BZ_EVQ_PTR_TBL,
3186 .evq_rptr_tbl_base = FR_BZ_EVQ_RPTR, 3171 .evq_rptr_tbl_base = FR_BZ_EVQ_RPTR,
3187 .txd_ring_mask = FALCON_TXD_RING_MASK,
3188 .rxd_ring_mask = FALCON_RXD_RING_MASK,
3189 .evq_size = FALCON_EVQ_SIZE,
3190 .max_dma_mask = FALCON_DMA_MASK, 3172 .max_dma_mask = FALCON_DMA_MASK,
3191 .tx_dma_mask = FALCON_TX_DMA_MASK, 3173 .tx_dma_mask = FALCON_TX_DMA_MASK,
3192 .bug5391_mask = 0, 3174 .bug5391_mask = 0,