Skip to content

Commit 2b245cb

Browse files
refactormanJeff Kirsher
authored andcommitted
ice: Implement transmit and NAPI support
This patch implements ice_start_xmit (the handler for ndo_start_xmit) and related functions. ice_start_xmit ultimately calls ice_tx_map, where the Tx descriptor is built and posted to the hardware by bumping the ring tail. This patch also implements ice_napi_poll, which is invoked when there's an interrupt on the VSI's queues. The interrupt can be due to either a completed Tx or an Rx event. In case of a completed Tx/Rx event, resources are reclaimed. Additionally, in case of an Rx event, the skb is fetched and passed up to the network stack. Signed-off-by: Anirudh Venkataramanan <[email protected]> Tested-by: Tony Brelinski <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent cdedef5 commit 2b245cb

File tree

5 files changed

+1171
-2
lines changed

5 files changed

+1171
-2
lines changed

drivers/net/ethernet/intel/ice/ice.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
(((val) << ICE_AQ_VSI_UP_TABLE_UP##i##_S) & \
6161
ICE_AQ_VSI_UP_TABLE_UP##i##_M)
6262

63+
#define ICE_TX_DESC(R, i) (&(((struct ice_tx_desc *)((R)->desc))[i]))
6364
#define ICE_RX_DESC(R, i) (&(((union ice_32b_rx_flex_desc *)((R)->desc))[i]))
6465

6566
#define ice_for_each_txq(vsi, i) \

drivers/net/ethernet/intel/ice/ice_lan_tx_rx.h

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,33 @@ enum ice_rx_flg64_bits {
131131
ICE_RXFLG_RSVD = 63
132132
};
133133

134+
/* for ice_32byte_rx_flex_desc.ptype_flexi_flags0 member */
135+
#define ICE_RX_FLEX_DESC_PTYPE_M (0x3FF) /* 10-bits */
136+
137+
/* for ice_32byte_rx_flex_desc.pkt_length member */
138+
#define ICE_RX_FLX_DESC_PKT_LEN_M (0x3FFF) /* 14-bits */
139+
140+
enum ice_rx_flex_desc_status_error_0_bits {
141+
/* Note: These are predefined bit offsets */
142+
ICE_RX_FLEX_DESC_STATUS0_DD_S = 0,
143+
ICE_RX_FLEX_DESC_STATUS0_EOF_S,
144+
ICE_RX_FLEX_DESC_STATUS0_HBO_S,
145+
ICE_RX_FLEX_DESC_STATUS0_L3L4P_S,
146+
ICE_RX_FLEX_DESC_STATUS0_XSUM_IPE_S,
147+
ICE_RX_FLEX_DESC_STATUS0_XSUM_L4E_S,
148+
ICE_RX_FLEX_DESC_STATUS0_XSUM_EIPE_S,
149+
ICE_RX_FLEX_DESC_STATUS0_XSUM_EUDPE_S,
150+
ICE_RX_FLEX_DESC_STATUS0_LPBK_S,
151+
ICE_RX_FLEX_DESC_STATUS0_IPV6EXADD_S,
152+
ICE_RX_FLEX_DESC_STATUS0_RXE_S,
153+
ICE_RX_FLEX_DESC_STATUS0_CRCP_S,
154+
ICE_RX_FLEX_DESC_STATUS0_RSS_VALID_S,
155+
ICE_RX_FLEX_DESC_STATUS0_L2TAG1P_S,
156+
ICE_RX_FLEX_DESC_STATUS0_XTRMD0_VALID_S,
157+
ICE_RX_FLEX_DESC_STATUS0_XTRMD1_VALID_S,
158+
ICE_RX_FLEX_DESC_STATUS0_LAST /* this entry must be last!!! */
159+
};
160+
134161
#define ICE_RXQ_CTX_SIZE_DWORDS 8
135162
#define ICE_RXQ_CTX_SZ (ICE_RXQ_CTX_SIZE_DWORDS * sizeof(u32))
136163

@@ -201,6 +228,25 @@ struct ice_tx_desc {
201228
__le64 cmd_type_offset_bsz;
202229
};
203230

231+
enum ice_tx_desc_dtype_value {
232+
ICE_TX_DESC_DTYPE_DATA = 0x0,
233+
ICE_TX_DESC_DTYPE_CTX = 0x1,
234+
/* DESC_DONE - HW has completed write-back of descriptor */
235+
ICE_TX_DESC_DTYPE_DESC_DONE = 0xF,
236+
};
237+
238+
#define ICE_TXD_QW1_CMD_S 4
239+
#define ICE_TXD_QW1_CMD_M (0xFFFUL << ICE_TXD_QW1_CMD_S)
240+
241+
enum ice_tx_desc_cmd_bits {
242+
ICE_TX_DESC_CMD_EOP = 0x0001,
243+
ICE_TX_DESC_CMD_RS = 0x0002,
244+
};
245+
246+
#define ICE_TXD_QW1_OFFSET_S 16
247+
#define ICE_TXD_QW1_TX_BUF_SZ_S 34
248+
#define ICE_TXD_QW1_L2TAG1_S 48
249+
204250
#define ICE_LAN_TXQ_MAX_QGRPS 127
205251
#define ICE_LAN_TXQ_MAX_QDIS 1023
206252

drivers/net/ethernet/intel/ice/ice_main.c

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,6 +1258,23 @@ static int ice_vsi_alloc_arrays(struct ice_vsi *vsi, bool alloc_qvectors)
12581258
return -ENOMEM;
12591259
}
12601260

1261+
/**
1262+
* ice_msix_clean_rings - MSIX mode Interrupt Handler
1263+
* @irq: interrupt number
1264+
* @data: pointer to a q_vector
1265+
*/
1266+
static irqreturn_t ice_msix_clean_rings(int __always_unused irq, void *data)
1267+
{
1268+
struct ice_q_vector *q_vector = (struct ice_q_vector *)data;
1269+
1270+
if (!q_vector->tx.ring && !q_vector->rx.ring)
1271+
return IRQ_HANDLED;
1272+
1273+
napi_schedule(&q_vector->napi);
1274+
1275+
return IRQ_HANDLED;
1276+
}
1277+
12611278
/**
12621279
* ice_vsi_alloc - Allocates the next available struct vsi in the PF
12631280
* @pf: board private structure
@@ -1298,6 +1315,8 @@ static struct ice_vsi *ice_vsi_alloc(struct ice_pf *pf, enum ice_vsi_type type)
12981315
if (ice_vsi_alloc_arrays(vsi, true))
12991316
goto err_rings;
13001317

1318+
/* Setup default MSIX irq handler for VSI */
1319+
vsi->irq_handler = ice_msix_clean_rings;
13011320
break;
13021321
default:
13031322
dev_warn(&pf->pdev->dev, "Unknown VSI type %d\n", vsi->type);
@@ -1741,6 +1760,9 @@ static int ice_vsi_alloc_q_vector(struct ice_vsi *vsi, int v_idx)
17411760
if (cpu_online(v_idx))
17421761
cpumask_set_cpu(v_idx, &q_vector->affinity_mask);
17431762

1763+
if (vsi->netdev)
1764+
netif_napi_add(vsi->netdev, &q_vector->napi, ice_napi_poll,
1765+
NAPI_POLL_WEIGHT);
17441766
/* tie q_vector and vsi together */
17451767
vsi->q_vectors[v_idx] = q_vector;
17461768

@@ -2914,6 +2936,21 @@ static int ice_vsi_stop_tx_rx_rings(struct ice_vsi *vsi)
29142936
return 0;
29152937
}
29162938

2939+
/**
2940+
* ice_napi_enable_all - Enable NAPI for all q_vectors in the VSI
2941+
* @vsi: the VSI being configured
2942+
*/
2943+
static void ice_napi_enable_all(struct ice_vsi *vsi)
2944+
{
2945+
int q_idx;
2946+
2947+
if (!vsi->netdev)
2948+
return;
2949+
2950+
for (q_idx = 0; q_idx < vsi->num_q_vectors; q_idx++)
2951+
napi_enable(&vsi->q_vectors[q_idx]->napi);
2952+
}
2953+
29172954
/**
29182955
* ice_up_complete - Finish the last steps of bringing up a connection
29192956
* @vsi: The VSI being configured
@@ -2939,6 +2976,7 @@ static int ice_up_complete(struct ice_vsi *vsi)
29392976
return err;
29402977

29412978
clear_bit(__ICE_DOWN, vsi->state);
2979+
ice_napi_enable_all(vsi);
29422980
ice_vsi_ena_irq(vsi);
29432981

29442982
if (vsi->port_info &&
@@ -2954,6 +2992,21 @@ static int ice_up_complete(struct ice_vsi *vsi)
29542992
return err;
29552993
}
29562994

2995+
/**
2996+
* ice_napi_disable_all - Disable NAPI for all q_vectors in the VSI
2997+
* @vsi: VSI having NAPI disabled
2998+
*/
2999+
static void ice_napi_disable_all(struct ice_vsi *vsi)
3000+
{
3001+
int q_idx;
3002+
3003+
if (!vsi->netdev)
3004+
return;
3005+
3006+
for (q_idx = 0; q_idx < vsi->num_q_vectors; q_idx++)
3007+
napi_disable(&vsi->q_vectors[q_idx]->napi);
3008+
}
3009+
29573010
/**
29583011
* ice_down - Shutdown the connection
29593012
* @vsi: The VSI being stopped
@@ -2972,6 +3025,7 @@ static int ice_down(struct ice_vsi *vsi)
29723025

29733026
ice_vsi_dis_irq(vsi);
29743027
err = ice_vsi_stop_tx_rx_rings(vsi);
3028+
ice_napi_disable_all(vsi);
29753029

29763030
ice_for_each_txq(vsi, i)
29773031
ice_clean_tx_ring(vsi->tx_rings[i]);
@@ -3251,4 +3305,5 @@ static int ice_stop(struct net_device *netdev)
32513305
static const struct net_device_ops ice_netdev_ops = {
32523306
.ndo_open = ice_open,
32533307
.ndo_stop = ice_stop,
3308+
.ndo_start_xmit = ice_start_xmit,
32543309
};

0 commit comments

Comments
 (0)