Add iecm and idpf
Subsystems (4)
PATCH 14/19 iecm: implement singleq napi_poll
In reply to Alan BradyQuoted 187 lines
From: Alan Brady <[email protected]>
Date: Thu, 27 Jan 2022 16:10:04 -0800This adds everything we do the more traditional singleq model data path.
Signed-off-by Phani Burra <[email protected]>Signed-off-by Joshua Hay <[email protected]>Signed-off-by Madhu Chittim <[email protected]>Signed-off-by Pavan Kumar Linga <[email protected]>Signed-off-by Alan Brady <[email protected]>--- drivers/net/ethernet/intel/iecm/iecm_lib.c | 2 +- .../ethernet/intel/iecm/iecm_singleq_txrx.c | 1208 ++++++++++++++++- drivers/net/ethernet/intel/include/iecm.h | 1 + .../net/ethernet/intel/include/iecm_txrx.h | 31 + 4 files changed, 1237 insertions(+), 5 deletions(-)drivers/net/ethernet/intel/iecm/iecm_lib.c +1
-1@@ -2723,7 +2723,7 @@ static const struct net_device_ops iecm_netdev_ops_splitq = {static const struct net_device_ops iecm_netdev_ops_singleq = { .ndo_open = iecm_open, .ndo_stop = iecm_stop, - .ndo_start_xmit =NULL , + .ndo_start_xmit = iecm_tx_singleq_start, .ndo_set_rx_mode = iecm_set_rx_mode, .ndo_validate_addr = eth_validate_addr, .ndo_set_mac_address = iecm_set_mac,drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +149
-0@@ -3,6 +3,779 @@#include "iecm.h" +/** +* iecm_tx_singleq_csum - Enable tx checksum offloads +* @first: pointer to first descriptor +* @off: pointer to struct that holds offload parameters +* +* Returns 0 or error (negative) if checksum offload +*/ +static +int iecm_tx_singleq_csum (struct iecm_tx_buf *first, +struct iecm_tx_offload_params *off) +{ +u32 l4_len =0 , l3_len =0 , l2_len =0 ; +struct sk_buff *skb = first->skb; +union { +struct iphdr *v4; +struct ipv6hdr *v6; +unsigned char *hdr; + } ip; +union { +struct tcphdr *tcp; +unsigned char *hdr; + } l4; +__be16 frag_off, protocol; +unsigned char *exthdr; +u32 offset, cmd =0 ; +u8 l4_proto =0 ; + +if (skb->ip_summed !=CHECKSUM_PARTIAL ) +return 0 ; + +if (skb->encapsulation) +return -1 ; + + ip.hdr =skb_network_header (skb); + l4.hdr =skb_transport_header (skb); + +/* compute outer L2 header size */ + l2_len = ip.hdr - skb->data; + offset = (l2_len /2 ) <<IECM_TX_DESC_LEN_MACLEN_S ; + +/* Enable IP checksum offloads */ + protocol =vlan_get_protocol (skb); +if (protocol ==htons (ETH_P_IP )) { + l4_proto = ip.v4->protocol; +/* the stack computes the IP header already, the only time we +* need the hardware to recompute it is in the case of TSO. +*/ +if (first->tx_flags &IECM_TX_FLAGS_TSO ) + cmd |=IECM_TX_DESC_CMD_IIPT_IPV4_CSUM ; +else + cmd |=IECM_TX_DESC_CMD_IIPT_IPV4 ; + + }else if (protocol ==htons (ETH_P_IPV6 )) { + cmd |=IECM_TX_DESC_CMD_IIPT_IPV6 ; + exthdr = ip.hdr +sizeof (struct ipv6hdr ); + l4_proto = ip.v6->nexthdr; +if (l4.hdr != exthdr) +ipv6_skip_exthdr (skb, exthdr - skb->data, &l4_proto, + &frag_off); + }else { +return -1 ; + } + +/* compute inner L3 header size */ + l3_len = l4.hdr - ip.hdr; + offset |= (l3_len /4 ) <<IECM_TX_DESC_LEN_IPLEN_S ; + +/* Enable L4 checksum offloads */ +switch (l4_proto) { +case IPPROTO_TCP : +/* enable checksum offloads */ + cmd |=IECM_TX_DESC_CMD_L4T_EOFT_TCP ; + l4_len = l4.tcp->doff; + offset |= l4_len <<IECM_TX_DESC_LEN_L4_LEN_S ; +break ; +case IPPROTO_UDP : +/* enable UDP checksum offload */ + cmd |=IECM_TX_DESC_CMD_L4T_EOFT_UDP ; + l4_len = (sizeof (struct udphdr ) >>2 ); + offset |= l4_len <<IECM_TX_DESC_LEN_L4_LEN_S ; +break ; +case IPPROTO_SCTP : +/* enable SCTP checksum offload */ + cmd |=IECM_TX_DESC_CMD_L4T_EOFT_SCTP ; + l4_len =sizeof (struct sctphdr ) >>2 ; + offset |= l4_len <<IECM_TX_DESC_LEN_L4_LEN_S ; +break ; + +default : +if (first->tx_flags &IECM_TX_FLAGS_TSO ) +return -1 ; +skb_checksum_help (skb); +return 0 ; + } + + off->td_cmd |= cmd; + off->hdr_offsets |= offset; +return 1 ; +} + +/** +* iecm_tx_singleq_map - Build the Tx base descriptor +* @tx_q: queue to send buffer on +* @first: first buffer info buffer to use +* @offloads: pointer to struct that holds offload parameters +* +* This function loops over the skb data pointed to by *first +* and gets a physical address for each memory location and programs +* it and the length into the transmit base mode descriptor. +*/ +static void +iecm_tx_singleq_map (struct iecm_queue *tx_q,struct iecm_tx_buf *first, +struct iecm_tx_offload_params *offloads) +{ +u32 offsets = offloads->hdr_offsets; +struct iecm_base_tx_desc *tx_desc; +u64 td_cmd = offloads->td_cmd; +unsigned int data_len, size; +struct iecm_tx_buf *tx_buf; +u16 i = tx_q->next_to_use; +struct netdev_queue *nq; +struct sk_buff *skb; +skb_frag_t *frag; +dma_addr_t dma; +u64 td_tag =0 ; + + skb = first->skb; + + data_len = skb->data_len; + size =skb_headlen (skb); + + tx_desc =IECM_BASE_TX_DESC (tx_q, i); + +if (first->tx_flags &IECM_TX_FLAGS_VLAN_TAG ) { + td_cmd |= (u64 )IECM_TX_DESC_CMD_IL2TAG1 ; + td_tag = (first->tx_flags &IECM_TX_FLAGS_VLAN_MASK ) >> +IECM_TX_FLAGS_VLAN_SHIFT ; + } + + dma =dma_map_single (tx_q->dev, skb->data, size,DMA_TO_DEVICE ); + + tx_buf = first; + +/* write each descriptor with CRC bit */ +if (tx_q->vport->adapter->dev_ops.crc_enable) + tx_q->vport->adapter->dev_ops.crc_enable (&td_cmd); + +for (frag = &skb_shinfo (skb)->frags[0 ];; frag++) { +unsigned int max_data =IECM_TX_MAX_DESC_DATA_ALIGNED ;
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c line 164
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +10
-0+ +if (dma_mapping_error (tx_q->dev, dma)) + goto dma_error; + +/* record length, and DMA address */ +dma_unmap_len_set (tx_buf, len, size); +dma_unmap_addr_set (tx_buf, dma, dma); + +/* align size to end of page */ + max_data += -dma & (IECM_TX_MAX_READ_REQ_SIZE -1 );
Here applies the same I said for splitq before, this code is counter-intuitive.
Quoted 203 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +203
-0+ tx_desc->buf_addr =cpu_to_le64 (dma); + +/* account for data chunks larger than the hardware +* can handle +*/ +while (unlikely (size >IECM_TX_MAX_DESC_DATA )) { + tx_desc->qw1 =iecm_tx_singleq_build_ctob (td_cmd, + offsets, + max_data, + td_tag); + tx_desc++; + i++; + +if (i == tx_q->desc_count) { + tx_desc =IECM_BASE_TX_DESC (tx_q,0 ); + i =0 ; + } + + dma += max_data; + size -= max_data; + + max_data =IECM_TX_MAX_DESC_DATA_ALIGNED ; + tx_desc->buf_addr =cpu_to_le64 (dma); + } + +if (likely (!data_len)) +break ; + tx_desc->qw1 =iecm_tx_singleq_build_ctob (td_cmd, offsets, + size, td_tag); + tx_desc++; + i++; + +if (i == tx_q->desc_count) { + tx_desc =IECM_BASE_TX_DESC (tx_q,0 ); + i =0 ; + } + + size =skb_frag_size (frag); + data_len -= size; + + dma =skb_frag_dma_map (tx_q->dev, frag,0 , size, +DMA_TO_DEVICE ); + + tx_buf = &tx_q->tx_buf[i]; + } + +/* record bytecount for BQL */ + nq =netdev_get_tx_queue (tx_q->vport->netdev, tx_q->idx); +netdev_tx_sent_queue (nq, first->bytecount); + +/* record SW timestamp if HW timestamp is not available */ +skb_tx_timestamp (first->skb); + +/* write last descriptor with RS and EOP bits */ + td_cmd |= (u64)(IECM_TX_DESC_CMD_EOP |IECM_TX_DESC_CMD_RS ); + + tx_desc->qw1 =iecm_tx_singleq_build_ctob (td_cmd, offsets, size, td_tag); + + i++; +if (i == tx_q->desc_count) + i =0 ; + +/* set next_to_watch value indicating a packet is present */ + first->next_to_watch = tx_desc; + +iecm_tx_buf_hw_update (tx_q, i,netdev_xmit_more ()); + +return ; + +dma_error: +/* clear dma mappings for failed tx_buf map */ +for (;;) { + tx_buf = &tx_q->tx_buf[i]; +iecm_tx_buf_rel (tx_q, tx_buf); +if (tx_buf == first) +break ; +if (i ==0 ) + i = tx_q->desc_count; + i--; + } + + tx_q->next_to_use = i; +} + +/** +* iecm_tx_singleq_frame - Sends buffer on Tx ring using base descriptors +* @skb: send buffer +* @tx_q: queue to send buffer on +* +* Returns NETDEV_TX_OK if sent, else an error code +*/ +static netdev_tx_t +iecm_tx_singleq_frame (struct sk_buff *skb,struct iecm_queue *tx_q) +{ +struct iecm_tx_offload_params offload = {0 }; +struct iecm_tx_buf *first; +unsigned int count; +int csum, tso; + + count =iecm_tx_desc_count_required (skb); + +if (iecm_chk_linearize (skb, tx_q->tx_max_bufs, count)) { +if (__skb_linearize (skb)) { +dev_kfree_skb_any (skb); +return NETDEV_TX_OK ; + } + count =iecm_size_to_txd_count (skb->len); + tx_q->vport->port_stats.tx_linearize++; + } + +if (iecm_tx_maybe_stop (tx_q, count +IECM_TX_DESCS_PER_CACHE_LINE + +IECM_TX_DESCS_FOR_CTX )) { +return NETDEV_TX_BUSY ; + } + +/* record the location of the first descriptor for this packet */ + first = &tx_q->tx_buf[tx_q->next_to_use]; + first->skb = skb; + first->bytecount = max_t(unsigned int, skb->len, ETH_ZLEN); + first->gso_segs =1 ; + first->tx_flags =0 ; + +iecm_tx_prepare_vlan_flags (tx_q, first, skb); + + tso =iecm_tso (first, &offload); +if (tso <0 ) + goto out_drop; + + csum =iecm_tx_singleq_csum (first, &offload); +if (csum <0 ) + goto out_drop; + +if (first->tx_flags &IECM_TX_FLAGS_TSO ) { +struct iecm_base_tx_ctx_desc *ctx_desc; +int i = tx_q->next_to_use; +u64 qw1 = (u64 )IECM_TX_DESC_DTYPE_CTX | +IECM_TX_CTX_DESC_TSO <<IECM_TXD_CTX_QW1_CMD_S ; + +/* grab the next descriptor */ + ctx_desc =IECM_BASE_TX_CTX_DESC (tx_q, i); + i++; + tx_q->next_to_use = (i < tx_q->desc_count) ? i :0 ; + + qw1 |= ((u64 )offload.tso_len <<IECM_TXD_CTX_QW1_TSO_LEN_S ) & +IECM_TXD_CTX_QW1_TSO_LEN_M ; + + qw1 |= ((u64 )offload.mss <<IECM_TXD_CTX_QW1_MSS_S ) & +IECM_TXD_CTX_QW1_MSS_M ; + + ctx_desc->qw0.rsvd0 =cpu_to_le32 (0 ); + ctx_desc->qw0.l2tag2 =cpu_to_le16 (0 ); + ctx_desc->qw0.rsvd1 =cpu_to_le16 (0 ); + ctx_desc->qw1 =cpu_to_le64 (qw1); + } + +iecm_tx_singleq_map (tx_q, first, &offload); + +return NETDEV_TX_OK ; + +out_drop: +dev_kfree_skb_any (skb); +return NETDEV_TX_OK ; +} + +/** +* iecm_tx_singleq_start - Selects the right Tx queue to send buffer +* @skb: send buffer +* @netdev: network interface device structure +* +* Returns NETDEV_TX_OK if sent, else an error code +*/ +netdev_tx_t iecm_tx_singleq_start (struct sk_buff *skb, +struct net_device *netdev) +{ +struct iecm_vport *vport =iecm_netdev_to_vport (netdev); +struct iecm_queue *tx_q; + +if (test_bit (__IECM_HR_RESET_IN_PROG, vport->adapter->flags)) +return NETDEV_TX_BUSY ; + + tx_q = vport->txqs[skb->queue_mapping]; + +/* hardware can't handle really short frames, hardware padding works +* beyond this point +*/ +if (skb_put_padto (skb,IECM_TX_MIN_LEN )) +return NETDEV_TX_OK ; + +return iecm_tx_singleq_frame (skb, tx_q); +} + +/** +* iecm_tx_singleq_clean - Reclaim resources from queue +* @tx_q: Tx queue to clean +* @napi_budget: Used to determine if we are in netpoll +* +*/ +static bool iecm_tx_singleq_clean (struct iecm_queue *tx_q,int napi_budget) +{ +unsigned int budget = tx_q->vport->compln_clean_budget; +unsigned int total_bytes =0 , total_pkts =0 ; +struct iecm_base_tx_desc *tx_desc; +s16 ntc = tx_q->next_to_clean;
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c line 377
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +10
-0+struct iecm_tx_buf *tx_buf; +struct netdev_queue *nq; + + tx_desc =IECM_BASE_TX_DESC (tx_q, ntc); + tx_buf = &tx_q->tx_buf[ntc]; + ntc -= tx_q->desc_count; + + do { + struct iecm_base_tx_desc *eop_desc = + (struct iecm_base_tx_desc *)tx_buf->next_to_watch;
struct iecm_base_tx_desc *eop_desc; eop_desc = (typeof(*eop_desc))tx_buf->next_to_watch;
Quoted 36 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +36
-0+ +/* if next_to_watch is not set then no work pending */ +if (!eop_desc) +break ; + +/* prevent any other reads prior to eop_desc */ +smp_rmb (); + +/* if the descriptor isn't done, no work yet to do */ +if (!(eop_desc->qw1 & +cpu_to_le64 (IECM_TX_DESC_DTYPE_DESC_DONE ))) +break ; + +/* clear next_to_watch to prevent false hangs */ + tx_buf->next_to_watch =NULL ; + +/* update the statistics for this packet */ + total_bytes += tx_buf->bytecount; + total_pkts += tx_buf->gso_segs; + +/* free the skb */ +napi_consume_skb (tx_buf->skb, napi_budget); + +/* unmap skb header data */ +dma_unmap_single (tx_q->dev, +dma_unmap_addr (tx_buf, dma), +dma_unmap_len (tx_buf, len), +DMA_TO_DEVICE ); + +/* clear tx_buf data */ + tx_buf->skb =NULL ; +dma_unmap_len_set (tx_buf, len,0 ); + +/* unmap remaining buffers */ +while (tx_desc != eop_desc) { + tx_buf++;
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c line 423
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +10
-0+ tx_desc++; + ntc++; +if (unlikely (!ntc)) { + ntc -= tx_q->desc_count; + tx_buf = tx_q->tx_buf; + tx_desc =IECM_BASE_TX_DESC (tx_q,0 ); + } + +/* unmap any remaining paged data */ +if (dma_unmap_len (tx_buf, len)) {
Here applies the same I said for splitq about dma_unmap_len().
Quoted 51 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +51
-0+dma_unmap_page (tx_q->dev, +dma_unmap_addr (tx_buf, dma), +dma_unmap_len (tx_buf, len), +DMA_TO_DEVICE ); +dma_unmap_len_set (tx_buf, len,0 ); + } + } + + tx_buf++; + tx_desc++; + ntc++; +if (unlikely (!ntc)) { + ntc -= tx_q->desc_count; + tx_buf = tx_q->tx_buf; + tx_desc =IECM_BASE_TX_DESC (tx_q,0 ); + } +/* update budget */ + budget--; + }while (likely (budget)); + + ntc += tx_q->desc_count; + tx_q->next_to_clean = ntc; + +u64_stats_update_begin (&tx_q->stats_sync); + tx_q->q_stats.tx.packets += total_pkts; + tx_q->q_stats.tx.bytes += total_bytes; +u64_stats_update_end (&tx_q->stats_sync); + + nq =netdev_get_tx_queue (tx_q->vport->netdev, tx_q->idx); +netdev_tx_completed_queue (nq, total_pkts, total_bytes); + +if (unlikely (total_pkts &&netif_carrier_ok (tx_q->vport->netdev) && + (IECM_DESC_UNUSED (tx_q) >=IECM_TX_WAKE_THRESH ))) { +/* Make sure any other threads stopping queue after this see +* new next_to_clean. +*/ +smp_mb (); +if (__netif_subqueue_stopped (tx_q->vport->netdev, tx_q->idx) && + tx_q->vport->adapter->state == __IECM_UP) +netif_wake_subqueue (tx_q->vport->netdev, tx_q->idx); + } + +return !!budget; +} + +/** +* iecm_tx_singleq_clean_all - Clean all Tx queues +* @q_vec: queue vector +* @budget: Used to determine if we are in netpoll +* +* Returns false if clean is not complete else returns true
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c line 484
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +10
-0+*/ +static bool +iecm_tx_singleq_clean_all (struct iecm_q_vector *q_vec,int budget) +{ +bool clean_complete = true; +int i, budget_per_q; + + budget_per_q =max (budget / q_vec->num_txq,1 ); +for (i =0 ; i < q_vec->num_txq; i++) + clean_complete =iecm_tx_singleq_clean (q_vec->tx[i], budget_per_q);
84 cols per line.
Quoted 25 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +25
-0+ +return clean_complete; +} + +/** +* iecm_rx_singleq_test_staterr - tests bits in Rx descriptor +* status and error fields +* @rx_desc: pointer to receive descriptor (in le64 format) +* @stat_err_bits: value to mask +* +* This function does some fast chicanery in order to return the +* value of the mask which is really only used for boolean tests. +* The status_error_ptype_len doesn't need to be shifted because it begins +* at offset zero. +*/ +bool +iecm_rx_singleq_test_staterr (union virtchnl2_rx_desc *rx_desc, +const u64 stat_err_bits) +{ +return !!(rx_desc->base_wb.qword1.status_error_ptype_len & +cpu_to_le64 (stat_err_bits)); +} + +/** +* iecm_rx_singleq_is_non_eop - process handling of non-EOP buffers
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c line 519
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +10
-0+* @rxq: Rx ring being processed +* @rx_desc: Rx descriptor for current buffer +* @skb: Current socket buffer containing buffer in progress +*/ +bool iecm_rx_singleq_is_non_eop (struct iecm_queue *rxq, +union virtchnl2_rx_desc *rx_desc, +struct sk_buff *skb) +{ +/* if we are the last buffer then there is nothing else to do */ +#define IECM_RXD_EOF BIT(VIRTCHNL2_RX_BASE_DESC_STATUS_EOF_S)
Not a good place for a definition, makes reading difficult.
Quoted 175 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +175
-0+if (likely (iecm_rx_singleq_test_staterr (rx_desc,IECM_RXD_EOF ))) +return false; + +/* place skb in next buffer to be received */ + rxq->rx_buf.buf[rxq->next_to_clean].skb = skb; + +return true; +} + +/** +* iecm_rx_singleq_csum - Indicate in skb if checksum is good +* @rxq: Rx descriptor ring packet is being transacted on +* @skb: skb currently being received and modified +* @csum_bits: descriptor csum bits +* @ptype: the packet type decoded by hardware +* +* skb->protocol must be set before this function is called +*/ +static void iecm_rx_singleq_csum (struct iecm_queue *rxq,struct sk_buff *skb, +struct iecm_rx_csum_decoded *csum_bits, +u16 ptype) +{ +struct iecm_rx_ptype_decoded decoded; +bool ipv4, ipv6; + +/* Start with CHECKSUM_NONE and by default csum_level = 0 */ + skb->ip_summed =CHECKSUM_NONE ; +skb_checksum_none_assert (skb); + +/* check if Rx checksum is enabled */ +if (!(rxq->vport->netdev->features &NETIF_F_RXCSUM )) +return ; + +/* check if HW has decoded the packet and checksum */ +if (!(csum_bits->l3l4p)) +return ; + + decoded = rxq->vport->rx_ptype_lkup[ptype]; +if (!(decoded.known && decoded.outer_ip)) +return ; + + ipv4 = (decoded.outer_ip ==IECM_RX_PTYPE_OUTER_IP ) && + (decoded.outer_ip_ver ==IECM_RX_PTYPE_OUTER_IPV4 ); + ipv6 = (decoded.outer_ip ==IECM_RX_PTYPE_OUTER_IP ) && + (decoded.outer_ip_ver ==IECM_RX_PTYPE_OUTER_IPV6 ); + +if (ipv4 && (csum_bits->ipe || csum_bits->eipe)) + goto checksum_fail; +else if (ipv6 && (csum_bits->ipv6exadd)) + goto checksum_fail; + +/* check for L4 errors and handle packets that were not able to be +* checksummed due to arrival speed +*/ +if (csum_bits->l4e) + goto checksum_fail; + +if (csum_bits->nat && csum_bits->eudpe) + goto checksum_fail; + +/* Handle packets that were not able to be checksummed due to arrival +* speed, in this case the stack can compute the csum. +*/ +if (csum_bits->pprs) +return ; + +/* If there is an outer header present that might contain a checksum +* we need to bump the checksum level by 1 to reflect the fact that +* we are indicating we validated the inner checksum. +*/ +if (decoded.tunnel_type >=IECM_RX_PTYPE_TUNNEL_IP_GRENAT ) + skb->csum_level =1 ; + +/* Only report checksum unnecessary for ICMP, TCP, UDP, or SCTP */ +switch (decoded.inner_prot) { +case IECM_RX_PTYPE_INNER_PROT_ICMP : +case IECM_RX_PTYPE_INNER_PROT_TCP : +case IECM_RX_PTYPE_INNER_PROT_UDP : +case IECM_RX_PTYPE_INNER_PROT_SCTP : + skb->ip_summed =CHECKSUM_UNNECESSARY ; +default : +break ; + } +return ; + +checksum_fail: + rxq->vport->port_stats.rx_hw_csum_err++; +} + +/** +* iecm_rx_singleq_base_csum - Indicate in skb if hw indicated a good cksum +* @rx_q: Rx completion queue +* @skb: skb currently being received and modified +* @rx_desc: the receive descriptor +* @ptype: Rx packet type +* +* This function only operates on the VIRTCHNL2_RXDID_1_32B_BASE_M legacy 32byte +* descriptor writeback format. +**/ +static void +iecm_rx_singleq_base_csum (struct iecm_queue *rx_q,struct sk_buff *skb, +union virtchnl2_rx_desc *rx_desc,u16 ptype) +{ +struct iecm_rx_csum_decoded csum_bits; +u32 rx_error, rx_status; +u64 qword; + + qword =le64_to_cpu (rx_desc->base_wb.qword1.status_error_ptype_len); + + rx_status = ((qword &VIRTCHNL2_RX_BASE_DESC_QW1_STATUS_M ) >> +VIRTCHNL2_RX_BASE_DESC_QW1_STATUS_S ); + rx_error = ((qword &VIRTCHNL2_RX_BASE_DESC_QW1_ERROR_M ) >> +VIRTCHNL2_RX_BASE_DESC_QW1_ERROR_S ); + + csum_bits.ipe = !!(rx_error &BIT (VIRTCHNL2_RX_BASE_DESC_ERROR_IPE_S )); + csum_bits.eipe = !!(rx_error &BIT (VIRTCHNL2_RX_BASE_DESC_ERROR_EIPE_S )); + csum_bits.l4e = !!(rx_error &BIT (VIRTCHNL2_RX_BASE_DESC_ERROR_L4E_S )); + csum_bits.pprs = !!(rx_error &BIT (VIRTCHNL2_RX_BASE_DESC_ERROR_PPRS_S )); + csum_bits.l3l4p = !!(rx_status & +BIT (VIRTCHNL2_RX_BASE_DESC_STATUS_L3L4P_S )); + csum_bits.ipv6exadd = !!(rx_status & +BIT (VIRTCHNL2_RX_BASE_DESC_STATUS_IPV6EXADD_S )); + csum_bits.nat =0 ; + csum_bits.eudpe =0 ; + +iecm_rx_singleq_csum (rx_q, skb, &csum_bits, ptype); +} + +/** +* iecm_rx_singleq_flex_csum - Indicate in skb if hw indicated a good cksum +* @rx_q: Rx completion queue +* @skb: skb currently being received and modified +* @rx_desc: the receive descriptor +* @ptype: Rx packet type +* +* This function only operates on the VIRTCHNL2_RXDID_2_FLEX_SQ_NIC flexible +* descriptor writeback format. +**/ +static void +iecm_rx_singleq_flex_csum (struct iecm_queue *rx_q,struct sk_buff *skb, +union virtchnl2_rx_desc *rx_desc,u16 ptype) +{ +struct iecm_rx_csum_decoded csum_bits; +u16 rx_status0, rx_status1; + + rx_status0 =le16_to_cpu (rx_desc->flex_nic_wb.status_error0); + rx_status1 =le16_to_cpu (rx_desc->flex_nic_wb.status_error1); + + csum_bits.ipe = !!(rx_status0 & +BIT (VIRTCHNL2_RX_FLEX_DESC_STATUS0_XSUM_IPE_S )); + csum_bits.eipe = !!(rx_status0 & +BIT (VIRTCHNL2_RX_FLEX_DESC_STATUS0_XSUM_EIPE_S )); + csum_bits.l4e = !!(rx_status0 & +BIT (VIRTCHNL2_RX_FLEX_DESC_STATUS0_XSUM_L4E_S )); + csum_bits.eudpe = !!(rx_status0 & +BIT (VIRTCHNL2_RX_FLEX_DESC_STATUS0_XSUM_EUDPE_S )); + csum_bits.l3l4p = !!(rx_status0 & +BIT (VIRTCHNL2_RX_FLEX_DESC_STATUS0_L3L4P_S )); + csum_bits.ipv6exadd = + !!(rx_status0 & +BIT (VIRTCHNL2_RX_FLEX_DESC_STATUS0_IPV6EXADD_S )); + csum_bits.nat = !!(rx_status1 & +BIT (VIRTCHNL2_RX_FLEX_DESC_STATUS1_NAT_S )); + csum_bits.pprs =0 ; + +iecm_rx_singleq_csum (rx_q, skb, &csum_bits, ptype); +} + +/** +* iecm_rx_singleq_base_hash - set the hash value in the skb +* @rx_q: Rx completion queue +* @skb: skb currently being received and modified +* @rx_desc: specific descriptor +* @decoded: Decoded Rx packet type related fields +*
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c line 704
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +10
-0+* This function only operates on the VIRTCHNL2_RXDID_1_32B_BASE_M legacy 32byte +* descriptor writeback format. +**/ +static void +iecm_rx_singleq_base_hash (struct iecm_queue *rx_q,struct sk_buff *skb, +union virtchnl2_rx_desc *rx_desc, +struct iecm_rx_ptype_decoded *decoded) +{ +const __le64 rss_mask = + cpu_to_le64((u64)VIRTCHNL2_RX_BASE_DESC_FLTSTAT_RSS_HASH <<
You can define _RSS_HASH with a 'ull' suffix to avoid casting. You can define a shorthand for this, like _RSS_HASH_LE to avoid these wraps.
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c line 712
Quoted 8 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +8
-0+ VIRTCHNL2_RX_BASE_DESC_STATUS_FLTSTAT_S); +u32 hash; + +if (!(rx_q->vport->netdev->features &NETIF_F_RXHASH )) +return ; + +if ((rx_desc->base_wb.qword1.status_error_ptype_len & rss_mask) == + rss_mask) {
This is wrong indentation, just align it to the first opening brace.
Quoted 22 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +22
-0+ hash =le32_to_cpu (rx_desc->base_wb.qword0.hi_dword.rss); +skb_set_hash (skb, hash,iecm_ptype_to_htype (decoded)); + } +} + +/** +* iecm_rx_singleq_flex_hash - set the hash value in the skb +* @rx_q: Rx completion queue +* @skb: skb currently being received and modified +* @rx_desc: specific descriptor +* @decoded: Decoded Rx packet type related fields +* +* This function only operates on the VIRTCHNL2_RXDID_2_FLEX_SQ_NIC flexible +* descriptor writeback format. +**/ +static void +iecm_rx_singleq_flex_hash (struct iecm_queue *rx_q,struct sk_buff *skb, +union virtchnl2_rx_desc *rx_desc, +struct iecm_rx_ptype_decoded *decoded) +{ +__le16 status0; +
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c line 744
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +10
-0+if (!(rx_q->vport->netdev->features &NETIF_F_RXHASH )) +return ; + + status0 = rx_desc->flex_nic_wb.status_error0; +if (status0 & +cpu_to_le16 (BIT (VIRTCHNL2_RX_FLEX_DESC_STATUS0_RSS_VALID_S ))) { +u32 hash =le32_to_cpu (rx_desc->flex_nic_wb.rss_hash); + +skb_set_hash (skb, hash,iecm_ptype_to_htype (decoded)); + }
if (!status) return;
-1 indent level.
Quoted 11 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +11
-0+} + +/** +* iecm_rx_singleq_process_skb_fields - Populate skb header fields from Rx +* descriptor +* @rx_q: Rx descriptor ring packet is being transacted on +* @skb: pointer to current skb being populated +* @rx_desc: descriptor for skb +* @ptype: packet type +* +* This function checks the ring, descriptor, and packet information in
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c line 765
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +10
-0+* order to populate the hash, checksum, VLAN, protocol, and +* other fields within the skb. +*/ +void +iecm_rx_singleq_process_skb_fields (struct iecm_queue *rx_q,struct sk_buff *skb, +union virtchnl2_rx_desc *rx_desc, +u16 ptype) +{ +struct iecm_rx_ptype_decoded decoded = + rx_q->vport->rx_ptype_lkup[ptype];
Declare, then assign to avoid wraps.
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c line 768
Quoted 3 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +3
-0+ +/* modifies the skb - consumes the enet header */ + skb->protocol =eth_type_trans (skb, rx_q->vport->netdev);
Here applies the same I said for splitq, eth_type_trans() should be right before napi_gro_receive().
Quoted 27 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +18
-2+ +if (rx_q->rxdids ==VIRTCHNL2_RXDID_1_32B_BASE_M ) { +iecm_rx_singleq_base_hash (rx_q, skb, rx_desc, &decoded); +iecm_rx_singleq_base_csum (rx_q, skb, rx_desc, ptype); + }else { +iecm_rx_singleq_flex_hash (rx_q, skb, rx_desc, &decoded); +iecm_rx_singleq_flex_csum (rx_q, skb, rx_desc, ptype); + } +} +/** * iecm_rx_singleq_buf_hw_alloc_all - Replace used receive buffers * @rx_q: queue for which the hw buffers are allocated @@ -13,8 +786,410 @@bool iecm_rx_singleq_buf_hw_alloc_all (struct iecm_queue *rx_q,u16 cleaned_count) { -/* stub */ -return true; +struct virtchnl2_singleq_rx_buf_desc *singleq_rx_desc =NULL ; +struct iecm_page_info *page_info; +u16 nta = rx_q->next_to_alloc; +struct iecm_rx_buf *buf; + +/* do nothing if no valid netdev defined */ +if (!rx_q->vport->netdev || !cleaned_count) +return false;
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c line 806
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +10
-0+ + singleq_rx_desc =IECM_SINGLEQ_RX_BUF_DESC (rx_q, nta); + buf = &rx_q->rx_buf.buf[nta]; + page_info = &buf->page_info[buf->page_indx]; + + do { + if (unlikely(!page_info->page)) { + if (!iecm_init_rx_buf_hw_alloc(rx_q, buf)) + break; + }
if (1 && 2)
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c line 818
Quoted 12 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +12
-0+ +/* Refresh the desc even if buffer_addrs didn't change +* because each write-back erases this info. +*/ + singleq_rx_desc->pkt_addr = +cpu_to_le64 (page_info->dma + page_info->page_offset); + singleq_rx_desc->hdr_addr =0 ; + singleq_rx_desc++; + + buf++; + nta++; +if (unlikely (nta == rx_q->desc_count)) {
Can be squashed into ++nta == count.
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c line 827
Quoted 9 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +9
-0+ singleq_rx_desc =IECM_SINGLEQ_RX_BUF_DESC (rx_q,0 ); + buf = rx_q->rx_buf.buf; + nta =0 ; + } + + page_info = &buf->page_info[buf->page_indx]; + + cleaned_count--; + }while (cleaned_count);
And these into while (--cleaned_count);
Quoted 9 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +9
-0+ +if (rx_q->next_to_alloc != nta) { +iecm_rx_buf_hw_update (rx_q, nta); + rx_q->next_to_alloc = nta; + } + +return !!cleaned_count; +} +
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c line 846
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +10
-0+/** +* iecm_rx_reuse_page - Put recycled buffer back onto ring +* @rxq: Rx descriptor ring to store buffers on +* @old_buf: donor buffer to have page reused +*/ +static void iecm_rx_reuse_page (struct iecm_queue *rxq, +struct iecm_rx_buf *old_buf) +{ +u16 ntu = rxq->next_to_use; +struct iecm_rx_buf *new_buf;
RCTree.
Quoted 22 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +22
-0+ + new_buf = &rxq->rx_buf.buf[ntu]; + +/* Transfer page from old buffer to new buffer. Move each member +* individually to avoid possible store forwarding stalls and +* unnecessary copy of skb. +*/ + new_buf->page_info[new_buf->page_indx].dma = + old_buf->page_info[old_buf->page_indx].dma; + new_buf->page_info[new_buf->page_indx].page = + old_buf->page_info[old_buf->page_indx].page; + new_buf->page_info[new_buf->page_indx].page_offset = + old_buf->page_info[old_buf->page_indx].page_offset; + new_buf->page_info[new_buf->page_indx].pagecnt_bias = + old_buf->page_info[old_buf->page_indx].pagecnt_bias; +} + +/** +* iecm_rx_singleq_recycle_buf - Clean up used buffer and either recycle or free +* @rxq: Rx descriptor queue to transact packets on +* @rx_buf: Rx buffer to pull data from +*
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c line 878
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +10
-0+* This function will clean up the contents of the rx_buf. It will either +* recycle the buffer or unmap it and free the associated resources. +* +* Returns true if the buffer is reused, false if the buffer is freed. +*/ +static bool iecm_rx_singleq_recycle_buf (struct iecm_queue *rxq, +struct iecm_rx_buf *rx_buf) +{ +struct iecm_page_info *page_info = + &rx_buf->page_info[rx_buf->page_indx];
Declare, then assign to avoid wraps.
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c line 879
Quoted 1 line
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +1
-0+
No empty lines between declarations.
Quoted 202 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +202
-0+bool recycled = false; + +if (iecm_rx_can_reuse_page (rx_buf)) { +/* hand second half of page back to the queue */ +iecm_rx_reuse_page (rxq, rx_buf); + recycled = true; + }else { +/* we are not reusing the buffer so unmap it */ +dma_unmap_page_attrs (rxq->dev, page_info->dma,PAGE_SIZE , +DMA_FROM_DEVICE ,IECM_RX_DMA_ATTR ); +__page_frag_cache_drain (page_info->page, + page_info->pagecnt_bias); + } + +/* clear contents of buffer_info */ + page_info->page =NULL ; + rx_buf->skb =NULL ; + +return recycled; +} + +/** +* iecm_rx_singleq_put_buf - Wrapper function to clean and recycle buffers +* @rxq: Rx descriptor queue to transact packets on +* @rx_buf: Rx buffer to pull data from +* +* This function will update the next_to_use/next_to_alloc if the current +* buffer is recycled. +*/ +static void iecm_rx_singleq_put_buf (struct iecm_queue *rxq, +struct iecm_rx_buf *rx_buf) +{ +u16 ntu = rxq->next_to_use; +bool recycled = false; + + recycled =iecm_rx_singleq_recycle_buf (rxq, rx_buf); + +/* update, and store next to alloc if the buffer was recycled */ +if (recycled) { + ntu++; + rxq->next_to_use = (ntu < rxq->desc_count) ? ntu :0 ; + } +} + +/** +* iecm_rx_singleq_bump_ntc - Bump and wrap q->next_to_clean value +* @rxq: queue to bump +*/ +void iecm_rx_singleq_bump_ntc (struct iecm_queue *rxq) +{ +u16 ntc = rxq->next_to_clean +1 ; +/* fetch, update, and store next to clean */ +if (ntc < rxq->desc_count) + rxq->next_to_clean = ntc; +else + rxq->next_to_clean =0 ; +} + +/** +* iecm_rx_singleq_get_buf_page - Fetch Rx buffer page and synchronize data +* @dev: device struct +* @rx_buf: Rx buf to fetch page for +* @size: size of buffer to add to skb +* +* This function will pull an Rx buffer page from the ring and synchronize it +* for use by the CPU. +*/ +static struct sk_buff * +iecm_rx_singleq_get_buf_page (struct device *dev,struct iecm_rx_buf *rx_buf, +const unsigned int size) +{ +struct iecm_page_info *page_info; + + page_info = &rx_buf->page_info[rx_buf->page_indx]; +prefetch (page_info->page); + +/* we are reusing so sync this buffer for CPU use */ +dma_sync_single_range_for_cpu (dev, page_info->dma, + page_info->page_offset, size, +DMA_FROM_DEVICE ); + +/* We have pulled a buffer for use, so decrement pagecnt_bias */ + page_info->pagecnt_bias--; + +return rx_buf->skb; +} + +/** +* iecm_rx_singleq_extract_base_fields - Extract fields from the Rx descriptor +* @rx_q: Rx descriptor queue +* @rx_desc: the descriptor to process +* @fields: storage for extracted values +* +* Decode the Rx descriptor and extract relevant information including the +* size, VLAN tag, and Rx packet type. +* +* This function only operates on the VIRTCHNL2_RXDID_1_32B_BASE_M legacy 32byte +* descriptor writeback format. +*/ +static inline void +iecm_rx_singleq_extract_base_fields (struct iecm_queue *rx_q, +union virtchnl2_rx_desc *rx_desc, +struct iecm_rx_extracted *fields) +{ +u64 qw2_status, qword; + + qword =le64_to_cpu (rx_desc->base_wb.qword1.status_error_ptype_len); + qw2_status =le16_to_cpu (rx_desc->base_wb.qword2.ext_status); + + fields->size = (qword &VIRTCHNL2_RX_BASE_DESC_QW1_LEN_PBUF_M ) >> +VIRTCHNL2_RX_BASE_DESC_QW1_LEN_PBUF_S ; + fields->rx_ptype = (qword &VIRTCHNL2_RX_BASE_DESC_QW1_PTYPE_M ) >> +VIRTCHNL2_RX_BASE_DESC_QW1_PTYPE_S ; + +if (qword &BIT (VIRTCHNL2_RX_BASE_DESC_STATUS_L2TAG1P_S ) && +test_bit (__IECM_Q_VLAN_TAG_LOC_L2TAG1, rx_q->flags)) + fields->vlan_tag = +le16_to_cpu (rx_desc->base_wb.qword0.lo_dword.l2tag1); +if (qw2_status &BIT (VIRTCHNL2_RX_BASE_DESC_EXT_STATUS_L2TAG2P_S ) && +test_bit (__IECM_Q_VLAN_TAG_LOC_L2TAG2, rx_q->flags)) + fields->vlan_tag = +le16_to_cpu (rx_desc->base_wb.qword2.l2tag2_1); +} + +/** +* iecm_rx_singleq_extract_flex_fields - Extract fields from the Rx descriptor +* @rx_q: Rx descriptor queue +* @rx_desc: the descriptor to process +* @fields: storage for extracted values +* +* Decode the Rx descriptor and extract relevant information including the +* size, VLAN tag, and Rx packet type. +* +* This function only operates on the VIRTCHNL2_RXDID_2_FLEX_SQ_NIC flexible +* descriptor writeback format. +*/ +static inline void +iecm_rx_singleq_extract_flex_fields (struct iecm_queue *rx_q, +union virtchnl2_rx_desc *rx_desc, +struct iecm_rx_extracted *fields) +{ +__le16 status0, status1; + + fields->size =le16_to_cpu (rx_desc->flex_nic_wb.pkt_len) & +VIRTCHNL2_RX_FLEX_DESC_PKT_LEN_M ; + fields->rx_ptype =le16_to_cpu (rx_desc->flex_nic_wb.ptype_flex_flags0) & +VIRTCHNL2_RX_FLEX_DESC_PTYPE_M ; + + status0 = rx_desc->flex_nic_wb.status_error0; +if (status0 &cpu_to_le16 (BIT (VIRTCHNL2_RX_FLEX_DESC_STATUS0_L2TAG1P_S )) && +test_bit (__IECM_Q_VLAN_TAG_LOC_L2TAG1, rx_q->flags)) + fields->vlan_tag =le16_to_cpu (rx_desc->flex_nic_wb.l2tag1); + + status1 = rx_desc->flex_nic_wb.status_error1; +if (status1 &cpu_to_le16 (BIT (VIRTCHNL2_RX_FLEX_DESC_STATUS1_L2TAG2P_S )) && +test_bit (__IECM_Q_VLAN_TAG_LOC_L2TAG2, rx_q->flags)) + fields->vlan_tag =le16_to_cpu (rx_desc->flex_nic_wb.l2tag2_2nd); +} + +/** +* iecm_rx_singleq_extract_fields - Extract fields from the Rx descriptor +* @rx_q: Rx descriptor queue +* @rx_desc: the descriptor to process +* @fields: storage for extracted values +* +*/ +void +iecm_rx_singleq_extract_fields (struct iecm_queue *rx_q, +union virtchnl2_rx_desc *rx_desc, +struct iecm_rx_extracted *fields) +{ +if (rx_q->rxdids ==VIRTCHNL2_RXDID_1_32B_BASE_M ) +iecm_rx_singleq_extract_base_fields (rx_q, rx_desc, fields); +else +iecm_rx_singleq_extract_flex_fields (rx_q, rx_desc, fields); +} + +/** +* iecm_rx_singleq_clean - Reclaim resources after receive completes +* @rx_q: rx queue to clean +* @budget: Total limit on number of packets to process +* +* Returns true if there's any budget left (e.g. the clean is finished) +*/ +static int iecm_rx_singleq_clean (struct iecm_queue *rx_q,int budget) +{ +unsigned int total_rx_bytes =0 , total_rx_pkts =0 ; +u16 cleaned_count =0 ; +bool failure = false; + +/* Process Rx packets bounded by budget */ +while (likely (total_rx_pkts < (unsigned int )budget)) { +struct iecm_rx_extracted fields = {}; +union virtchnl2_rx_desc *rx_desc; +struct sk_buff *skb =NULL ; +struct iecm_rx_buf *rx_buf; + +/* get the Rx desc from Rx queue based on 'next_to_clean' */ + rx_desc =IECM_RX_DESC (rx_q, rx_q->next_to_clean); + +/* This memory barrier is needed to keep us from reading +* any other fields out of the rx_desc
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c line 1091
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +10
-0+*/ +dma_rmb (); + +/* status_error_ptype_len will always be zero for unused +* descriptors because it's cleared in cleanup, and overlaps +* with hdr_addr which is always zero because packet split +* isn't used, if the hardware wrote DD then the length will be +* non-zero +*/ +#define IECM_RXD_DD BIT(VIRTCHNL2_RX_BASE_DESC_STATUS_DD_S)
Should be moved from here as well.
Quoted 21 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +21
-0+if (!iecm_rx_singleq_test_staterr (rx_desc, +IECM_RXD_DD )) +break ; +iecm_rx_singleq_extract_fields (rx_q, rx_desc, &fields); + +if (!fields.size) +break ; + + rx_buf = &rx_q->rx_buf.buf[rx_q->next_to_clean]; + skb =iecm_rx_singleq_get_buf_page (rx_q->dev, rx_buf, + fields.size); + +if (skb) +iecm_rx_add_frag (rx_buf, skb, fields.size); +else + skb =iecm_rx_construct_skb (rx_q, rx_buf, fields.size); + +/* exit if we failed to retrieve a buffer */ +if (!skb) { + rx_buf->page_info[rx_buf->page_indx].pagecnt_bias++; +break ;
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c line 1122
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +10
-0+ } + +iecm_rx_singleq_put_buf (rx_q, rx_buf); +iecm_rx_singleq_bump_ntc (rx_q); + + cleaned_count++; + +/* skip if it is non EOP desc */ +if (iecm_rx_singleq_is_non_eop (rx_q, rx_desc, + skb))
skb fits into previous line.
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c line 1125
Quoted 3 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +3
-0+continue ; + +#define IECM_RXD_ERR_S BIT(VIRTCHNL2_RX_BASE_DESC_QW1_ERROR_S)
Same.
Quoted 71 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +67
-0+if (unlikely (iecm_rx_singleq_test_staterr (rx_desc, +IECM_RXD_ERR_S ))) { +dev_kfree_skb_any (skb); + skb =NULL ; +continue ; + } + +/* pad skb if needed (to make valid ethernet frame) */ +if (eth_skb_pad (skb)) { + skb =NULL ; +continue ; + } + +/* probably a little skewed due to removing CRC */ + total_rx_bytes += skb->len; + +/* protocol */ +iecm_rx_singleq_process_skb_fields (rx_q, skb, + rx_desc, fields.rx_ptype); + +/* send completed skb up the stack */ +iecm_rx_skb (rx_q, skb, fields.vlan_tag); + +/* update budget accounting */ + total_rx_pkts++; + } +if (cleaned_count) + failure =iecm_rx_singleq_buf_hw_alloc_all (rx_q, cleaned_count); + +u64_stats_update_begin (&rx_q->stats_sync); + rx_q->q_stats.rx.packets += total_rx_pkts; + rx_q->q_stats.rx.bytes += total_rx_bytes; +u64_stats_update_end (&rx_q->stats_sync); + +/* guarantee a trip back through this routine if there was a failure */ +return failure ? budget : (int )total_rx_pkts; +} + +/** +* iecm_rx_singleq_clean_all - Clean all Rx queues +* @q_vec: queue vector +* @budget: Used to determine if we are in netpoll +* @cleaned: returns number of packets cleaned +* +* Returns false if clean is not complete else returns true +*/ +static bool +iecm_rx_singleq_clean_all (struct iecm_q_vector *q_vec,int budget, +int *cleaned) +{ +bool clean_complete = true; +int budget_per_q, i; + + budget_per_q =max (budget / q_vec->num_rxq,1 ); +for (i =0 ; i < q_vec->num_rxq; i++) { +struct iecm_queue *rxq = q_vec->rx[i]; +int pkts_cleaned_per_q; + + pkts_cleaned_per_q =iecm_rx_singleq_clean (rxq, budget_per_q); + +/* if we clean as many as budgeted, we must not be done */ +if (pkts_cleaned_per_q >= budget_per_q) + clean_complete = false; + *cleaned += pkts_cleaned_per_q; + } + +return clean_complete; }/**
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c bool iecm_rx_singleq_buf_hw_alloc_all(struct iecm_queue *rx_q, · line 1203
Quoted 7 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +2
-2@@ -24,6 +1199,31 @@ bool iecm_rx_singleq_buf_hw_alloc_all(struct iecm_queue *rx_q,*/ int iecm_vport_singleq_napi_poll (struct napi_struct *napi,int budget) { -/* stub */ -return 0 ; +struct iecm_q_vector *q_vector = + container_of(napi, struct iecm_q_vector, napi);
Declare + assign to avoid.
Quoted 70 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +25
-0+bool clean_complete; +int work_done =0 ; + + clean_complete =iecm_tx_singleq_clean_all (q_vector, budget); + +/* Handle case where we are called by netpoll with a budget of 0 */ +if (budget <=0 ) +return budget; + +/* We attempt to distribute budget to each Rx queue fairly, but don't +* allow the budget to go below 1 because that would exit polling early. +*/ + clean_complete |=iecm_rx_singleq_clean_all (q_vector, budget, + &work_done); + +/* If work not completed, return budget and polling will return */ +if (!clean_complete) +return budget; + +/* Exit the polling mode, but don't re-enable interrupts if stack might +* poll us due to busy-polling +*/ +if (likely (napi_complete_done (napi, work_done))) +iecm_vport_intr_update_itr_ena_irq (q_vector); +return min_t (int, work_done, budget -1 ); }drivers/net/ethernet/intel/include/iecm.h +1
-0@@ -8,6 +8,7 @@#include <net/pkt_cls.h> #include <linux/aer.h> #include <linux/pci.h> +#include <linux/sctp.h> #include <linux/netdevice.h> #include <linux/etherdevice.h> #include <linux/ethtool.h> drivers/net/ethernet/intel/include/iecm_txrx.h +20
-0@@ -624,6 +624,26 @@ struct iecm_txq_group {struct iecm_adapter ; +/** +* iecm_tx_singleq_build_ctob - populate command tag offset and size +* @td_cmd: Command to be filled in desc +* @td_offset: Offset to be filled in desc +* @size: Size of the buffer +* @td_tag: vlan tag to be filled +* +* Returns the 64 bit value populated with the input parameters +*/ +static inline __le64 +iecm_tx_singleq_build_ctob (u64 td_cmd,u64 td_offset,unsigned int size, +u64 td_tag) +{ +return cpu_to_le64 (IECM_TX_DESC_DTYPE_DATA | + (td_cmd <<IECM_TXD_QW1_CMD_S ) | + (td_offset <<IECM_TXD_QW1_OFFSET_S ) | + ((u64 )size <<IECM_TXD_QW1_TX_BUF_SZ_S ) | + (td_tag <<IECM_TXD_QW1_L2TAG1_S )); +} +void iecm_tx_splitq_build_ctb (union iecm_tx_flex_desc *desc,struct iecm_tx_splitq_params *parms,u16 td_cmd,u16 size);
drivers/net/ethernet/intel/include/iecm_txrx.h void iecm_rx_splitq_put_bufs(struct iecm_queue *rx_bufq, · line 701
Quoted 9 lines
drivers/net/ethernet/intel/include/iecm_txrx.h +4
-0@@ -673,8 +693,19 @@ void iecm_rx_splitq_put_bufs(struct iecm_queue *rx_bufq,struct iecm_rx_buf *hdr_buf, struct iecm_rx_buf *rx_buf);bool iecm_rx_splitq_test_staterr (u8 stat_err_field,const u8 stat_err_bits); +bool iecm_rx_singleq_test_staterr (union virtchnl2_rx_desc *rx_desc, +const u64 stat_err_bits);int iecm_rx_process_skb_fields (struct iecm_queue *rxq,struct sk_buff *skb,struct virtchnl2_rx_flex_desc_adv_nic_3 *rx_desc); +void iecm_rx_singleq_process_skb_fields (struct iecm_queue *rx_q,struct sk_buff *skb, +union virtchnl2_rx_desc *rx_desc,u16 ptype);
Break the line after void to avoid (huh) going past 79.
Quoted 12 lines
drivers/net/ethernet/intel/include/iecm_txrx.h +7
-0+void iecm_rx_singleq_extract_fields (struct iecm_queue *rx_q, +union virtchnl2_rx_desc *rx_desc, +struct iecm_rx_extracted *fields); +void iecm_rx_singleq_bump_ntc (struct iecm_queue *q); +bool iecm_rx_singleq_is_non_eop (struct iecm_queue *rxq, +union virtchnl2_rx_desc *rx_desc, +struct sk_buff *skb);bool iecm_rx_splitq_extract_vlan_tag (struct virtchnl2_rx_flex_desc_adv_nic_3 *desc,struct iecm_queue *rxq,u16 *vlan_tag);void iecm_rx_bump_ntc (struct iecm_queue *q);Signature · 1 line
2.33.0
Thanks,
Al
Brady
PATCH 14/19 iecm: implement singleq napi_poll
Quoted 204 lines
-----Original Message-----
From: Lobakin, Alexandr <[email protected]>
Sent: Friday, January 28, 2022 9:58 AM
To: Brady, Alan <[email protected]>
Cc: Lobakin, Alexandr <[email protected]>; intel-wired- lan at lists.osuosl.org; Burra, Phani R <[email protected]>; Chittim, Madhu <[email protected]>; Linga, Pavan Kumar <[email protected]>
Subject: [Intel-wired-lan] [PATCH net-next 14/19] iecm: implement singleqnapi_pollQuoted 5 lines
From: Alan Brady <[email protected]>
Date: Thu, 27 Jan 2022 16:10:04 -0800This adds everything we do the more traditional singleq model data path.
Quoted 8 lines
Signed-off-by Phani Burra <[email protected]>Signed-off-by Joshua Hay <[email protected]>Signed-off-by Madhu Chittim <[email protected]>Signed-off-by Pavan Kumar Linga <[email protected]>Signed-off-by Alan Brady <[email protected]>--- drivers/net/ethernet/intel/iecm/iecm_lib.c | 2 +- .../ethernet/intel/iecm/iecm_singleq_txrx.c | 1208++++++++++++++++-
Quoted 11 lines
drivers/net/ethernet/intel/include/iecm.h | 1 + .../net/ethernet/intel/include/iecm_txrx.h | 31 + 4 files changed, 1237 insertions(+), 5 deletions(-)drivers/net/ethernet/intel/iecm/iecm_lib.c +0
-0@@ -2723,7 +2723,7 @@ static const struct net_device_ops
iecm_netdev_ops_splitq= { static const structnet_device_ops
iecm_netdev_ops_singleq= {Quoted 48 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +1
-1.ndo_open = iecm_open, .ndo_stop = iecm_stop, - .ndo_start_xmit = NULL, + .ndo_start_xmit = iecm_tx_singleq_start, .ndo_set_rx_mode = iecm_set_rx_mode, .ndo_validate_addr = eth_validate_addr, .ndo_set_mac_address = iecm_set_mac, diff --git
a/drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.cb/drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.cindexd6c47cb84249..7bfec79e6afc100644drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +32
-0@@ -3,6 +3,779 @@#include "iecm.h" +/** +* iecm_tx_singleq_csum - Enable tx checksum offloads +* @first: pointer to first descriptor +* @off: pointer to struct that holds offload parameters +* +* Returns 0 or error (negative) if checksum offload */ static int +iecm_tx_singleq_csum (struct iecm_tx_buf *first, +struct iecm_tx_offload_params *off) { +u32 l4_len =0 , l3_len =0 , l2_len =0 ; +struct sk_buff *skb = first->skb; +union { +struct iphdr *v4; +struct ipv6hdr *v6; +unsigned char *hdr; + } ip; +union { +struct tcphdr *tcp; +unsigned char *hdr; + } l4; +__be16 frag_off, protocol; +unsigned char *exthdr; +u32 offset, cmd =0 ; +u8 l4_proto =0 ; + +if (skb->ip_summed !=CHECKSUM_PARTIAL ) +return 0 ; + +if (skb->encapsulation) +return -1 ; + + ip.hdr =skb_network_header (skb); + l4.hdr =skb_transport_header (skb);drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c line 47
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +10
-0+ +/* compute outer L2 header size */ + l2_len = ip.hdr - skb->data; + offset = (l2_len /2 ) <<IECM_TX_DESC_LEN_MACLEN_S ; + +/* Enable IP checksum offloads */ + protocol =vlan_get_protocol (skb); +if (protocol ==htons (ETH_P_IP )) { + l4_proto = ip.v4->protocol; +/* the stack computes the IP header already, the only time we
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c
Quoted 13 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +13
-0+* need the hardware to recompute it is in the case of TSO. +*/ +if (first->tx_flags &IECM_TX_FLAGS_TSO ) + cmd |=IECM_TX_DESC_CMD_IIPT_IPV4_CSUM ; +else + cmd |=IECM_TX_DESC_CMD_IIPT_IPV4 ; + + }else if (protocol ==htons (ETH_P_IPV6 )) { + cmd |=IECM_TX_DESC_CMD_IIPT_IPV6 ; + exthdr = ip.hdr +sizeof (struct ipv6hdr ); + l4_proto = ip.v6->nexthdr; +if (l4.hdr != exthdr) + ipv6_skip_exthdr(skb, exthdr - skb->data,
&l4_proto,Quoted 44 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +44
-0+ &frag_off); + }else { +return -1 ; + } + +/* compute inner L3 header size */ + l3_len = l4.hdr - ip.hdr; + offset |= (l3_len /4 ) <<IECM_TX_DESC_LEN_IPLEN_S ; + +/* Enable L4 checksum offloads */ +switch (l4_proto) { +case IPPROTO_TCP : +/* enable checksum offloads */ + cmd |=IECM_TX_DESC_CMD_L4T_EOFT_TCP ; + l4_len = l4.tcp->doff; + offset |= l4_len <<IECM_TX_DESC_LEN_L4_LEN_S ; +break ; +case IPPROTO_UDP : +/* enable UDP checksum offload */ + cmd |=IECM_TX_DESC_CMD_L4T_EOFT_UDP ; + l4_len = (sizeof (struct udphdr ) >>2 ); + offset |= l4_len <<IECM_TX_DESC_LEN_L4_LEN_S ; +break ; +case IPPROTO_SCTP : +/* enable SCTP checksum offload */ + cmd |=IECM_TX_DESC_CMD_L4T_EOFT_SCTP ; + l4_len =sizeof (struct sctphdr ) >>2 ; + offset |= l4_len <<IECM_TX_DESC_LEN_L4_LEN_S ; +break ; + +default : +if (first->tx_flags &IECM_TX_FLAGS_TSO ) +return -1 ; +skb_checksum_help (skb); +return 0 ; + } + + off->td_cmd |= cmd; + off->hdr_offsets |= offset; +return 1 ; +} + +/** +* iecm_tx_singleq_map - Build the Tx base descriptor drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +10
-0+* @tx_q: queue to send buffer on +* @first: first buffer info buffer to use +* @offloads: pointer to struct that holds offload parameters +* +* This function loops over the skb data pointed to by *first +* and gets a physical address for each memory location and programs +* it and the length into the transmit base mode descriptor. +*/ +static void +iecm_tx_singleq_map(struct iecm_queue *tx_q, struct iecm_tx_buf*first,
Quoted 24 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +23
-0+ struct iecm_tx_offload_params *offloads) { +u32 offsets = offloads->hdr_offsets; +struct iecm_base_tx_desc *tx_desc; +u64 td_cmd = offloads->td_cmd; +unsigned int data_len, size; +struct iecm_tx_buf *tx_buf; +u16 i = tx_q->next_to_use; +struct netdev_queue *nq; +struct sk_buff *skb; +skb_frag_t *frag; +dma_addr_t dma; +u64 td_tag =0 ; + + skb = first->skb; + + data_len = skb->data_len; + size =skb_headlen (skb); + + tx_desc =IECM_BASE_TX_DESC (tx_q, i); + +if (first->tx_flags &IECM_TX_FLAGS_VLAN_TAG ) { + td_cmd |= (u64 )IECM_TX_DESC_CMD_IL2TAG1 ; + td_tag = (first->tx_flags &IECM_TX_FLAGS_VLAN_MASK )Quoted 1 line
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c
Quoted 4 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +4
-0+IECM_TX_FLAGS_VLAN_SHIFT ; + } + + dma = dma_map_single(tx_q->dev, skb->data, size,
DMA_TO_DEVICE);drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c
Quoted 9 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +9
-0+ + tx_buf = first; + +/* write each descriptor with CRC bit */ +if (tx_q->vport->adapter->dev_ops.crc_enable) + tx_q->vport->adapter->dev_ops.crc_enable (&td_cmd); + +for (frag = &skb_shinfo (skb)->frags[0 ];; frag++) { + unsigned int max_data =
IECM_TX_MAX_DESC_DATA_ALIGNED;
Quoted 13 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c line 164
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +10
-0+ +if (dma_mapping_error (tx_q->dev, dma)) + goto dma_error; + +/* record length, and DMA address */ +dma_unmap_len_set (tx_buf, len, size); +dma_unmap_addr_set (tx_buf, dma, dma); + +/* align size to end of page */ + max_data += -dma & (IECM_TX_MAX_READ_REQ_SIZE -1 );Here applies the same I said for splitq before, this code is counter-intuitive.
I'm failing to find a matching comment for iecm_tx_splitq_map but I'm sure we're open to suggestion how to make it better.
Quoted 216 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c
Quoted 7 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +7
-0+ tx_desc->buf_addr =cpu_to_le64 (dma); + +/* account for data chunks larger than the hardware +* can handle +*/ +while (unlikely (size >IECM_TX_MAX_DESC_DATA )) { + tx_desc->qw1 =iecm_tx_singleq_build_ctob(td_cmd,
Quoted 11 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +11
-0+ offsets, + max_data, + td_tag); + tx_desc++; + i++; + +if (i == tx_q->desc_count) { + tx_desc =IECM_BASE_TX_DESC (tx_q,0 ); + i =0 ; + } +drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +10
-0+ dma += max_data; + size -= max_data; + + max_data =IECM_TX_MAX_DESC_DATA_ALIGNED ; + tx_desc->buf_addr =cpu_to_le64 (dma); + } + +if (likely (!data_len)) +break ; + tx_desc->qw1 = iecm_tx_singleq_build_ctob(td_cmd,offsets,
Quoted 17 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +17
-0+ size, td_tag); + tx_desc++; + i++; + +if (i == tx_q->desc_count) { + tx_desc =IECM_BASE_TX_DESC (tx_q,0 ); + i =0 ; + } + + size =skb_frag_size (frag); + data_len -= size; + + dma =skb_frag_dma_map (tx_q->dev, frag,0 , size, +DMA_TO_DEVICE ); + + tx_buf = &tx_q->tx_buf[i]; + }drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +10
-0+ +/* record bytecount for BQL */ + nq =netdev_get_tx_queue (tx_q->vport->netdev, tx_q->idx); +netdev_tx_sent_queue (nq, first->bytecount); + +/* record SW timestamp if HW timestamp is not available */ +skb_tx_timestamp (first->skb); + +/* write last descriptor with RS and EOP bits */ + td_cmd |= (u64)(IECM_TX_DESC_CMD_EOP |
IECM_TX_DESC_CMD_RS);Quoted 46 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +46
-0+ + tx_desc->qw1 =iecm_tx_singleq_build_ctob (td_cmd, offsets, size, +td_tag); + + i++; +if (i == tx_q->desc_count) + i =0 ; + +/* set next_to_watch value indicating a packet is present */ + first->next_to_watch = tx_desc; + +iecm_tx_buf_hw_update (tx_q, i,netdev_xmit_more ()); + +return ; + +dma_error: +/* clear dma mappings for failed tx_buf map */ +for (;;) { + tx_buf = &tx_q->tx_buf[i]; +iecm_tx_buf_rel (tx_q, tx_buf); +if (tx_buf == first) +break ; +if (i ==0 ) + i = tx_q->desc_count; + i--; + } + + tx_q->next_to_use = i; +} + +/** +* iecm_tx_singleq_frame - Sends buffer on Tx ring using base +descriptors +* @skb: send buffer +* @tx_q: queue to send buffer on +* +* Returns NETDEV_TX_OK if sent, else an error code */ static +netdev_tx_t iecm_tx_singleq_frame (struct sk_buff *skb,struct +iecm_queue *tx_q) { +struct iecm_tx_offload_params offload = {0 }; +struct iecm_tx_buf *first; +unsigned int count; +int csum, tso; + + count =iecm_tx_desc_count_required (skb); +drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +10
-0+if (iecm_chk_linearize (skb, tx_q->tx_max_bufs, count)) { +if (__skb_linearize (skb)) { +dev_kfree_skb_any (skb); +return NETDEV_TX_OK ; + } + count =iecm_size_to_txd_count (skb->len); + tx_q->vport->port_stats.tx_linearize++; + } + + if (iecm_tx_maybe_stop(tx_q, count +
IECM_TX_DESCS_PER_CACHE_LINE+Quoted 16 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +16
-0+ IECM_TX_DESCS_FOR_CTX)) { +return NETDEV_TX_BUSY ; + } + +/* record the location of the first descriptor for this packet */ + first = &tx_q->tx_buf[tx_q->next_to_use]; + first->skb = skb; + first->bytecount = max_t(unsigned int, skb->len, ETH_ZLEN); + first->gso_segs =1 ; + first->tx_flags =0 ; + +iecm_tx_prepare_vlan_flags (tx_q, first, skb); + + tso =iecm_tso (first, &offload); +if (tso <0 ) + goto out_drop;drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +10
-0+ + csum =iecm_tx_singleq_csum (first, &offload); +if (csum <0 ) + goto out_drop; + +if (first->tx_flags &IECM_TX_FLAGS_TSO ) { +struct iecm_base_tx_ctx_desc *ctx_desc; +int i = tx_q->next_to_use; +u64 qw1 = (u64 )IECM_TX_DESC_DTYPE_CTX | + IECM_TX_CTX_DESC_TSO <<
IECM_TXD_CTX_QW1_CMD_S;drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c
Quoted 7 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +7
-0+ +/* grab the next descriptor */ + ctx_desc =IECM_BASE_TX_CTX_DESC (tx_q, i); + i++; + tx_q->next_to_use = (i < tx_q->desc_count) ? i :0 ; + + qw1 |= ((u64)offload.tso_len <<
IECM_TXD_CTX_QW1_TSO_LEN_S) &drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c
Quoted 3 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +3
-0+IECM_TXD_CTX_QW1_TSO_LEN_M ; + + qw1 |= ((u64 )offload.mss <<IECM_TXD_CTX_QW1_MSS_S )&
Quoted 25 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +25
-0+IECM_TXD_CTX_QW1_MSS_M ; + + ctx_desc->qw0.rsvd0 =cpu_to_le32 (0 ); + ctx_desc->qw0.l2tag2 =cpu_to_le16 (0 ); + ctx_desc->qw0.rsvd1 =cpu_to_le16 (0 ); + ctx_desc->qw1 =cpu_to_le64 (qw1); + } + +iecm_tx_singleq_map (tx_q, first, &offload); + +return NETDEV_TX_OK ; + +out_drop: +dev_kfree_skb_any (skb); +return NETDEV_TX_OK ; +} + +/** +* iecm_tx_singleq_start - Selects the right Tx queue to send buffer +* @skb: send buffer +* @netdev: network interface device structure +* +* Returns NETDEV_TX_OK if sent, else an error code */ netdev_tx_t +iecm_tx_singleq_start (struct sk_buff *skb, +struct net_device *netdev)drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +10
-0+{ +struct iecm_vport *vport =iecm_netdev_to_vport (netdev); +struct iecm_queue *tx_q; + +if (test_bit (__IECM_HR_RESET_IN_PROG, vport->adapter->flags)) +return NETDEV_TX_BUSY ; + + tx_q = vport->txqs[skb->queue_mapping]; + +/* hardware can't handle really short frames, hardware padding works
Quoted 26 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +26
-0+* beyond this point +*/ +if (skb_put_padto (skb,IECM_TX_MIN_LEN )) +return NETDEV_TX_OK ; + +return iecm_tx_singleq_frame (skb, tx_q); } + +/** +* iecm_tx_singleq_clean - Reclaim resources from queue +* @tx_q: Tx queue to clean +* @napi_budget: Used to determine if we are in netpoll +* +*/ +static bool iecm_tx_singleq_clean (struct iecm_queue *tx_q,int +napi_budget) { +unsigned int budget = tx_q->vport->compln_clean_budget; +unsigned int total_bytes =0 , total_pkts =0 ; +struct iecm_base_tx_desc *tx_desc; +s16 ntc = tx_q->next_to_clean; +struct iecm_tx_buf *tx_buf; +struct netdev_queue *nq; + + tx_desc =IECM_BASE_TX_DESC (tx_q, ntc); + tx_buf = &tx_q->tx_buf[ntc]; + ntc -= tx_q->desc_count; +
Quoted 9 lines
Quoted 4 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +3
-0+ do { + struct iecm_base_tx_desc *eop_desc = + (struct iecm_base_tx_desc *)tx_buf-
next_to_watch;struct iecm_base_tx_desc *eop_desc; eop_desc = (typeof(*eop_desc))tx_buf->next_to_watch;
Again not sure I see the benefit to prefer assigning it's own line over letting it wrap. Suggestion as written is wrong also.
Quoted 40 lines
Quoted 40 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +40
-0+ +/* if next_to_watch is not set then no work pending */ +if (!eop_desc) +break ; + +/* prevent any other reads prior to eop_desc */ +smp_rmb (); + +/* if the descriptor isn't done, no work yet to do */ +if (!(eop_desc->qw1 & +cpu_to_le64 (IECM_TX_DESC_DTYPE_DESC_DONE ))) +break ; + +/* clear next_to_watch to prevent false hangs */ + tx_buf->next_to_watch =NULL ; + +/* update the statistics for this packet */ + total_bytes += tx_buf->bytecount; + total_pkts += tx_buf->gso_segs; + +/* free the skb */ +napi_consume_skb (tx_buf->skb, napi_budget); + +/* unmap skb header data */ +dma_unmap_single (tx_q->dev, +dma_unmap_addr (tx_buf, dma), +dma_unmap_len (tx_buf, len), +DMA_TO_DEVICE ); + +/* clear tx_buf data */ + tx_buf->skb =NULL ; +dma_unmap_len_set (tx_buf, len,0 ); + +/* unmap remaining buffers */ +while (tx_desc != eop_desc) { + tx_buf++; + tx_desc++; + ntc++; +if (unlikely (!ntc)) { + ntc -= tx_q->desc_count;
Quoted 9 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c line 423
Quoted 6 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +6
-0+ tx_buf = tx_q->tx_buf; + tx_desc =IECM_BASE_TX_DESC (tx_q,0 ); + } + +/* unmap any remaining paged data */ +if (dma_unmap_len (tx_buf, len)) {Here applies the same I said for splitq about
dma_unmap_len().
Sure we'll take a look at dma_unmap_len
Quoted 105 lines
Quoted 22 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +22
-0+dma_unmap_page (tx_q->dev, +dma_unmap_addr (tx_buf, dma), +dma_unmap_len (tx_buf, len), +DMA_TO_DEVICE ); +dma_unmap_len_set (tx_buf, len,0 ); + } + } + + tx_buf++; + tx_desc++; + ntc++; +if (unlikely (!ntc)) { + ntc -= tx_q->desc_count; + tx_buf = tx_q->tx_buf; + tx_desc =IECM_BASE_TX_DESC (tx_q,0 ); + } +/* update budget */ + budget--; + }while (likely (budget)); + + ntc += tx_q->desc_count; + tx_q->next_to_clean = ntc;drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +10
-0+ +u64_stats_update_begin (&tx_q->stats_sync); + tx_q->q_stats.tx.packets += total_pkts; + tx_q->q_stats.tx.bytes += total_bytes; +u64_stats_update_end (&tx_q->stats_sync); + + nq =netdev_get_tx_queue (tx_q->vport->netdev, tx_q->idx); +netdev_tx_completed_queue (nq, total_pkts, total_bytes); + + if (unlikely(total_pkts && netif_carrier_ok(tx_q->vport->netdev)&&
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c
Quoted 1 line
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +1
-0+ (IECM_DESC_UNUSED(tx_q) >=
IECM_TX_WAKE_THRESH))) {drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c
Quoted 1 line
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +1
-0+/* Make sure any other threads stopping queue after this see
Quoted 17 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +4
-0+* new next_to_clean. +*/ +smp_mb (); + if (__netif_subqueue_stopped(tx_q->vport->netdev, tx_q-idx) &&
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +2
-0+ tx_q->vport->adapter->state == __IECM_UP) + netif_wake_subqueue(tx_q->vport->netdev, tx_q-idx);
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +9
-0+ } + +return !!budget; +} + +/** +* iecm_tx_singleq_clean_all - Clean all Tx queues +* @q_vec: queue vector +* @budget: Used to determine if we are in netpoll drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +10
-0+* +* Returns false if clean is not complete else returns true */ +static bool iecm_tx_singleq_clean_all (struct iecm_q_vector *q_vec, +int budget) { +bool clean_complete = true; +int i, budget_per_q; + + budget_per_q =max (budget / q_vec->num_txq,1 ); +for (i =0 ; i < q_vec->num_txq; i++) + clean_complete = iecm_tx_singleq_clean(q_vec->tx[i],
budget_per_q);84 cols per line.
Quoted 25 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +25
-0+ +return clean_complete; +} + +/** +* iecm_rx_singleq_test_staterr - tests bits in Rx descriptor +* status and error fields +* @rx_desc: pointer to receive descriptor (in le64 format) +* @stat_err_bits: value to mask +* +* This function does some fast chicanery in order to return the +* value of the mask which is really only used for boolean tests. +* The status_error_ptype_len doesn't need to be shifted because it +begins +* at offset zero. +*/ +bool +iecm_rx_singleq_test_staterr (union virtchnl2_rx_desc *rx_desc, +const u64 stat_err_bits) +{ +return !!(rx_desc->base_wb.qword1.status_error_ptype_len & +cpu_to_le64 (stat_err_bits)); +} + +/** drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +10
-0+* iecm_rx_singleq_is_non_eop - process handling of non-EOP buffers +* @rxq: Rx ring being processed +* @rx_desc: Rx descriptor for current buffer +* @skb: Current socket buffer containing buffer in progress */ bool +iecm_rx_singleq_is_non_eop (struct iecm_queue *rxq, +union virtchnl2_rx_desc *rx_desc, +struct sk_buff *skb) +{ +/* if we are the last buffer then there is nothing else to do */ +#define IECM_RXD_EOF
BIT(VIRTCHNL2_RX_BASE_DESC_STATUS_EOF_S)
Quoted 2 lines
Not a good place for a definition, makes reading difficult.
Will fix.
Quoted 213 lines
Quoted 8 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +8
-0+if (likely (iecm_rx_singleq_test_staterr (rx_desc,IECM_RXD_EOF ))) +return false; + +/* place skb in next buffer to be received */ + rxq->rx_buf.buf[rxq->next_to_clean].skb = skb; + +return true; +}drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +10
-0+ +/** +* iecm_rx_singleq_csum - Indicate in skb if checksum is good +* @rxq: Rx descriptor ring packet is being transacted on +* @skb: skb currently being received and modified +* @csum_bits: descriptor csum bits +* @ptype: the packet type decoded by hardware +* +* skb->protocol must be set before this function is called */ +static void iecm_rx_singleq_csum(struct iecm_queue *rxq, struct
sk_buff*skb,Quoted 32 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +32
-0+ struct iecm_rx_csum_decoded *csum_bits, + u16 ptype) +{ +struct iecm_rx_ptype_decoded decoded; +bool ipv4, ipv6; + +/* Start with CHECKSUM_NONE and by default csum_level = 0 */ + skb->ip_summed =CHECKSUM_NONE ; +skb_checksum_none_assert (skb); + +/* check if Rx checksum is enabled */ +if (!(rxq->vport->netdev->features &NETIF_F_RXCSUM )) +return ; + +/* check if HW has decoded the packet and checksum */ +if (!(csum_bits->l3l4p)) +return ; + + decoded = rxq->vport->rx_ptype_lkup[ptype]; +if (!(decoded.known && decoded.outer_ip)) +return ; + + ipv4 = (decoded.outer_ip ==IECM_RX_PTYPE_OUTER_IP ) && + (decoded.outer_ip_ver ==IECM_RX_PTYPE_OUTER_IPV4 ); + ipv6 = (decoded.outer_ip ==IECM_RX_PTYPE_OUTER_IP ) && + (decoded.outer_ip_ver ==IECM_RX_PTYPE_OUTER_IPV6 ); + +if (ipv4 && (csum_bits->ipe || csum_bits->eipe)) + goto checksum_fail; +else if (ipv6 && (csum_bits->ipv6exadd)) + goto checksum_fail; +drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +10
-0+/* check for L4 errors and handle packets that were not able to be +* checksummed due to arrival speed +*/ +if (csum_bits->l4e) + goto checksum_fail; + +if (csum_bits->nat && csum_bits->eudpe) + goto checksum_fail; + +/* Handle packets that were not able to be checksummed due to arrival
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c
Quoted 6 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +6
-0+* speed, in this case the stack can compute the csum. +*/ +if (csum_bits->pprs) +return ; + +/* If there is an outer header present that might contain a checksum
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c
Quoted 7 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +7
-0+* we need to bump the checksum level by 1 to reflect the fact that +* we are indicating we validated the inner checksum. +*/ +if (decoded.tunnel_type >=IECM_RX_PTYPE_TUNNEL_IP_GRENAT ) + skb->csum_level =1 ; + +/* Only report checksum unnecessary for ICMP, TCP, UDP, or SCTP */
Quoted 14 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +14
-0+switch (decoded.inner_prot) { +case IECM_RX_PTYPE_INNER_PROT_ICMP : +case IECM_RX_PTYPE_INNER_PROT_TCP : +case IECM_RX_PTYPE_INNER_PROT_UDP : +case IECM_RX_PTYPE_INNER_PROT_SCTP : + skb->ip_summed =CHECKSUM_UNNECESSARY ; +default : +break ; + } +return ; + +checksum_fail: + rxq->vport->port_stats.rx_hw_csum_err++; +}drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +10
-0+ +/** +* iecm_rx_singleq_base_csum - Indicate in skb if hw indicated a good +cksum +* @rx_q: Rx completion queue +* @skb: skb currently being received and modified +* @rx_desc: the receive descriptor +* @ptype: Rx packet type +* +* This function only operates on the
VIRTCHNL2_RXDID_1_32B_BASE_Mdrivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c
Quoted 5 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +5
-0+legacy 32byte +* descriptor writeback format. +**/ +static void +iecm_rx_singleq_base_csum(struct iecm_queue *rx_q, struct sk_buff*skb,
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c
Quoted 9 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +6
-0+ union virtchnl2_rx_desc *rx_desc, u16 ptype) { +struct iecm_rx_csum_decoded csum_bits; +u32 rx_error, rx_status; +u64 qword; + + qword = le64_to_cpu(rx_desc-base_wb.qword1.status_error_ptype_len);
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +2
-0+ + rx_status = ((qword &
VIRTCHNL2_RX_BASE_DESC_QW1_STATUS_M) >>Quoted 1 line
+
VIRTCHNL2_RX_BASE_DESC_QW1_STATUS_S);Quoted 3 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +1
-0+ rx_error = ((qword & VIRTCHNL2_RX_BASE_DESC_QW1_ERROR_M)Quoted 1 line
+
VIRTCHNL2_RX_BASE_DESC_QW1_ERROR_S);drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c
Quoted 2 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +2
-0+ + csum_bits.ipe = !!(rx_error &
BIT(VIRTCHNL2_RX_BASE_DESC_ERROR_IPE_S));drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c
Quoted 1 line
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +1
-0+ csum_bits.eipe = !!(rx_error &
BIT(VIRTCHNL2_RX_BASE_DESC_ERROR_EIPE_S));drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c
Quoted 1 line
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +1
-0+ csum_bits.l4e = !!(rx_error &
BIT(VIRTCHNL2_RX_BASE_DESC_ERROR_L4E_S));drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c
Quoted 1 line
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +1
-0+ csum_bits.pprs = !!(rx_error &
BIT(VIRTCHNL2_RX_BASE_DESC_ERROR_PPRS_S));drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c line 644
Quoted 2 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +2
-0+ csum_bits.l3l4p = !!(rx_status & +
BIT(VIRTCHNL2_RX_BASE_DESC_STATUS_L3L4P_S));drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c line 644
Quoted 2 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +2
-0+ csum_bits.ipv6exadd = !!(rx_status & +
BIT(VIRTCHNL2_RX_BASE_DESC_STATUS_IPV6EXADD_S));Quoted 4 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +4
-0+ csum_bits.nat =0 ; + csum_bits.eudpe =0 ; + +iecm_rx_singleq_csum (rx_q, skb, &csum_bits, ptype); }drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +10
-0+ +/** +* iecm_rx_singleq_flex_csum - Indicate in skb if hw indicated a good +cksum +* @rx_q: Rx completion queue +* @skb: skb currently being received and modified +* @rx_desc: the receive descriptor +* @ptype: Rx packet type +* +* This function only operates on the
VIRTCHNL2_RXDID_2_FLEX_SQ_NICdrivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c
Quoted 5 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +5
-0+flexible +* descriptor writeback format. +**/ +static void +iecm_rx_singleq_flex_csum(struct iecm_queue *rx_q, struct sk_buff*skb,
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c line 684
Quoted 9 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +9
-0+ union virtchnl2_rx_desc *rx_desc, u16 ptype) { +struct iecm_rx_csum_decoded csum_bits; +u16 rx_status0, rx_status1; + + rx_status0 =le16_to_cpu (rx_desc->flex_nic_wb.status_error0); + rx_status1 =le16_to_cpu (rx_desc->flex_nic_wb.status_error1); + + csum_bits.ipe = !!(rx_status0 & +
BIT(VIRTCHNL2_RX_FLEX_DESC_STATUS0_XSUM_IPE_S));drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c line 684
Quoted 2 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +2
-0+ csum_bits.eipe = !!(rx_status0 & +
BIT(VIRTCHNL2_RX_FLEX_DESC_STATUS0_XSUM_EIPE_S));drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c line 684
Quoted 2 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +2
-0+ csum_bits.l4e = !!(rx_status0 & +
BIT(VIRTCHNL2_RX_FLEX_DESC_STATUS0_XSUM_L4E_S));drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c line 684
Quoted 2 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +2
-0+ csum_bits.eudpe = !!(rx_status0 & +
BIT(VIRTCHNL2_RX_FLEX_DESC_STATUS0_XSUM_EUDPE_S));drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c line 684
Quoted 2 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +2
-0+ csum_bits.l3l4p = !!(rx_status0 & +
BIT(VIRTCHNL2_RX_FLEX_DESC_STATUS0_L3L4P_S));drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c line 684
Quoted 3 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +3
-0+ csum_bits.ipv6exadd = + !!(rx_status0 & +
BIT(VIRTCHNL2_RX_FLEX_DESC_STATUS0_IPV6EXADD_S));drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c line 684
Quoted 2 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +2
-0+ csum_bits.nat = !!(rx_status1 & +
BIT(VIRTCHNL2_RX_FLEX_DESC_STATUS1_NAT_S));drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c
Quoted 12 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +12
-0+ csum_bits.pprs =0 ; + +iecm_rx_singleq_csum (rx_q, skb, &csum_bits, ptype); } + +/** +* iecm_rx_singleq_base_hash - set the hash value in the skb +* @rx_q: Rx completion queue +* @skb: skb currently being received and modified +* @rx_desc: specific descriptor +* @decoded: Decoded Rx packet type related fields +* +* This function only operates on the
VIRTCHNL2_RXDID_1_32B_BASE_Mdrivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c
Quoted 5 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +5
-0+legacy 32byte +* descriptor writeback format. +**/ +static void +iecm_rx_singleq_base_hash(struct iecm_queue *rx_q, struct sk_buff*skb,
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c line 707
Quoted 4 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +4
-0+union virtchnl2_rx_desc *rx_desc, + struct iecm_rx_ptype_decoded *decoded) { + const __le64 rss_mask = +cpu_to_le64((u64)VIRTCHNL2_RX_BASE_DESC_FLTSTAT_RSS_HASH
Quoted 6 lines
<<
You can define
_RSS_HASHwith a 'ull' suffix to avoid casting. You can define a shorthand for this, like_RSS_HASH_LEto avoid these wraps.
Good idea, will fix.
Quoted 9 lines
Quoted 1 line
+
VIRTCHNL2_RX_BASE_DESC_STATUS_FLTSTAT_S);drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c
Quoted 6 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +6
-0+u32 hash; + +if (!(rx_q->vport->netdev->features &NETIF_F_RXHASH )) +return ; + + if ((rx_desc->base_wb.qword1.status_error_ptype_len & rss_mask)==
Quoted 4 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c line 712
Quoted 1 line
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +1
-0+ rss_mask) {This is wrong indentation, just align it to the first opening brace.
Sure will fix.
Quoted 41 lines
Quoted 4 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +1
-0+ hash = le32_to_cpu(rx_desc-base_wb.qword0.hi_dword.rss);
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +2
-0+skb_set_hash (skb, hash,iecm_ptype_to_htype (decoded)); + }drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +10
-0+} + +/** +* iecm_rx_singleq_flex_hash - set the hash value in the skb +* @rx_q: Rx completion queue +* @skb: skb currently being received and modified +* @rx_desc: specific descriptor +* @decoded: Decoded Rx packet type related fields +* +* This function only operates on the
VIRTCHNL2_RXDID_2_FLEX_SQ_NICdrivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c
Quoted 5 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +5
-0+flexible +* descriptor writeback format. +**/ +static void +iecm_rx_singleq_flex_hash(struct iecm_queue *rx_q, struct sk_buff*skb,
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c line 742
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +10
-0+union virtchnl2_rx_desc *rx_desc, + struct iecm_rx_ptype_decoded *decoded) { + __le16 status0; + +if (!(rx_q->vport->netdev->features &NETIF_F_RXHASH )) +return ; + + status0 = rx_desc->flex_nic_wb.status_error0; + if (status0 & +cpu_to_le16(BIT(VIRTCHNL2_RX_FLEX_DESC_STATUS0_RSS_VALID_S))) {
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c line 744
Quoted 4 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +4
-0+u32 hash =le32_to_cpu (rx_desc->flex_nic_wb.rss_hash); + +skb_set_hash (skb, hash,iecm_ptype_to_htype (decoded)); + }if (!status) return;
Quoted 2 lines
-1 indent level.
if (!(status0 & cpu_to_le16(BIT(VIRTCHNL2_RX_FLEX_DESC_STATUS0_RSS_VALID_S))))
return;
skb_set_hash(...);
vs.
if (status0 & cpu_to_le16(BIT(VIRTCHNL2_RX_FLEX_DESC_STATUS0_RSS_VALID_S)))
skb_set_hash(....);
Doesn't seem any better to me, in fact it seems worse.
Quoted 19 lines
Quoted 8 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +8
-0+} + +/** +* iecm_rx_singleq_process_skb_fields - Populate skb header fields +from Rx +* descriptor +* @rx_q: Rx descriptor ring packet is being transacted on +* @skb: pointer to current skb being populated drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +10
-0+* @rx_desc: descriptor for skb +* @ptype: packet type +* +* This function checks the ring, descriptor, and packet information +in +* order to populate the hash, checksum, VLAN, protocol, and +* other fields within the skb. +*/ +void +iecm_rx_singleq_process_skb_fields(struct iecm_queue *rx_q, struct
sk_buff*skb,
Quoted 8 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c line 765
Quoted 5 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +5
-0+ union virtchnl2_rx_desc *rx_desc, + u16 ptype) +{ +struct iecm_rx_ptype_decoded decoded = + rx_q->vport->rx_ptype_lkup[ptype];Declare, then assign to avoid wraps.
I'm just not seeing the benefit in doing that. If 'net' tree is concerned with wrapping I would assume they would move to 100 cols with the rest of the kernel.
Quoted 39 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c line 768
Quoted 3 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +3
-0+ +/* modifies the skb - consumes the enet header */ + skb->protocol =eth_type_trans (skb, rx_q->vport->netdev);Here applies the same I said for splitq,
eth_type_trans()should be right beforenapi_gro_receive().Quoted 4 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +4
-0+ +if (rx_q->rxdids ==VIRTCHNL2_RXDID_1_32B_BASE_M ) { +iecm_rx_singleq_base_hash (rx_q, skb, rx_desc, &decoded); +iecm_rx_singleq_base_csum (rx_q, skb, rx_desc, ptype);drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +7
-0+ }else { +iecm_rx_singleq_flex_hash (rx_q, skb, rx_desc, &decoded); +iecm_rx_singleq_flex_csum (rx_q, skb, rx_desc, ptype); + } +} +/** * iecm_rx_singleq_buf_hw_alloc_all - Replace used receive buffers * @rx_q: queue for which the hw buffers are allocated @@ -13,8 +786,410 @@ bool iecm_rx_singleq_buf_hw_alloc_all(struct
iecm_queueQuoted 17 lines
*rx_q,drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +12
-2u16 cleaned_count) { -/* stub */ -return true; +struct virtchnl2_singleq_rx_buf_desc *singleq_rx_desc =NULL ; +struct iecm_page_info *page_info; +u16 nta = rx_q->next_to_alloc; +struct iecm_rx_buf *buf; + +/* do nothing if no valid netdev defined */ +if (!rx_q->vport->netdev || !cleaned_count) +return false; + + singleq_rx_desc =IECM_SINGLEQ_RX_BUF_DESC (rx_q, nta); + buf = &rx_q->rx_buf.buf[nta]; + page_info = &buf->page_info[buf->page_indx];
Quoted 9 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c line 806
Quoted 6 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +6
-0+ + do { + if (unlikely(!page_info->page)) { + if (!iecm_init_rx_buf_hw_alloc(rx_q, buf)) + break; + }if (1 && 2)
Will fix.
Quoted 7 lines
Quoted 7 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +6
-0+ +/* Refresh the desc even if buffer_addrs didn't change +* because each write-back erases this info. +*/ + singleq_rx_desc->pkt_addr = + cpu_to_le64(page_info->dma + page_info-
page_offset);
Quoted 9 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c line 818
Quoted 6 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +6
-0+ singleq_rx_desc->hdr_addr =0 ; + singleq_rx_desc++; + + buf++; + nta++; +if (unlikely (nta == rx_q->desc_count)) {Can be squashed into ++nta == count.
Will not fix.
Quoted 13 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c
Quoted 1 line
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +1
-0+ singleq_rx_desc =
IECM_SINGLEQ_RX_BUF_DESC(rx_q, 0);drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c line 827
Quoted 8 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +8
-0+ buf = rx_q->rx_buf.buf; + nta =0 ; + } + + page_info = &buf->page_info[buf->page_indx]; + + cleaned_count--; + }while (cleaned_count);And these into
while (--cleaned_count);
We would prefer not to.
Quoted 11 lines
Quoted 11 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +11
-0+ +if (rx_q->next_to_alloc != nta) { +iecm_rx_buf_hw_update (rx_q, nta); + rx_q->next_to_alloc = nta; + } + +return !!cleaned_count; +} + +/** +* iecm_rx_reuse_page - Put recycled buffer back onto ring
Quoted 9 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c line 846
Quoted 6 lines
+ * @rxq: Rx descriptor ring to store buffers on
+ * @old_buf: donor buffer to have page reused */ static voiddrivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +4
-0+iecm_rx_reuse_page(struct iecm_queue *rxq, + struct iecm_rx_buf *old_buf) { + u16 ntu = rxq->next_to_use; +struct iecm_rx_buf *new_buf;RCTree.
Will fix.
Quoted 32 lines
Quoted 32 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +9
-0+ + new_buf = &rxq->rx_buf.buf[ntu]; + +/* Transfer page from old buffer to new buffer. Move each member +* individually to avoid possible store forwarding stalls and +* unnecessary copy of skb. +*/ + new_buf->page_info[new_buf->page_indx].dma = + old_buf->page_info[old_buf-page_indx].dma;
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +2
-0+ new_buf->page_info[new_buf->page_indx].page = + old_buf->page_info[old_buf-page_indx].page;
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +2
-0+ new_buf->page_info[new_buf->page_indx].page_offset = + old_buf->page_info[old_buf-page_indx].page_offset;
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +2
-0+ new_buf->page_info[new_buf->page_indx].pagecnt_bias = + old_buf->page_info[old_buf-page_indx].pagecnt_bias;
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +13
-0+} + +/** +* iecm_rx_singleq_recycle_buf - Clean up used buffer and either +recycle or free +* @rxq: Rx descriptor queue to transact packets on +* @rx_buf: Rx buffer to pull data from +* +* This function will clean up the contents of the rx_buf. It will +either +* recycle the buffer or unmap it and free the associated resources. +* +* Returns true if the buffer is reused, false if the buffer is freed.
Quoted 9 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c line 878
Quoted 6 lines
+ */
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +5
-0+static bool iecm_rx_singleq_recycle_buf (struct iecm_queue *rxq, +struct iecm_rx_buf *rx_buf) +{ +struct iecm_page_info *page_info = + &rx_buf->page_info[rx_buf->page_indx];Declare, then assign to avoid wraps.
Will not fix.
Quoted 4 lines
Quoted 1 line
+
No empty lines between declarations.
Will fix
Quoted 236 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c
Quoted 9 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +9
-0+bool recycled = false; + +if (iecm_rx_can_reuse_page (rx_buf)) { +/* hand second half of page back to the queue */ +iecm_rx_reuse_page (rxq, rx_buf); + recycled = true; + }else { +/* we are not reusing the buffer so unmap it */ + dma_unmap_page_attrs(rxq->dev, page_info->dma,
PAGE_SIZE,drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c
Quoted 1 line
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +1
-0+ DMA_FROM_DEVICE,
IECM_RX_DMA_ATTR);Quoted 52 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +52
-0+__page_frag_cache_drain (page_info->page, + page_info->pagecnt_bias); + } + +/* clear contents of buffer_info */ + page_info->page =NULL ; + rx_buf->skb =NULL ; + +return recycled; +} + +/** +* iecm_rx_singleq_put_buf - Wrapper function to clean and recycle +buffers +* @rxq: Rx descriptor queue to transact packets on +* @rx_buf: Rx buffer to pull data from +* +* This function will update the next_to_use/next_to_alloc if the +current +* buffer is recycled. +*/ +static void iecm_rx_singleq_put_buf (struct iecm_queue *rxq, +struct iecm_rx_buf *rx_buf) +{ +u16 ntu = rxq->next_to_use; +bool recycled = false; + + recycled =iecm_rx_singleq_recycle_buf (rxq, rx_buf); + +/* update, and store next to alloc if the buffer was recycled */ +if (recycled) { + ntu++; + rxq->next_to_use = (ntu < rxq->desc_count) ? ntu :0 ; + } +} + +/** +* iecm_rx_singleq_bump_ntc - Bump and wrap q->next_to_clean value +* @rxq: queue to bump +*/ +void iecm_rx_singleq_bump_ntc (struct iecm_queue *rxq) { +u16 ntc = rxq->next_to_clean +1 ; +/* fetch, update, and store next to clean */ +if (ntc < rxq->desc_count) + rxq->next_to_clean = ntc; +else + rxq->next_to_clean =0 ; +} + +/** +* iecm_rx_singleq_get_buf_page - Fetch Rx buffer page and +synchronize data drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +10
-0+* @dev: device struct +* @rx_buf: Rx buf to fetch page for +* @size: size of buffer to add to skb +* +* This function will pull an Rx buffer page from the ring and +synchronize it +* for use by the CPU. +*/ +static struct sk_buff * +iecm_rx_singleq_get_buf_page(struct device *dev, struct iecm_rx_buf
*rx_buf,Quoted 20 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +20
-0+ const unsigned int size) +{ +struct iecm_page_info *page_info; + + page_info = &rx_buf->page_info[rx_buf->page_indx]; +prefetch (page_info->page); + +/* we are reusing so sync this buffer for CPU use */ +dma_sync_single_range_for_cpu (dev, page_info->dma, + page_info->page_offset, size, +DMA_FROM_DEVICE ); + +/* We have pulled a buffer for use, so decrement pagecnt_bias */ + page_info->pagecnt_bias--; + +return rx_buf->skb; +} + +/** +* iecm_rx_singleq_extract_base_fields - Extract fields from the Rx drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +10
-0+descriptor + * @rx_q: Rx descriptor queue + * @rx_desc: the descriptor to process + * @fields: storage for extracted values + * + * Decode the Rx descriptor and extract relevant information +including the + * size, VLAN tag, and Rx packet type. + * + * This function only operates on the
VIRTCHNL2_RXDID_1_32B_BASE_MQuoted 11 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +10
-0+legacy 32byte +* descriptor writeback format. +*/ +static inline void +iecm_rx_singleq_extract_base_fields (struct iecm_queue *rx_q, +union virtchnl2_rx_desc *rx_desc, +struct iecm_rx_extracted *fields) { +u64 qw2_status, qword; + + qword = le64_to_cpu(rx_desc-base_wb.qword1.status_error_ptype_len);
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c
Quoted 3 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +3
-0+ qw2_status =le16_to_cpu (rx_desc->base_wb.qword2.ext_status); + + fields->size = (qword &
VIRTCHNL2_RX_BASE_DESC_QW1_LEN_PBUF_M) >>Quoted 1 line
+
VIRTCHNL2_RX_BASE_DESC_QW1_LEN_PBUF_S;drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c
Quoted 1 line
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +1
-0+ fields->rx_ptype = (qword &
VIRTCHNL2_RX_BASE_DESC_QW1_PTYPE_M) >>Quoted 1 line
+
VIRTCHNL2_RX_BASE_DESC_QW1_PTYPE_S;drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c
Quoted 2 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +2
-0+ + if (qword & BIT(VIRTCHNL2_RX_BASE_DESC_STATUS_L2TAG1P_S)&&
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c
Quoted 5 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +3
-0+ test_bit(__IECM_Q_VLAN_TAG_LOC_L2TAG1, rx_q->flags)) + fields->vlan_tag = + le16_to_cpu(rx_desc-base_wb.qword0.lo_dword.l2tag1);
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +1
-0+ if (qw2_status &
BIT(VIRTCHNL2_RX_BASE_DESC_EXT_STATUS_L2TAG2P_S)&&Quoted 7 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +7
-0+ test_bit(__IECM_Q_VLAN_TAG_LOC_L2TAG2, rx_q->flags)) + fields->vlan_tag = +le16_to_cpu (rx_desc->base_wb.qword2.l2tag2_1); +} + +/** +* iecm_rx_singleq_extract_flex_fields - Extract fields from the Rx drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +10
-0+descriptor + * @rx_q: Rx descriptor queue + * @rx_desc: the descriptor to process + * @fields: storage for extracted values + * + * Decode the Rx descriptor and extract relevant information +including the + * size, VLAN tag, and Rx packet type. + * + * This function only operates on the
VIRTCHNL2_RXDID_2_FLEX_SQ_NICdrivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c line 1027
Quoted 11 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +11
-0+flexible +* descriptor writeback format. +*/ +static inline void +iecm_rx_singleq_extract_flex_fields (struct iecm_queue *rx_q, +union virtchnl2_rx_desc *rx_desc, +struct iecm_rx_extracted *fields) { +__le16 status0, status1; + + fields->size = le16_to_cpu(rx_desc->flex_nic_wb.pkt_len) & +VIRTCHNL2_RX_FLEX_DESC_PKT_LEN_M;Quoted 3 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +1
-0+ fields->rx_ptype = le16_to_cpu(rx_desc-flex_nic_wb.ptype_flex_flags0) &
+VIRTCHNL2_RX_FLEX_DESC_PTYPE_M;drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c line 739
Quoted 3 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +3
-0+ + status0 = rx_desc->flex_nic_wb.status_error0; + if (status0 &cpu_to_le16(BIT(VIRTCHNL2_RX_FLEX_DESC_STATUS0_L2TAG1P_S)) &&
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c
Quoted 6 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +2
-0+ test_bit(__IECM_Q_VLAN_TAG_LOC_L2TAG1, rx_q->flags)) + fields->vlan_tag = le16_to_cpu(rx_desc-flex_nic_wb.l2tag1);
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +3
-0+ + status1 = rx_desc->flex_nic_wb.status_error1; + if (status1 &cpu_to_le16(BIT(VIRTCHNL2_RX_FLEX_DESC_STATUS1_L2TAG2P_S)) &&
Quoted 32 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +2
-0+ test_bit(__IECM_Q_VLAN_TAG_LOC_L2TAG2, rx_q->flags)) + fields->vlan_tag = le16_to_cpu(rx_desc-flex_nic_wb.l2tag2_2nd);
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +29
-0+} + +/** +* iecm_rx_singleq_extract_fields - Extract fields from the Rx +descriptor +* @rx_q: Rx descriptor queue +* @rx_desc: the descriptor to process +* @fields: storage for extracted values +* +*/ +void +iecm_rx_singleq_extract_fields (struct iecm_queue *rx_q, +union virtchnl2_rx_desc *rx_desc, +struct iecm_rx_extracted *fields) { +if (rx_q->rxdids ==VIRTCHNL2_RXDID_1_32B_BASE_M ) +iecm_rx_singleq_extract_base_fields (rx_q, rx_desc, fields); +else +iecm_rx_singleq_extract_flex_fields (rx_q, rx_desc, fields); } + +/** +* iecm_rx_singleq_clean - Reclaim resources after receive completes +* @rx_q: rx queue to clean +* @budget: Total limit on number of packets to process +* +* Returns true if there's any budget left (e.g. the clean is +finished) */ static int iecm_rx_singleq_clean (struct iecm_queue +*rx_q,int budget) { +unsigned int total_rx_bytes =0 , total_rx_pkts =0 ;Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c line 1076
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +10
-0+u16 cleaned_count =0 ; +bool failure = false; + +/* Process Rx packets bounded by budget */ +while (likely (total_rx_pkts < (unsigned int )budget)) { +struct iecm_rx_extracted fields = {}; +union virtchnl2_rx_desc *rx_desc; +struct sk_buff *skb =NULL ; +struct iecm_rx_buf *rx_buf; +*/
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c
Quoted 11 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +11
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
be
Quoted 6 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c
Quoted 3 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +3
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Should be moved from here as well.
242 lines not shown · raw message
Parts of this message are not shown here. View the raw message.
PATCH 14/19 iecm: implement singleq napi_poll
From: Alan Brady <[email protected]>
Date: Thu, 3 Feb 2022 02:45:14 +0100
Quoted 24 lines
Quoted 24 lines
-----Original Message-----
From: Lobakin, Alexandr <[email protected]>
Sent: Friday, January 28, 2022 9:58 AM
To: Brady, Alan <[email protected]>
Cc: Lobakin, Alexandr <[email protected]>; intel-wired- lan at lists.osuosl.org; Burra, Phani R <[email protected]>; Chittim, Madhu <[email protected]>; Linga, Pavan Kumar <[email protected]>
Subject: [Intel-wired-lan] [PATCH net-next 14/19] iecm: implement singleqnapi_pollQuoted 13 lines
From: Alan Brady <[email protected]>
Date: Thu, 27 Jan 2022 16:10:04 -0800This adds everything we do the more traditional singleq model data path.
Signed-off-by Phani Burra <[email protected]>Signed-off-by Joshua Hay <[email protected]>Signed-off-by Madhu Chittim <[email protected]>Signed-off-by Pavan Kumar Linga <[email protected]>Signed-off-by Alan Brady <[email protected]>--- drivers/net/ethernet/intel/iecm/iecm_lib.c | 2 +- .../ethernet/intel/iecm/iecm_singleq_txrx.c | 1208
Quoted 5 lines
Quoted 5 lines
++++++++++++++++-
Quoted 4 lines
drivers/net/ethernet/intel/include/iecm.h | 1 + .../net/ethernet/intel/include/iecm_txrx.h | 31 + 4 files changed, 1237 insertions(+), 5 deletions(-)
--- 8< ---
Quoted 7 lines
Quoted 5 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c line 164
Quoted 2 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +2
-0+/* align size to end of page */ + max_data += -dma & (IECM_TX_MAX_READ_REQ_SIZE -1 );Here applies the same I said for splitq before, this code is counter-intuitive.
I'm failing to find a matching comment for
iecm_tx_splitq_mapbut I'm sure we're open to suggestion how to make it better.
As I said in my reply to 11/19, I don't get the logics here at all, so I kindly asked to explain it to me.
Since I don't get it, I'm not able to provide any suggestions.
Quoted 2 lines
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +1
-0+ tx_desc->buf_addr = cpu_to_le64(dma);
--- 8< ---
Quoted 11 lines
Quoted 9 lines
Quoted 4 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +3
-0+ do { + struct iecm_base_tx_desc *eop_desc = + (struct iecm_base_tx_desc *)tx_buf-
next_to_watch;struct iecm_base_tx_desc *eop_desc; eop_desc = (typeof(*eop_desc))tx_buf->next_to_watch;Again not sure I see the benefit to prefer assigning it's own line over letting it wrap. Suggestion as written is wrong also.
Declaration, then assignment is a normal practice. Assignment with a line-wrap is an exception only for the lines which can't be composed any other way. Here you have at least two:
struct iecm_base_tx_desc *eop_desc; /* This is fixed variant from my initial reply, I apologize * for the excessive '*'. */ eop_desc = (typeof(eop_desc))tx_buf->next_to_watch; /* More classic variant, fits into 79 as well */ eop_desc = (struct iecm_base_tx_desc *)tx_buf->next_to_watch;
Breaking declaration and assignment into two separate lines is the first choice when a line exceeds the char limit.
Quoted 3 lines
Quoted 3 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c line 379
Quoted 3 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +2
-0+ +/* if next_to_watch is not set then no work pending */
--- 8< ---
Quoted 13 lines
Quoted 13 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c line 742
Quoted 3 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +3
-0+ status0 = rx_desc->flex_nic_wb.status_error0; + if (status0 & +cpu_to_le16(BIT(VIRTCHNL2_RX_FLEX_DESC_STATUS0_RSS_VALID_S))) {
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c line 744
Quoted 4 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +4
-0+u32 hash =le32_to_cpu (rx_desc->flex_nic_wb.rss_hash); + +skb_set_hash (skb, hash,iecm_ptype_to_htype (decoded)); + }if (!status) return;
Quoted 7 lines
Quoted 2 lines
-1 indent level.
if (!(status0 & cpu_to_le16(BIT(VIRTCHNL2_RX_FLEX_DESC_STATUS0_RSS_VALID_S))))
return;
skb_set_hash(...);
hash =skb_set_hash()
There are two lines there.
Quoted 7 lines
vs.
if (status0 & cpu_to_le16(BIT(VIRTCHNL2_RX_FLEX_DESC_STATUS0_RSS_VALID_S)))
skb_set_hash(....);Doesn't seem any better to me, in fact it seems worse.
Perhaps due to that train starting from cpu_to_le16 should be hidden into a compact definition, like
#define IECM_RX_DESC_HASH_BIT \ BIT(VIRTCHNL2_RX_FLEX_DESC_STATUS0_RSS_VALID_S)));
#define __iecm_rx_desc_hash_present(status0) \ !!((status0) & cpu_to_le16(IECM_RX_DESC_HASH_BIT))
#define iecm_rx_desc_hash_present(rx_desc) \ __iecm_rx_desc_hash_present((rx_desc)->flex_nic_wb.status_error0)
...
then either way (if (hash) or if (!hash)) starts working.
if (!(rx_q->vport->netdev->features & NETIF_F_RXHASH))
return;
if (iecm_rx_desc_hash_present(rx_desc)) {
u32 hash = le32_to_cpu(rx_desc->flex_nic_wb.rss_hash);
skb_set_hash(skb, hash, iecm_ptype_to_htype(decoded));
}||
if (!(rx_q->vport->netdev->features & NETIF_F_RXHASH) || !iecm_rx_desc_hash_present(rx_desc)) return; hash = le32_to_cpu(rx_desc->flex_nic_wb.rss_hash); skb_set_hash(skb, hash, iecm_ptype_to_htype(decoded));
Quoted 5 lines
Quoted 5 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c
Quoted 5 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +4
-0+} + +/** +* iecm_rx_singleq_process_skb_fields - Populate skb header fields
--- 8< ---
Quoted 12 lines
Quoted 11 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+void +iecm_rx_singleq_process_skb_fields(struct iecm_queue *rx_q, struct
sk_buff*skb,drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c line 765
Quoted 5 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +5
-0+ union virtchnl2_rx_desc *rx_desc, + u16 ptype) +{ +struct iecm_rx_ptype_decoded decoded = + rx_q->vport->rx_ptype_lkup[ptype];Declare, then assign to avoid wraps.
Quoted 1 line
I'm just not seeing the benefit in doing that. If 'net' tree is concerned with wrapping I would assume they would move to 100 cols with the rest of the kernel.
Everyone is concerned with wrapping.
But one thing is to have a function call wrapped by arguments:
ret = some_long_function_name(argument1, ARG2);
and completely different -- line breaks, when no alignment is possible:
some_really_long_variable = some_long_function_name();
At least I can tell for sure that declaration + assignment is way more preferred over such line breaks for not altering readability in any way.
Quoted 3 lines
Quoted 3 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c line 767
Quoted 3 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +2
-0+ +/* modifies the skb - consumes the enet header */
--- 8< ---
Quoted 10 lines
Quoted 8 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c line 878
Quoted 5 lines
drivers/net/ethernet/intel/iecm/iecm_singleq_txrx.c +5
-0+static bool iecm_rx_singleq_recycle_buf (struct iecm_queue *rxq, +struct iecm_rx_buf *rx_buf) +{ +struct iecm_page_info *page_info = + &rx_buf->page_info[rx_buf->page_indx];Declare, then assign to avoid wraps.
Will not fix.
The very same questions may come from the upstream maintainers. The less such trivial places there will be, the better for everyone I believe? Especially for the maintainers since they review tons of code daily and aren't happy to see simple style issues again and again.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
+
--- 8< ---
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
--
2.33.0Thanks,
Al
Thanks,
Al
PATCH 15/19 iecm: implement ethtool callbacks
In reply to Alan BradyThis does everything needed to handle ethtool ops minus a few stubs for cloud filters and other advanced features which will be added in later in this series.
--- drivers/net/ethernet/intel/iecm/Makefile | 1 + .../net/ethernet/intel/iecm/iecm_ethtool.c | 1325 +++++++++++++++++ drivers/net/ethernet/intel/iecm/iecm_lib.c | 11 +- drivers/net/ethernet/intel/include/iecm.h | 1 + 4 files changed, 1337 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ethernet/intel/iecm/iecm_ethtool.c
drivers/net/ethernet/intel/iecm/Makefile +1 -0
@@ -15,6 +15,7 @@ iecm-y := \ iecm_virtchnl.o \ iecm_txrx.o \ iecm_singleq_txrx.o \ + iecm_ethtool.o \ iecm_controlq.o \ iecm_controlq_setup.o \ iecm_main.o
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +1325 -0
1,325 lines not on this page · raw message
drivers/net/ethernet/intel/iecm/iecm_lib.c +10 -1
@@ -871,6 +871,7 @@ static int iecm_cfg_netdev(struct iecm_vport *vport) netdev->hw_features |= dflt_features | offloads; netdev->hw_enc_features |= dflt_features | offloads; +iecm_set_ethtool_ops (netdev);SET_NETDEV_DEV (netdev, &adapter->pdev->dev);/* carrier off on init to avoid Tx hangs */
@@ -1150,7 +1151,15 @@ iecm_vport_alloc(struct iecm_adapter *adapter, int vport_id)*/ static void iecm_statistics_task (struct work_struct *work) { -/* stub */ +struct iecm_adapter *adapter =container_of (work, + struct iecm_adapter, + stats_task.work); +if (test_bit (__IECM_MB_STATS_PENDING, adapter->flags) && + !test_bit (__IECM_HR_RESET_IN_PROG, adapter->flags)) + adapter->dev_ops.vc_ops.get_stats_msg (adapter->vports[0 ]); + +queue_delayed_work (adapter->stats_wq, &adapter->stats_task, +msecs_to_jiffies (1000 )); }/**
drivers/net/ethernet/intel/include/iecm.h +1 -0
@@ -745,6 +745,7 @@ int iecm_recv_mb_msg(struct iecm_adapter *adapter, enum virtchnl_ops op, void *msg, int msg_size);int iecm_send_mb_msg (struct iecm_adapter *adapter,enum virtchnl_ops op,u16 msg_size,u8 *msg); +void iecm_set_ethtool_ops (struct net_device *netdev);void iecm_vport_set_hsplit (struct iecm_vport *vport,bool ena);void iecm_add_del_ether_addrs (struct iecm_vport *vport,bool add,bool async);int iecm_set_promiscuous (struct iecm_adapter *adapter);
Signature · 1 line
2.33.0
PATCH 15/19 iecm: implement ethtool callbacks
From: Alan Brady <[email protected]>
Date: Thu, 27 Jan 2022 16:10:05 -0800
Quoted 40 lines
This does everything needed to handle ethtool ops minus a few stubs for cloud filters and other advanced features which will be added in later in this series.
Signed-off-by Phani Burra <[email protected]>Signed-off-by Joshua Hay <[email protected]>Signed-off-by Madhu Chittim <[email protected]>Signed-off-by Pavan Kumar Linga <[email protected]>Signed-off-by Alan Brady <[email protected]>--- drivers/net/ethernet/intel/iecm/Makefile | 1 + .../net/ethernet/intel/iecm/iecm_ethtool.c | 1325 +++++++++++++++++ drivers/net/ethernet/intel/iecm/iecm_lib.c | 11 +- drivers/net/ethernet/intel/include/iecm.h | 1 + 4 files changed, 1337 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ethernet/intel/iecm/iecm_ethtool.cdrivers/net/ethernet/intel/iecm/Makefile +1
-0@@ -15,6 +15,7 @@ iecm-y := \ iecm_virtchnl.o \ iecm_txrx.o \ iecm_singleq_txrx.o \ + iecm_ethtool.o \ iecm_controlq.o \ iecm_controlq_setup.o \ iecm_main.odrivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +5
-0@@ -0,0 +1,1325 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* Copyright (C) 2019 Intel Corporation */ + +#include "iecm.h" +
drivers/net/ethernet/intel/iecm/iecm_ethtool.c line 15
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +10
-0+/** +* iecm_get_rxnfc - command to get RX flow classification rules +* @netdev: network interface device structure +* @cmd: ethtool rxnfc command +* @rule_locs: pointer to store rule locations +* +* Returns Success if the command is supported. +*/ +static int iecm_get_rxnfc (struct net_device *netdev,struct ethtool_rxnfc *cmd, +u32 __always_unused *rule_locs)
Kernel Kbuild system tell compilers to not complain on unused function arguments.
It's pointless to add __always_unused here.
Quoted 63 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +63
-0+{ +struct iecm_vport *vport =iecm_netdev_to_vport (netdev); +int ret = -EOPNOTSUPP ; + +switch (cmd->cmd) { +case ETHTOOL_GRXRINGS : + cmd->data = vport->num_rxq; + ret =0 ; +break ; +case ETHTOOL_GRXCLSRLCNT : +/* stub */ + ret =0 ; +break ; +case ETHTOOL_GRXCLSRULE : +/* stub */ +break ; +case ETHTOOL_GRXCLSRLALL : +/* stub */ +break ; +case ETHTOOL_GRXFH : +/* stub */ +break ; +default : +break ; + } + +return ret; +} + +/** +* iecm_set_rxnfc - command to set Rx flow rules. +* @netdev: network interface device structure +* @cmd: ethtool rxnfc command +* +* Returns 0 for success and negative values for errors +*/ +static int iecm_set_rxnfc (struct net_device *netdev,struct ethtool_rxnfc *cmd) +{ +int ret = -EOPNOTSUPP ; + +switch (cmd->cmd) { +case ETHTOOL_SRXCLSRLINS : +/* stub */ +break ; +case ETHTOOL_SRXCLSRLDEL : +/* stub */ +break ; +case ETHTOOL_SRXFH : +/* stub */ +break ; +default : +break ; + } + +return ret; +} + +/** +* iecm_get_rxfh_key_size - get the RSS hash key size +* @netdev: network interface device structure +* +* Returns the table size. +*/
drivers/net/ethernet/intel/iecm/iecm_ethtool.c line 88
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +10
-0+static u32 iecm_get_rxfh_key_size (struct net_device *netdev) +{ +struct iecm_vport *vport =iecm_netdev_to_vport (netdev); + +if (!iecm_is_cap_ena_all (vport->adapter,IECM_RSS_CAPS ,IECM_CAP_RSS )) { +dev_info (&vport->adapter->pdev->dev,"RSS is not supported on this device\n" ); +return 0 ; + } + +return vport->adapter->rss_data.rss_key_size;
If you invert the condition, it would take less lines.
Quoted 8 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +8
-0+} + +/** +* iecm_get_rxfh_indir_size - get the rx flow hash indirection table size +* @netdev: network interface device structure +* +* Returns the table size. +*/
drivers/net/ethernet/intel/iecm/iecm_ethtool.c line 106
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +10
-0+static u32 iecm_get_rxfh_indir_size (struct net_device *netdev) +{ +struct iecm_vport *vport =iecm_netdev_to_vport (netdev); + +if (!iecm_is_cap_ena_all (vport->adapter,IECM_RSS_CAPS ,IECM_CAP_RSS )) { +dev_info (&vport->adapter->pdev->dev,"RSS is not supported on this device\n" ); +return 0 ; + } + +return vport->adapter->rss_data.rss_lut_size;
Same here.
Quoted 146 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +146
-0+} + +/** +* iecm_get_rxfh - get the rx flow hash indirection table +* @netdev: network interface device structure +* @indir: indirection table +* @key: hash key +* @hfunc: hash function in use +* +* Reads the indirection table directly from the hardware. Always returns 0. +*/ +static int iecm_get_rxfh (struct net_device *netdev,u32 *indir,u8 *key, +u8 *hfunc) +{ +struct iecm_vport *vport =iecm_netdev_to_vport (netdev); +struct iecm_adapter *adapter; +u16 i; + + adapter = vport->adapter; + +if (!iecm_is_cap_ena_all (adapter,IECM_RSS_CAPS ,IECM_CAP_RSS )) { +dev_info (&vport->adapter->pdev->dev,"RSS is not supported on this device\n" ); +return 0 ; + } + +if (adapter->state != __IECM_UP) +return 0 ; + +if (hfunc) + *hfunc =ETH_RSS_HASH_TOP ; + +if (key) +memcpy (key, adapter->rss_data.rss_key, + adapter->rss_data.rss_key_size); + +if (indir) +/* Each 32 bits pointed by 'indir' is stored with a lut entry */ +for (i =0 ; i < adapter->rss_data.rss_lut_size; i++) + indir[i] = adapter->rss_data.rss_lut[i]; + +return 0 ; +} + +/** +* iecm_set_rxfh - set the rx flow hash indirection table +* @netdev: network interface device structure +* @indir: indirection table +* @key: hash key +* @hfunc: hash function to use +* +* Returns -EINVAL if the table specifies an invalid queue id, otherwise +* returns 0 after programming the table. +*/ +static int iecm_set_rxfh (struct net_device *netdev,const u32 *indir, +const u8 *key,const u8 hfunc) +{ +struct iecm_vport *vport =iecm_netdev_to_vport (netdev); +struct iecm_adapter *adapter; +u16 lut; + + adapter = vport->adapter; + +if (!iecm_is_cap_ena_all (adapter,IECM_RSS_CAPS ,IECM_CAP_RSS )) { +dev_info (&adapter->pdev->dev,"RSS is not supported on this device\n" ); +return 0 ; + } +if (adapter->state != __IECM_UP) +return 0 ; +if (hfunc !=ETH_RSS_HASH_NO_CHANGE && hfunc !=ETH_RSS_HASH_TOP ) +return -EOPNOTSUPP ; + +if (key) +memcpy (adapter->rss_data.rss_key, key, + adapter->rss_data.rss_key_size); + +if (indir) { +for (lut =0 ; lut < adapter->rss_data.rss_lut_size; lut++) + adapter->rss_data.rss_lut[lut] = indir[lut]; + } + +return iecm_config_rss (vport); +} + +/** +* iecm_get_channels: get the number of channels supported by the device +* @netdev: network interface device structure +* @ch: channel information structure +* +* Report maximum of TX and RX. Report one extra channel to match our MailBox +* Queue. +*/ +static void iecm_get_channels (struct net_device *netdev, +struct ethtool_channels *ch) +{ +struct iecm_vport *vport =iecm_netdev_to_vport (netdev); +unsigned int combined; +int num_txq, num_rxq; + + num_txq = vport->adapter->config_data.num_req_tx_qs; + num_rxq = vport->adapter->config_data.num_req_rx_qs; + + combined =min (num_txq, num_rxq); + +/* Report maximum channels */ + ch->max_combined = vport->adapter->max_queue_limit; + +/* For now we've only enabled combined queues but will be enabling +* asymmetric queues after splitq model is fleshed out more. +*/ + ch->max_rx =0 ; + ch->max_tx =0 ; + + ch->max_other =IECM_MAX_NONQ ; + ch->other_count =IECM_MAX_NONQ ; + + ch->combined_count = combined; + ch->rx_count = num_rxq - combined; + ch->tx_count = num_txq - combined; +} + +/** +* iecm_set_channels: set the new channel count +* @netdev: network interface device structure +* @ch: channel information structure +* +* Negotiate a new number of channels with CP. Returns 0 on success, negative +* on failure. +*/ +static int iecm_set_channels (struct net_device *netdev, +struct ethtool_channels *ch) +{ +unsigned int num_req_tx_q = ch->combined_count + ch->tx_count; +unsigned int num_req_rx_q = ch->combined_count + ch->rx_count; +struct iecm_vport *vport =iecm_netdev_to_vport (netdev); +struct iecm_adapter *adapter = vport->adapter; +int num_txq, num_rxq, err; + +if (num_req_tx_q ==0 || num_req_rx_q ==0 ) +return -EINVAL ; + + num_txq = vport->adapter->config_data.num_req_tx_qs; + num_rxq = vport->adapter->config_data.num_req_rx_qs; + +if (num_req_tx_q == num_txq && num_req_rx_q == num_rxq) +return 0 ; +
drivers/net/ethernet/intel/iecm/iecm_ethtool.c line 262
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +10
-0+ vport->adapter->config_data.num_req_tx_qs = num_req_tx_q; + vport->adapter->config_data.num_req_rx_qs = num_req_rx_q; + +if (adapter->virt_ver_maj <VIRTCHNL_VERSION_MAJOR_2 ) { + err = adapter->dev_ops.vc_ops.add_queues (vport, + num_req_tx_q,0 , + num_req_rx_q,0 ); + }else { + err =iecm_initiate_soft_reset (vport, __IECM_SR_Q_CHANGE); + }
One-liners, no need for braces.
Quoted 14 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +14
-0+ +if (err) { +/* roll back queue change */ + vport->adapter->config_data.num_req_tx_qs = num_txq; + vport->adapter->config_data.num_req_rx_qs = num_rxq; + } + +return err; +} + +/** +* iecm_get_ringparam - Get ring parameters +* @netdev: network interface device structure +* @ring: ethtool ringparam structure
drivers/net/ethernet/intel/iecm/iecm_ethtool.c line 286
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +10
-0+* @kring: unused +* @ext_ack: unused +* +* Returns current ring parameters. TX and RX rings are reported separately, +* but the number of rings is not reported. +*/ +static void iecm_get_ringparam (struct net_device *netdev, +struct ethtool_ringparam *ring, +__always_unused struct kernel_ethtool_ringparam *kring, +__always_unused struct netlink_ext_ack *ext_ack)
Same here for __always_unused. +lines longer than 79.
Quoted 13 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +13
-0+{ +struct iecm_vport *vport =iecm_netdev_to_vport (netdev); + + ring->rx_max_pending =IECM_MAX_RXQ_DESC ; + ring->tx_max_pending =IECM_MAX_TXQ_DESC ; + ring->rx_pending = vport->rxq_desc_count; + ring->tx_pending = vport->txq_desc_count; +} + +/** +* iecm_set_ringparam - Set ring parameters +* @netdev: network interface device structure +* @ring: ethtool ringparam structure
drivers/net/ethernet/intel/iecm/iecm_ethtool.c line 309
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +10
-0+* @kring: unused +* @ext_ack: unused +* +* Sets ring parameters. TX and RX rings are controlled separately, but the +* number of rings is not specified, so all rings get the same settings. +*/ +static int iecm_set_ringparam (struct net_device *netdev, +struct ethtool_ringparam *ring, +__always_unused struct kernel_ethtool_ringparam *kring, +__always_unused struct netlink_ext_ack *ext_ack)
Same.
Quoted 101 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +101
-0+{ +struct iecm_vport *vport =iecm_netdev_to_vport (netdev); +u32 new_rx_count, new_tx_count; +int i; + +if (iecm_is_queue_model_split (vport->rxq_model)) +/* When in splitq mode, any one RXQ needs to contain enough +* descriptors to service the 2 buffer queues associated with +* it. Since each buffer queue must be a multiple of 32, the +* RXQ then needs to be a multiple of 64 to be divided into +* multiples of 32 for each buffer queue +*/ + new_rx_count =ALIGN (ring->rx_pending, +IECM_REQ_SPLITQ_RXQ_DESC_MULTIPLE ); +else + new_rx_count =ALIGN (ring->rx_pending,IECM_REQ_DESC_MULTIPLE ); + + new_tx_count =ALIGN (ring->tx_pending,IECM_REQ_DESC_MULTIPLE ); + +/* if nothing to do return success */ +if (new_tx_count == vport->txq_desc_count && + new_rx_count == vport->rxq_desc_count) +return 0 ; + + vport->adapter->config_data.num_req_txq_desc = new_tx_count; + vport->adapter->config_data.num_req_rxq_desc = new_rx_count; + +/* Since we adjusted the RX completion queue count, the RX buffer queue +* descriptor count needs to be adjusted as well +*/ +for (i =0 ; i < vport->num_bufqs_per_qgrp; i++) + vport->bufq_desc_count[i] = +IECM_RX_BUFQ_DESC_COUNT (new_rx_count, + vport->num_bufqs_per_qgrp); + +return iecm_initiate_soft_reset (vport, __IECM_SR_Q_DESC_CHANGE); +} + +/** +* struct iecm_stats - definition for an ethtool statistic +* @stat_string: statistic name to display in ethtool -S output +* @sizeof_stat: the sizeof() the stat, must be no greater than sizeof(u64) +* @stat_offset: offsetof() the stat from a base pointer +* +* This structure defines a statistic to be added to the ethtool stats buffer. +* It defines a statistic as offset from a common base pointer. Stats should +* be defined in constant arrays using the IECM_STAT macro, with every element +* of the array using the same _type for calculating the sizeof_stat and +* stat_offset. +* +* The @sizeof_stat is expected to be sizeof(u8), sizeof(u16), sizeof(u32) or +* sizeof(u64). Other sizes are not expected and will produce a WARN_ONCE from +* the iecm_add_ethtool_stat() helper function. +* +* The @stat_string is interpreted as a format string, allowing formatted +* values to be inserted while looping over multiple structures for a given +* statistics array. Thus, every statistic string in an array should have the +* same type and number of format specifiers, to be formatted by variadic +* arguments to the iecm_add_stat_string() helper function. +*/ +struct iecm_stats { +char stat_string[ETH_GSTRING_LEN ]; +int sizeof_stat; +int stat_offset; +}; + +/* Helper macro to define an iecm_stat structure with proper size and type. +* Use this when defining constant statistics arrays. Note that @_type expects +* only a type name and is used multiple times. +*/ +#define IECM_STAT (_type, _name, _stat) { \ + .stat_string = _name, \ + .sizeof_stat = sizeof_field(_type, _stat), \ + .stat_offset = offsetof(_type, _stat) \ +} + +/* Helper macro for defining some statistics related to queues */ +#define IECM_QUEUE_STAT (_name, _stat) \ + IECM_STAT(struct iecm_queue, _name, _stat) + +/* Stats associated with a Tx queue */ +static const struct iecm_stats iecm_gstrings_tx_queue_stats[] = { +IECM_QUEUE_STAT ("packets" , q_stats.tx.packets), +IECM_QUEUE_STAT ("bytes" , q_stats.tx.bytes), +IECM_QUEUE_STAT ("lso_pkts" , q_stats.tx.lso_pkts), +}; + +/* Stats associated with an Rx queue */ +static const struct iecm_stats iecm_gstrings_rx_queue_stats[] = { +IECM_QUEUE_STAT ("packets" , q_stats.rx.packets), +IECM_QUEUE_STAT ("bytes" , q_stats.rx.bytes), +IECM_QUEUE_STAT ("rsc_pkts" , q_stats.rx.rsc_pkts), +}; + +#define IECM_TX_QUEUE_STATS_LEN ARRAY_SIZE(iecm_gstrings_tx_queue_stats) +#define IECM_RX_QUEUE_STATS_LEN ARRAY_SIZE(iecm_gstrings_rx_queue_stats) + +#define IECM_PORT_STAT (_name, _stat) \ + IECM_STAT(struct iecm_vport, _name, _stat) + +static const struct iecm_stats iecm_gstrings_port_stats[] = {
drivers/net/ethernet/intel/iecm/iecm_ethtool.c line 420
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +10
-0+IECM_PORT_STAT ("port-rx-csum_errors" , port_stats.rx_hw_csum_err), +IECM_PORT_STAT ("port-rx-hsplit" , port_stats.rx_hsplit), +IECM_PORT_STAT ("port-rx-hsplit_hbo" , port_stats.rx_hsplit_hbo), +IECM_PORT_STAT ("tx-linearized_pkts" , port_stats.tx_linearize), +IECM_PORT_STAT ("rx-bad_descs" , port_stats.rx_bad_descs), +IECM_PORT_STAT ("port-rx_bytes" , port_stats.eth_stats.rx_bytes), +IECM_PORT_STAT ("port-rx-unicast_pkts" , port_stats.eth_stats.rx_unicast), +IECM_PORT_STAT ("port-rx-multicast_pkts" , port_stats.eth_stats.rx_multicast), +IECM_PORT_STAT ("port-rx-broadcast_pkts" , port_stats.eth_stats.rx_broadcast), + IECM_PORT_STAT("port-rx-unknown_protocol", port_stats.eth_stats.rx_unknown_protocol),
94-cols line.
Quoted 163 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +163
-0+IECM_PORT_STAT ("port-tx_bytes" , port_stats.eth_stats.tx_bytes), +IECM_PORT_STAT ("port-tx-unicast_pkts" , port_stats.eth_stats.tx_unicast), +IECM_PORT_STAT ("port-tx-multicast_pkts" , port_stats.eth_stats.tx_multicast), +IECM_PORT_STAT ("port-tx-broadcast_pkts" , port_stats.eth_stats.tx_broadcast), + IECM_PORT_STAT("port-tx_errors", port_stats.eth_stats.tx_errors), +}; + +#define IECM_PORT_STATS_LEN ARRAY_SIZE(iecm_gstrings_port_stats) + +struct iecm_priv_flags { +char flag_string[ETH_GSTRING_LEN ]; +bool read_only; +u32 bitno; +}; + +#define IECM_PRIV_FLAG (_name, _bitno, _read_only) { \ + .read_only = _read_only, \ + .flag_string = _name, \ + .bitno = _bitno, \ +} + +static const struct iecm_priv_flags iecm_gstrings_priv_flags[] = { +IECM_PRIV_FLAG ("header-split" , __IECM_PRIV_FLAGS_HDR_SPLIT,0 ), +}; + +#define IECM_PRIV_FLAGS_STR_LEN ARRAY_SIZE(iecm_gstrings_priv_flags) + +/** +* __iecm_add_qstat_strings - copy stat strings into ethtool buffer +* @p: ethtool supplied buffer +* @stats: stat definitions array +* @size: size of the stats array +* @type: stat type +* @idx: stat index +* +* Format and copy the strings described by stats into the buffer pointed at +* by p. +*/ +static void __iecm_add_qstat_strings (u8 **p,const struct iecm_stats stats[], +const unsigned int size,const char *type, +unsigned int idx) +{ +unsigned int i; + +for (i =0 ; i < size; i++) { +snprintf ((char *)*p,ETH_GSTRING_LEN , +"%2s-%u.%.17s" , type, idx, stats[i].stat_string); + *p +=ETH_GSTRING_LEN ; + } +} + +/** +* iecm_add_qstat_strings - Copy queue stat strings into ethtool buffer +* @p: ethtool supplied buffer +* @stats: stat definitions array +* @type: stat type +* @idx: stat idx +* +* Format and copy the strings described by the const static stats value into +* the buffer pointed at by p. +* +* The parameter @stats is evaluated twice, so parameters with side effects +* should be avoided. Additionally, stats must be an array such that +* ARRAY_SIZE can be called on it. +*/ +#define iecm_add_qstat_strings (p, stats, type, idx) \ + __iecm_add_qstat_strings(p, stats, ARRAY_SIZE(stats), type, idx) + +/** +* iecm_add_port_stat_strings - Copy port stat strings into ethtool buffer +* @p: ethtool buffer +* @stats: struct to copy from +*/ +static void iecm_add_port_stat_strings (u8 **p,const struct iecm_stats stats[]) +{ +const unsigned int size =IECM_PORT_STATS_LEN ; +unsigned int i; + +for (i =0 ; i < size; i++) { +snprintf ((char *)*p,ETH_GSTRING_LEN ,"%.32s" , + stats[i].stat_string); + *p +=ETH_GSTRING_LEN ; + } +} + +/** +* iecm_get_stat_strings - Get stat strings +* @netdev: network interface device structure +* @data: buffer for string data +* +* Builds the statistics string table +*/ +static void iecm_get_stat_strings (struct net_device *netdev,u8 *data) +{ +struct iecm_vport *vport =iecm_netdev_to_vport (netdev); +unsigned int i; +u16 max_q; + +iecm_add_port_stat_strings (&data, iecm_gstrings_port_stats); + +/* It's critical that we always report a constant number of strings and +* that the strings are reported in the same order regardless of how +* many queues are actually in use. +*/ + max_q = vport->adapter->max_queue_limit; + +for (i =0 ; i < max_q; i++) +iecm_add_qstat_strings (&data, iecm_gstrings_tx_queue_stats, +"tx" , i); +for (i =0 ; i < max_q; i++) +iecm_add_qstat_strings (&data, iecm_gstrings_rx_queue_stats, +"rx" , i); +} + +/** +* iecm_get_priv_flag_strings - Get private flag strings +* @netdev: network interface device structure +* @data: buffer for string data +* +* Builds the private flags string table +*/ +static void iecm_get_priv_flag_strings (struct net_device *netdev,u8 *data) +{ +unsigned int i; + +for (i =0 ; i <IECM_PRIV_FLAGS_STR_LEN ; i++) { +snprintf ((char *)data,ETH_GSTRING_LEN ,"%s" , + iecm_gstrings_priv_flags[i].flag_string); + data +=ETH_GSTRING_LEN ; + } +} + +/** +* iecm_get_priv_flags - report device private flags +* @dev: network interface device structure +* +* The get string set count and the string set should be matched for each +* flag returned. Add new strings for each flag to the iecm_gstrings_priv_flags +* array. +* +* Returns a u32 bitmap of flags. +**/ +static u32 iecm_get_priv_flags (struct net_device *dev) +{ +struct iecm_netdev_priv *np =netdev_priv (dev); +struct iecm_user_config_data *user_data; +struct iecm_vport *vport = np->vport; +u32 i, ret_flags =0 ; + + user_data = &vport->adapter->config_data; + +for (i =0 ; i <IECM_PRIV_FLAGS_STR_LEN ; i++) { +const struct iecm_priv_flags *priv_flag; + + priv_flag = &iecm_gstrings_priv_flags[i]; + +if (test_bit (priv_flag->bitno, user_data->user_flags)) + ret_flags |=BIT (i); + } + +return ret_flags; +} +
drivers/net/ethernet/intel/iecm/iecm_ethtool.c line 593
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +10
-0+/** +* iecm_set_priv_flags - set private flags +* @dev: network interface device structure +* @flags: bit flags to be set +**/ +static int iecm_set_priv_flags (struct net_device *dev,u32 flags) +{ +struct iecm_netdev_priv *np =netdev_priv (dev); +DECLARE_BITMAP (change_flags, __IECM_USER_FLAGS_NBITS); +DECLARE_BITMAP (orig_flags, __IECM_USER_FLAGS_NBITS);
RCT.
Quoted 24 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +24
-0+struct iecm_user_config_data *user_data; +struct iecm_vport *vport = np->vport; +bool is_reset_needed; +int err =0 ; +u32 i; + +if (flags >BIT (IECM_PRIV_FLAGS_STR_LEN )) +return -EINVAL ; + + user_data = &vport->adapter->config_data; + +bitmap_copy (orig_flags, user_data->user_flags, __IECM_USER_FLAGS_NBITS); + +for (i =0 ; i <IECM_PRIV_FLAGS_STR_LEN ; i++) { +const struct iecm_priv_flags *priv_flag; + + priv_flag = &iecm_gstrings_priv_flags[i]; + +if (flags &BIT (i)) { +/* If this is a read-only flag, it can't be changed */ +if (priv_flag->read_only) +return -EOPNOTSUPP ; + +set_bit (priv_flag->bitno, user_data->user_flags);
drivers/net/ethernet/intel/iecm/iecm_ethtool.c line 627
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +10
-0+ }else { +clear_bit (priv_flag->bitno, user_data->user_flags); + } + } + +bitmap_xor (change_flags, user_data->user_flags, + orig_flags, __IECM_USER_FLAGS_NBITS); + + is_reset_needed = + !!(test_bit (__IECM_PRIV_FLAGS_HDR_SPLIT, change_flags));
Shorter name would allow avoiding line break.
Quoted 19 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +19
-0+ +/* Issue reset to cause things to take effect, as additional bits +* are added we will need to create a mask of bits requiring reset +*/ +if (is_reset_needed) + err =iecm_initiate_soft_reset (vport, __IECM_SR_HSPLIT_CHANGE); + +return err; +} + +/** +* iecm_get_strings - Get string set +* @netdev: network interface device structure +* @sset: id of string set +* @data: buffer for string data +* +* Builds string tables for various string sets +*/ +static void iecm_get_strings (struct net_device *netdev,u32 sset,u8 *data)
drivers/net/ethernet/intel/iecm/iecm_ethtool.c line 656
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +10
-0+{ +switch (sset) { +case ETH_SS_STATS : +iecm_get_stat_strings (netdev, data); +break ; +case ETH_SS_PRIV_FLAGS : +iecm_get_priv_flag_strings (netdev, data); +break ; +default : +break ;
Equivalent to not having a 'default' case.
Quoted 27 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +27
-0+ } +} + +/** +* iecm_get_sset_count - Get length of string set +* @netdev: network interface device structure +* @sset: id of string set +* +* Reports size of various string tables. +*/ +static +int iecm_get_sset_count (struct net_device *netdev,int sset) +{ +if (sset ==ETH_SS_STATS ) { +struct iecm_vport *vport =iecm_netdev_to_vport (netdev); +u16 max_q; + +/* This size reported back here *must* be constant throughout +* the lifecycle of the netdevice, i.e. we must report the +* maximum length even for queues that don't technically exist. +* This is due to the fact that this userspace API uses three +* separate ioctl calls to get stats data but has no way to +* communicate back to userspace when that size has changed, +* which can typically happen as a result of changing number of +* queues. If the number/order of stats change in the middle of +* this call chain it will lead to userspace crashing/accessing +* bad data through buffer under/overflow.
drivers/net/ethernet/intel/iecm/iecm_ethtool.c line 693
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +10
-0+*/ + max_q = vport->adapter->max_queue_limit; + +return IECM_PORT_STATS_LEN + + (IECM_TX_QUEUE_STATS_LEN * max_q) + + (IECM_RX_QUEUE_STATS_LEN * max_q); + }else if (sset ==ETH_SS_PRIV_FLAGS ) { +return IECM_PRIV_FLAGS_STR_LEN ; + }else { +return -EINVAL ;
Check for this at first and save 1 level of indentation for ETH_SS_STATS.
Quoted 131 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +131
-0+ } +} + +/** +* iecm_add_one_ethtool_stat - copy the stat into the supplied buffer +* @data: location to store the stat value +* @pstat: old stat pointer to copy from +* @stat: the stat definition +* +* Copies the stat data defined by the pointer and stat structure pair into +* the memory supplied as data. Used to implement iecm_add_ethtool_stats and +* iecm_add_queue_stats. If the pointer is null, data will be zero'd. +*/ +static void +iecm_add_one_ethtool_stat (u64 *data,void *pstat, +const struct iecm_stats *stat) +{ +char *p; + +if (!pstat) { +/* Ensure that the ethtool data buffer is zero'd for any stats +* which don't have a valid pointer. +*/ + *data =0 ; +return ; + } + + p = (char *)pstat + stat->stat_offset; +switch (stat->sizeof_stat) { +case sizeof (u64): + *data = *((u64 *)p); +break ; +case sizeof (u32): + *data = *((u32 *)p); +break ; +case sizeof (u16): + *data = *((u16 *)p); +break ; +case sizeof (u8): + *data = *((u8 *)p); +break ; +default : +WARN_ONCE (1 ,"unexpected stat size for %s" , + stat->stat_string); + *data =0 ; + } +} + +/** +* iecm_add_queue_stats - copy queue statistics into supplied buffer +* @data: ethtool stats buffer +* @q: the queue to copy +* +* Queue statistics must be copied while protected by +* u64_stats_fetch_begin_irq, so we can't directly use iecm_add_ethtool_stats. +* Assumes that queue stats are defined in iecm_gstrings_queue_stats. If the +* queue pointer is null, zero out the queue stat values and update the data +* pointer. Otherwise safely copy the stats from the queue into the supplied +* buffer and update the data pointer when finished. +* +* This function expects to be called while under rcu_read_lock(). +*/ +static void +iecm_add_queue_stats (u64 **data,struct iecm_queue *q) +{ +const struct iecm_stats *stats; +unsigned int start; +unsigned int size; +unsigned int i; + +if (q->q_type ==VIRTCHNL2_QUEUE_TYPE_RX ) { + size =IECM_RX_QUEUE_STATS_LEN ; + stats = iecm_gstrings_rx_queue_stats; + }else { + size =IECM_TX_QUEUE_STATS_LEN ; + stats = iecm_gstrings_tx_queue_stats; + } + +/* To avoid invalid statistics values, ensure that we keep retrying +* the copy until we get a consistent value according to +* u64_stats_fetch_retry_irq. But first, make sure our queue is +* non-null before attempting to access its syncp. +*/ +do { + start =u64_stats_fetch_begin_irq (&q->stats_sync); +for (i =0 ; i < size; i++) +iecm_add_one_ethtool_stat (&(*data)[i], q, &stats[i]); + }while (u64_stats_fetch_retry_irq (&q->stats_sync, start)); + +/* Once we successfully copy the stats in, update the data pointer */ + *data += size; +} + +/** +* iecm_add_empty_queue_stats - Add stats for a non-existent queue +* @data: pointer to data buffer +* @qtype: type of data queue +* +* We must report a constant length of stats back to userspace regardless of +* how many queues are actually in use because stats collection happens over +* three separate ioctls and there's no way to notify userspace the size +* changed between those calls. This adds empty to data to the stats since we +* don't have a real queue to refer to for this stats slot. +*/ +static void +iecm_add_empty_queue_stats (u64 **data,u16 qtype) +{ +unsigned int i; +int stats_len; + +if (qtype ==VIRTCHNL2_QUEUE_TYPE_RX ) + stats_len =IECM_RX_QUEUE_STATS_LEN ; +else + stats_len =IECM_TX_QUEUE_STATS_LEN ; + +for (i =0 ; i < stats_len; i++) + (*data)[i] =0 ; + *data += stats_len; +} + +/** +* iecm_add_port_stats - Copy port stats into ethtool buffer +* @vport: virtual port struct +* @data: ethtool buffer to copy into +*/ +static void iecm_add_port_stats (struct iecm_vport *vport,u64 **data) +{ +unsigned int size =IECM_PORT_STATS_LEN ; +unsigned int start; +unsigned int i; +
drivers/net/ethernet/intel/iecm/iecm_ethtool.c line 834
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +10
-0+/* To avoid invalid statistics values, ensure that we keep retrying +* the copy until we get a consistent value according to +* u64_stats_fetch_retry_irq. +*/ + do { + start = u64_stats_fetch_begin_irq(&vport->port_stats.stats_sync); + for (i = 0; i < size; i++) { + iecm_add_one_ethtool_stat(&(*data)[i], vport, + &iecm_gstrings_port_stats[i]); + }
Redundant braces.
Quoted 5 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +5
-0+ }while (u64_stats_fetch_retry_irq (&vport->port_stats.stats_sync, start)); + + *data += size; +} +
drivers/net/ethernet/intel/iecm/iecm_ethtool.c line 849
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +10
-0+/** +* iecm_get_ethtool_stats - report device statistics +* @netdev: network interface device structure +* @stats: ethtool statistics structure +* @data: pointer to data buffer +* +* All statistics are added to the data buffer as an array of u64. +*/ +static void iecm_get_ethtool_stats(struct net_device *netdev, + struct ethtool_stats __always_unused *stats,
Redundant __always_unused.
Quoted 176 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +176
-0+ u64 *data) +{ +struct iecm_vport *vport =iecm_netdev_to_vport (netdev); +unsigned int total =0 ; +unsigned int i, j; +u16 max_q, qtype; + +if (vport->adapter->state != __IECM_UP) +return ; + +set_bit (__IECM_MB_STATS_PENDING, vport->adapter->flags); + + max_q = vport->adapter->max_queue_limit; + +rcu_read_lock (); + +iecm_add_port_stats (vport, &data); + +for (i =0 ; i < vport->num_txq_grp; i++) { +struct iecm_txq_group *txq_grp = &vport->txq_grps[i]; + + qtype =VIRTCHNL2_QUEUE_TYPE_TX ; + +for (j =0 ; j < txq_grp->num_txq; j++, total++) { +struct iecm_queue *txq = txq_grp->txqs[j]; + +if (!txq) +iecm_add_empty_queue_stats (&data, qtype); +else +iecm_add_queue_stats (&data, txq); + } + } +/* It is critical we provide a constant number of stats back to +* userspace regardless of how many queues are actually in use because +* there is no way to inform userspace the size has changed between +* ioctl calls. This will fill in any missing stats with zero. +*/ +for (; total < max_q; total++) +iecm_add_empty_queue_stats (&data,VIRTCHNL2_QUEUE_TYPE_TX ); + total =0 ; + +for (i =0 ; i < vport->num_rxq_grp; i++) { +struct iecm_rxq_group *rxq_grp = &vport->rxq_grps[i]; +int num_rxq; + + qtype =VIRTCHNL2_QUEUE_TYPE_RX ; + +if (iecm_is_queue_model_split (vport->rxq_model)) + num_rxq = rxq_grp->splitq.num_rxq_sets; +else + num_rxq = rxq_grp->singleq.num_rxq; + +for (j =0 ; j < num_rxq; j++, total++) { +struct iecm_queue *rxq; + +if (iecm_is_queue_model_split (vport->rxq_model)) + rxq = &rxq_grp->splitq.rxq_sets[j]->rxq; +else + rxq = rxq_grp->singleq.rxqs[j]; +if (!rxq) +iecm_add_empty_queue_stats (&data, qtype); +else +iecm_add_queue_stats (&data, rxq); + } + } +for (; total < max_q; total++) +iecm_add_empty_queue_stats (&data,VIRTCHNL2_QUEUE_TYPE_RX ); +rcu_read_unlock (); +} + +/** +* iecm_find_rxq - find rxq from q index +* @vport: virtual port associated to queue +* @q_num: q index used to find queue +* +* returns pointer to rx queue +*/ +static struct iecm_queue * +iecm_find_rxq (struct iecm_vport *vport,int q_num) +{ +struct iecm_queue *rxq; + +if (iecm_is_queue_model_split (vport->rxq_model)) { +int q_grp, q_idx; + + q_grp = q_num /IECM_DFLT_SPLITQ_RXQ_PER_GROUP ; + q_idx = q_num %IECM_DFLT_SPLITQ_RXQ_PER_GROUP ; + + rxq = &vport->rxq_grps[q_grp].splitq.rxq_sets[q_idx]->rxq; + }else { + rxq = vport->rxq_grps->singleq.rxqs[q_num]; + } + +return rxq; +} + +/** +* iecm_find_txq - find txq from q index +* @vport: virtual port associated to queue +* @q_num: q index used to find queue +* +* returns pointer to tx queue +*/ +static struct iecm_queue * +iecm_find_txq (struct iecm_vport *vport,int q_num) +{ +struct iecm_queue *txq; + +if (iecm_is_queue_model_split (vport->txq_model)) { +int q_grp = q_num /IECM_DFLT_SPLITQ_TXQ_PER_GROUP ; + + txq = vport->txq_grps[q_grp].complq; + }else { + txq = vport->txqs[q_num]; + } + +return txq; +} + +/** +* __iecm_get_q_coalesce - get ITR values for specific queue +* @ec: ethtool structure to fill with driver's coalesce settings +* @q: quuee of Rx or Tx +*/ +static void +__iecm_get_q_coalesce (struct ethtool_coalesce *ec,struct iecm_queue *q) +{ +if (q->q_type ==VIRTCHNL2_QUEUE_TYPE_RX ) { + ec->use_adaptive_rx_coalesce = +IECM_ITR_IS_DYNAMIC (q->q_vector->rx_intr_mode); + ec->rx_coalesce_usecs = q->q_vector->rx_itr_value; + }else { + ec->use_adaptive_tx_coalesce = +IECM_ITR_IS_DYNAMIC (q->q_vector->tx_intr_mode); + ec->tx_coalesce_usecs = q->q_vector->tx_itr_value; + } +} + +/** +* iecm_get_q_coalesce - get ITR values for specific queue +* @netdev: pointer to the netdev associated with this query +* @ec: coalesce settings to program the device with +* @q_num: update ITR/INTRL (coalesce) settings for this queue number/index +* +* Return 0 on success, and negative on failure +*/ +static int +iecm_get_q_coalesce (struct net_device *netdev,struct ethtool_coalesce *ec, +u32 q_num) +{ +struct iecm_vport *vport =iecm_netdev_to_vport (netdev); + +if (vport->adapter->state != __IECM_UP) +return 0 ; + +if (q_num >= vport->num_rxq && q_num >= vport->num_txq) +return -EINVAL ; + +if (q_num < vport->num_rxq) { +struct iecm_queue *rxq =iecm_find_rxq (vport, q_num); + +__iecm_get_q_coalesce (ec, rxq); + } + +if (q_num < vport->num_txq) { +struct iecm_queue *txq =iecm_find_txq (vport, q_num); + +__iecm_get_q_coalesce (ec, txq); + } + +return 0 ; +} + +/** +* iecm_get_coalesce - get ITR values as requested by user +* @netdev: pointer to the netdev associated with this query
drivers/net/ethernet/intel/iecm/iecm_ethtool.c line 1035
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +10
-0+* @ec: coalesce settings to be filled +* @kec: unused +* @extack: unused +* +* Return 0 on success, and negative on failure +*/ +static int +iecm_get_coalesce (struct net_device *netdev,struct ethtool_coalesce *ec, +struct kernel_ethtool_coalesce __always_unused *kec, +struct netlink_ext_ack __always_unused *extack)
__always_unused.
Quoted 162 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +162
-0+{ +/* Return coalesce based on queue number zero */ +return iecm_get_q_coalesce (netdev, ec,0 ); +} + +/** +* iecm_get_per_q_coalesce - get ITR values as requested by user +* @netdev: pointer to the netdev associated with this query +* @q_num: queue for which the itr values has to retrieved +* @ec: coalesce settings to be filled +* +* Return 0 on success, and negative on failure +*/ + +static int +iecm_get_per_q_coalesce (struct net_device *netdev,u32 q_num, +struct ethtool_coalesce *ec) +{ +return iecm_get_q_coalesce (netdev, ec, q_num); +} + +/** +* __iecm_set_q_coalesce - set ITR values for specific queue +* @ec: ethtool structure from user to update ITR settings +* @q: queue for which itr values has to be set +* +* Returns 0 on success, negative otherwise. +*/ +static int +__iecm_set_q_coalesce (struct ethtool_coalesce *ec,struct iecm_queue *q) +{ +u32 use_adaptive_coalesce, coalesce_usecs; +struct iecm_q_vector *qv = q->q_vector; +struct iecm_vport *vport; +bool is_dim_ena = false; + + vport = q->vport; +if (q->q_type ==VIRTCHNL2_QUEUE_TYPE_RX ) { + is_dim_ena =IECM_ITR_IS_DYNAMIC (qv->rx_intr_mode); + use_adaptive_coalesce = ec->use_adaptive_rx_coalesce; + coalesce_usecs = ec->rx_coalesce_usecs; + }else { + is_dim_ena =IECM_ITR_IS_DYNAMIC (qv->tx_intr_mode); + use_adaptive_coalesce = ec->use_adaptive_tx_coalesce; + coalesce_usecs = ec->tx_coalesce_usecs; + } + +if (coalesce_usecs && use_adaptive_coalesce) { +netdev_info (vport->netdev,"Cannot set coalesce usecs if adaptive enabled\n" ); +return -EINVAL ; + } + +if (is_dim_ena && use_adaptive_coalesce) +return 0 ; + +if (coalesce_usecs >IECM_ITR_MAX ) { +netdev_info (vport->netdev, +"Invalid value, %d-usecs range is 0-%d\n" , + coalesce_usecs,IECM_ITR_MAX ); +return -EINVAL ; + } + +if (coalesce_usecs %2 !=0 ) { + coalesce_usecs = coalesce_usecs &0xFFFFFFFE ; +netdev_info (vport->netdev,"HW only supports even ITR values, ITR rounded to %d\n" , + coalesce_usecs); + } + +if (q->q_type ==VIRTCHNL2_QUEUE_TYPE_RX ) { + qv->rx_itr_value = coalesce_usecs; +if (use_adaptive_coalesce) { + qv->rx_intr_mode =IECM_ITR_DYNAMIC ; + }else { + qv->rx_intr_mode = !IECM_ITR_DYNAMIC ; +iecm_vport_intr_write_itr (qv, qv->rx_itr_value, + false); + } + }else { + qv->tx_itr_value = coalesce_usecs; +if (use_adaptive_coalesce) { + qv->tx_intr_mode =IECM_ITR_DYNAMIC ; + }else { + qv->tx_intr_mode = !IECM_ITR_DYNAMIC ; +iecm_vport_intr_write_itr (qv, qv->tx_itr_value, true); + } + } +/* Update of static/dynamic itr will be taken care when interrupt is +* fired +*/ +return 0 ; +} + +/** +* iecm_set_q_coalesce - set ITR values for specific queue +* @vport: vport associated to the queue that need updating +* @ec: coalesce settings to program the device with +* @q_num: update ITR/INTRL (coalesce) settings for this queue number/index +* @is_rxq: is queue type rx +* +* Return 0 on success, and negative on failure +*/ +static int +iecm_set_q_coalesce (struct iecm_vport *vport,struct ethtool_coalesce *ec, +int q_num,bool is_rxq) +{ +struct iecm_queue *q; + +if (is_rxq) + q =iecm_find_rxq (vport, q_num); +else + q =iecm_find_txq (vport, q_num); + +if (q &&__iecm_set_q_coalesce (ec, q)) +return -EINVAL ; + +return 0 ; +} + +/** +* iecm_set_coalesce - set ITR values as requested by user +* @netdev: pointer to the netdev associated with this query +* @ec: coalesce settings to program the device with +* @kec: unused +* @extack: unused +* +* Return 0 on success, and negative on failure +*/ +static int +iecm_set_coalesce (struct net_device *netdev,struct ethtool_coalesce *ec, +struct kernel_ethtool_coalesce __always_unused *kec, +struct netlink_ext_ack __always_unused *extack) +{ +struct iecm_vport *vport =iecm_netdev_to_vport (netdev); +int i, err; + +if (vport->adapter->state != __IECM_UP) +return 0 ; + +for (i =0 ; i < vport->num_txq; i++) { + err =iecm_set_q_coalesce (vport, ec, i, false); +if (err) +return err; + } + +for (i =0 ; i < vport->num_rxq; i++) { + err =iecm_set_q_coalesce (vport, ec, i, true); +if (err) +return err; + } +return 0 ; +} + +/** +* iecm_set_per_q_coalesce - set ITR values as requested by user +* @netdev: pointer to the netdev associated with this query +* @q_num: queue for which the itr values has to be set +* @ec: coalesce settings to program the device with +* +* Return 0 on success, and negative on failure +*/ +static int +iecm_set_per_q_coalesce(struct net_device *netdev, u32 q_num,
drivers/net/ethernet/intel/iecm/iecm_ethtool.c line 1207
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +10
-0+ struct ethtool_coalesce *ec) +{ +struct iecm_vport *vport =iecm_netdev_to_vport (netdev); +int err; + + err =iecm_set_q_coalesce (vport, ec, q_num, false); +if (!err) + err =iecm_set_q_coalesce (vport, ec, q_num, true); + +return err;
err = iecm_set_q_coalesce(vport, ec, q_num, false); if (err) return err; return iecm_set_q_coalesce(vport, ec, q_num, true);
Quoted 108 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +108
-0+} + +/** +* iecm_get_msglevel - Get debug message level +* @netdev: network interface device structure +* +* Returns current debug message level. +*/ +static u32 iecm_get_msglevel (struct net_device *netdev) +{ +struct iecm_adapter *adapter =iecm_netdev_to_adapter (netdev); + +return adapter->msg_enable; +} + +/** +* iecm_set_msglevel - Set debug message level +* @netdev: network interface device structure +* @data: message level +* +* Set current debug message level. Higher values cause the driver to +* be noisier. +*/ +static void iecm_set_msglevel (struct net_device *netdev,u32 data) +{ +struct iecm_adapter *adapter =iecm_netdev_to_adapter (netdev); + + adapter->msg_enable = data; +} + +/** +* iecm_get_link_ksettings - Get Link Speed and Duplex settings +* @netdev: network interface device structure +* @cmd: ethtool command +* +* Reports speed/duplex settings. +**/ +static int iecm_get_link_ksettings (struct net_device *netdev, +struct ethtool_link_ksettings *cmd) +{ +struct iecm_netdev_priv *np =netdev_priv (netdev); +struct iecm_adapter *adapter = np->vport->adapter; + +ethtool_link_ksettings_zero_link_mode (cmd, supported); + cmd->base.autoneg =AUTONEG_DISABLE ; + cmd->base.port =PORT_NONE ; + cmd->base.duplex =DUPLEX_FULL ; + +if (adapter->link_speed_mbps) { + cmd->base.speed = adapter->link_speed_mbps; +return 0 ; + } + +/* Set speed and duplex */ +switch (adapter->link_speed) { +case VIRTCHNL_LINK_SPEED_40GB : + cmd->base.speed =SPEED_40000 ; +break ; +case VIRTCHNL_LINK_SPEED_25GB : + cmd->base.speed =SPEED_25000 ; +break ; +case VIRTCHNL_LINK_SPEED_20GB : + cmd->base.speed =SPEED_20000 ; +break ; +case VIRTCHNL_LINK_SPEED_10GB : + cmd->base.speed =SPEED_10000 ; +break ; +case VIRTCHNL_LINK_SPEED_1GB : + cmd->base.speed =SPEED_1000 ; +break ; +case VIRTCHNL_LINK_SPEED_100MB : + cmd->base.speed =SPEED_100 ; +break ; +default : +break ; + } + +return 0 ; +} + +static const struct ethtool_ops iecm_ethtool_ops = { + .supported_coalesce_params =ETHTOOL_COALESCE_USECS | +ETHTOOL_COALESCE_USE_ADAPTIVE , + .get_msglevel = iecm_get_msglevel, + .set_msglevel = iecm_set_msglevel, + .get_coalesce = iecm_get_coalesce, + .set_coalesce = iecm_set_coalesce, + .get_per_queue_coalesce = iecm_get_per_q_coalesce, + .set_per_queue_coalesce = iecm_set_per_q_coalesce, + .get_ethtool_stats = iecm_get_ethtool_stats, + .get_strings = iecm_get_strings, + .get_sset_count = iecm_get_sset_count, + .get_priv_flags = iecm_get_priv_flags, + .set_priv_flags = iecm_set_priv_flags, + .get_rxnfc = iecm_get_rxnfc, + .set_rxnfc = iecm_set_rxnfc, + .get_rxfh_key_size = iecm_get_rxfh_key_size, + .get_rxfh_indir_size = iecm_get_rxfh_indir_size, + .get_rxfh = iecm_get_rxfh, + .set_rxfh = iecm_set_rxfh, + .get_channels = iecm_get_channels, + .set_channels = iecm_set_channels, + .get_ringparam = iecm_get_ringparam, + .set_ringparam = iecm_set_ringparam, + .get_link_ksettings = iecm_get_link_ksettings, +}; + +/**
drivers/net/ethernet/intel/iecm/iecm_ethtool.c line 1325
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +10
-0+* iecm_set_ethtool_ops - Initialize ethtool ops struct +* @netdev: network interface device structure +* +* Sets ethtool ops struct in our netdev so that ethtool can call +* our functions. +*/ +void iecm_set_ethtool_ops (struct net_device *netdev) +{ + netdev->ethtool_ops = &iecm_ethtool_ops; +}
Declaring @iecm_ethtool_ops as external and directly assigning it in iecm_cfg_netdev() would result in smaller code size than this.
Quoted 13 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +1
-0@@ -871,6 +871,7 @@ static int iecm_cfg_netdev(struct iecm_vport *vport) netdev->hw_features |= dflt_features | offloads; netdev->hw_enc_features |= dflt_features | offloads; +iecm_set_ethtool_ops (netdev);SET_NETDEV_DEV (netdev, &adapter->pdev->dev);/* carrier off on init to avoid Tx hangs */
drivers/net/ethernet/intel/iecm/iecm_lib.c iecm_vport_alloc(struct iecm_adapter *adapter, int vport_id) · line 1156
Quoted 7 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +3
-1@@ -1150,7 +1151,15 @@ iecm_vport_alloc(struct iecm_adapter *adapter, int vport_id)*/ static void iecm_statistics_task (struct work_struct *work) { -/* stub */ +struct iecm_adapter *adapter =container_of (work, + struct iecm_adapter, + stats_task.work);
struct iecm_adapter *adapter; adapter = container_of(work, typeof(*adapter), stats_task.work);
This fits into 79 without a line wrap.
Quoted 23 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +6
-0+if (test_bit (__IECM_MB_STATS_PENDING, adapter->flags) && + !test_bit (__IECM_HR_RESET_IN_PROG, adapter->flags)) + adapter->dev_ops.vc_ops.get_stats_msg (adapter->vports[0 ]); + +queue_delayed_work (adapter->stats_wq, &adapter->stats_task, +msecs_to_jiffies (1000 )); }/** drivers/net/ethernet/intel/include/iecm.h +1
-0@@ -745,6 +745,7 @@ int iecm_recv_mb_msg(struct iecm_adapter *adapter, enum virtchnl_ops op, void *msg, int msg_size);int iecm_send_mb_msg (struct iecm_adapter *adapter,enum virtchnl_ops op,u16 msg_size,u8 *msg); +void iecm_set_ethtool_ops (struct net_device *netdev);void iecm_vport_set_hsplit (struct iecm_vport *vport,bool ena);void iecm_add_del_ether_addrs (struct iecm_vport *vport,bool add,bool async);int iecm_set_promiscuous (struct iecm_adapter *adapter);Signature · 1 line
2.33.0
Thanks,
Al
Brady
PATCH 15/19 iecm: implement ethtool callbacks
Quoted 67 lines
-----Original Message-----
From: Lobakin, Alexandr <[email protected]>
Sent: Friday, January 28, 2022 10:14 AM
To: Brady, Alan <[email protected]>
Cc: Lobakin, Alexandr <[email protected]>; intel-wired- lan at lists.osuosl.org; Burra, Phani R <[email protected]>; Chittim, Madhu <[email protected]>; Linga, Pavan Kumar <[email protected]>
Subject: Re: [Intel-wired-lan] [PATCH net-next 15/19] iecm: implement ethtool callbacksFrom: Alan Brady <[email protected]>
Date: Thu, 27 Jan 2022 16:10:05 -0800Quoted 4 lines
This does everything needed to handle ethtool ops minus a few stubs for cloud filters and other advanced features which will be added in later in this series.
Quoted 8 lines
Signed-off-by Phani Burra <[email protected]>Signed-off-by Joshua Hay <[email protected]>Signed-off-by Madhu Chittim <[email protected]>Signed-off-by Pavan Kumar Linga <[email protected]>Signed-off-by Alan Brady <[email protected]>--- drivers/net/ethernet/intel/iecm/Makefile | 1 + .../net/ethernet/intel/iecm/iecm_ethtool.c | 1325+++++++++++++++++
Quoted 29 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c | 11 +- drivers/net/ethernet/intel/include/iecm.h | 1 + 4 files changed, 1337 insertions(+), 1 deletion(-) create mode100644
drivers/net/ethernet/intel/iecm/iecm_ethtool.cdrivers/net/ethernet/intel/iecm/Makefile +1
-0@@ -15,6 +15,7 @@ iecm-y := \ iecm_virtchnl.o \ iecm_txrx.o \ iecm_singleq_txrx.o \ + iecm_ethtool.o \ iecm_controlq.o \ iecm_controlq_setup.o \ iecm_main.odrivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +4
-0@@ -0,0 +1,1325 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* Copyright (C) 2019 Intel Corporation */ + +#include "iecm.h" drivers/net/ethernet/intel/iecm/iecm_ethtool.c line 14
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +10
-0+ +/** +* iecm_get_rxnfc - command to get RX flow classification rules +* @netdev: network interface device structure +* @cmd: ethtool rxnfc command +* @rule_locs: pointer to store rule locations +* +* Returns Success if the command is supported. +*/ +static int iecm_get_rxnfc(struct net_device *netdev, struct ethtool_rxnfc*cmd,
Quoted 6 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c line 15
Quoted 1 line
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +1
-0+ u32 __always_unused *rule_locs)Kernel
Kbuildsystem tell compilers to not complain on unused function arguments.
It's pointless to add__always_unusedhere.
Sparse does complain about it (e.g. make ... C=2) and it's present in other (non-Intel) network drivers. I think I need a better argument to remove it.
Quoted 67 lines
Quoted 56 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +56
-0+{ +struct iecm_vport *vport =iecm_netdev_to_vport (netdev); +int ret = -EOPNOTSUPP ; + +switch (cmd->cmd) { +case ETHTOOL_GRXRINGS : + cmd->data = vport->num_rxq; + ret =0 ; +break ; +case ETHTOOL_GRXCLSRLCNT : +/* stub */ + ret =0 ; +break ; +case ETHTOOL_GRXCLSRULE : +/* stub */ +break ; +case ETHTOOL_GRXCLSRLALL : +/* stub */ +break ; +case ETHTOOL_GRXFH : +/* stub */ +break ; +default : +break ; + } + +return ret; +} + +/** +* iecm_set_rxnfc - command to set Rx flow rules. +* @netdev: network interface device structure +* @cmd: ethtool rxnfc command +* +* Returns 0 for success and negative values for errors */ static +int iecm_set_rxnfc (struct net_device *netdev,struct ethtool_rxnfc +*cmd) { +int ret = -EOPNOTSUPP ; + +switch (cmd->cmd) { +case ETHTOOL_SRXCLSRLINS : +/* stub */ +break ; +case ETHTOOL_SRXCLSRLDEL : +/* stub */ +break ; +case ETHTOOL_SRXFH : +/* stub */ +break ; +default : +break ; + } + +return ret; +} +drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +10
-0+/** +* iecm_get_rxfh_key_size - get the RSS hash key size +* @netdev: network interface device structure +* +* Returns the table size. +*/ +static u32 iecm_get_rxfh_key_size(struct net_device *netdev) { + struct iecm_vport *vport = iecm_netdev_to_vport(netdev); + + if (!iecm_is_cap_ena_all(vport->adapter, IECM_RSS_CAPS,
IECM_CAP_RSS)) {
Quoted 9 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c line 82
Quoted 1 line
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +1
-0+ dev_info(&vport->adapter->pdev->dev, "RSS is notsupported on this device\n");
drivers/net/ethernet/intel/iecm/iecm_ethtool.c line 88
Quoted 4 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +4
-0+return 0 ; + } + +return vport->adapter->rss_data.rss_key_size;If you invert the condition, it would take less lines.
Sure why not. Will fix.
Quoted 190 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 13 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +13
-0+} + +/** +* iecm_get_rxfh_indir_size - get the rx flow hash indirection table +size +* @netdev: network interface device structure +* +* Returns the table size. +*/ +static u32 iecm_get_rxfh_indir_size(struct net_device *netdev) { + struct iecm_vport *vport = iecm_netdev_to_vport(netdev); + + if (!iecm_is_cap_ena_all(vport->adapter, IECM_RSS_CAPS,
IECM_CAP_RSS)) {drivers/net/ethernet/intel/iecm/iecm_ethtool.c line 100
Quoted 1 line
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +1
-0+ dev_info(&vport->adapter->pdev->dev, "RSS is notsupported on this device\n");
drivers/net/ethernet/intel/iecm/iecm_ethtool.c line 106
Quoted 4 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +4
-0+return 0 ; + } + +return vport->adapter->rss_data.rss_lut_size;Same here.
drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +10
-0+} + +/** +* iecm_get_rxfh - get the rx flow hash indirection table +* @netdev: network interface device structure +* @indir: indirection table +* @key: hash key +* @hfunc: hash function in use +* +* Reads the indirection table directly from the hardware. Always returns 0.
drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 11 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +11
-0+*/ +static int iecm_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key, + u8 *hfunc) +{ + struct iecm_vport *vport = iecm_netdev_to_vport(netdev); + struct iecm_adapter *adapter; + u16 i; + + adapter = vport->adapter; + + if (!iecm_is_cap_ena_all(adapter, IECM_RSS_CAPS,
IECM_CAP_RSS)) {drivers/net/ethernet/intel/iecm/iecm_ethtool.c line 126
Quoted 1 line
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +1
-0+ dev_info(&vport->adapter->pdev->dev, "RSS is notsupported on this device\n");
Quoted 5 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +5
-0+return 0 ; + } + +if (adapter->state != __IECM_UP) +return 0 ;drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +10
-0+ +if (hfunc) + *hfunc =ETH_RSS_HASH_TOP ; + +if (key) +memcpy (key, adapter->rss_data.rss_key, + adapter->rss_data.rss_key_size); + +if (indir) +/* Each 32 bits pointed by 'indir' is stored with a lut entry */
Quoted 17 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +17
-0+for (i =0 ; i < adapter->rss_data.rss_lut_size; i++) + indir[i] = adapter->rss_data.rss_lut[i]; + +return 0 ; +} + +/** +* iecm_set_rxfh - set the rx flow hash indirection table +* @netdev: network interface device structure +* @indir: indirection table +* @key: hash key +* @hfunc: hash function to use +* +* Returns -EINVAL if the table specifies an invalid queue id, +otherwise +* returns 0 after programming the table. +*/ drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +10
-0+static int iecm_set_rxfh(struct net_device *netdev, const u32 *indir, + const u8 *key, const u8 hfunc) +{ + struct iecm_vport *vport = iecm_netdev_to_vport(netdev); + struct iecm_adapter *adapter; + u16 lut; + + adapter = vport->adapter; + + if (!iecm_is_cap_ena_all(adapter, IECM_RSS_CAPS,
IECM_CAP_RSS)) {drivers/net/ethernet/intel/iecm/iecm_ethtool.c line 169
Quoted 1 line
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +1
-0+ dev_info(&adapter->pdev->dev, "RSS is not supported onthis device\n");
drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 5 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +5
-0+return 0 ; + } +if (adapter->state != __IECM_UP) +return 0 ; + if (hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc !=
ETH_RSS_HASH_TOP)Quoted 29 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +29
-0+return -EOPNOTSUPP ; + +if (key) +memcpy (adapter->rss_data.rss_key, key, + adapter->rss_data.rss_key_size); + +if (indir) { +for (lut =0 ; lut < adapter->rss_data.rss_lut_size; lut++) + adapter->rss_data.rss_lut[lut] = indir[lut]; + } + +return iecm_config_rss (vport); +} + +/** +* iecm_get_channels: get the number of channels supported by the +device +* @netdev: network interface device structure +* @ch: channel information structure +* +* Report maximum of TX and RX. Report one extra channel to match our +MailBox +* Queue. +*/ +static void iecm_get_channels (struct net_device *netdev, +struct ethtool_channels *ch) { +struct iecm_vport *vport =iecm_netdev_to_vport (netdev); +unsigned int combined; +int num_txq, num_rxq;drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +10
-0+ + num_txq = vport->adapter->config_data.num_req_tx_qs; + num_rxq = vport->adapter->config_data.num_req_rx_qs; + + combined =min (num_txq, num_rxq); + +/* Report maximum channels */ + ch->max_combined = vport->adapter->max_queue_limit; + +/* For now we've only enabled combined queues but will be enabling
Quoted 39 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +39
-0+* asymmetric queues after splitq model is fleshed out more. +*/ + ch->max_rx =0 ; + ch->max_tx =0 ; + + ch->max_other =IECM_MAX_NONQ ; + ch->other_count =IECM_MAX_NONQ ; + + ch->combined_count = combined; + ch->rx_count = num_rxq - combined; + ch->tx_count = num_txq - combined; +} + +/** +* iecm_set_channels: set the new channel count +* @netdev: network interface device structure +* @ch: channel information structure +* +* Negotiate a new number of channels with CP. Returns 0 on success, +negative +* on failure. +*/ +static int iecm_set_channels (struct net_device *netdev, +struct ethtool_channels *ch) +{ +unsigned int num_req_tx_q = ch->combined_count + ch->tx_count; +unsigned int num_req_rx_q = ch->combined_count + ch->rx_count; +struct iecm_vport *vport =iecm_netdev_to_vport (netdev); +struct iecm_adapter *adapter = vport->adapter; +int num_txq, num_rxq, err; + +if (num_req_tx_q ==0 || num_req_rx_q ==0 ) +return -EINVAL ; + + num_txq = vport->adapter->config_data.num_req_tx_qs; + num_rxq = vport->adapter->config_data.num_req_rx_qs; + +if (num_req_tx_q == num_txq && num_req_rx_q == num_rxq) +return 0 ;drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +10
-0+ + vport->adapter->config_data.num_req_tx_qs = num_req_tx_q; + vport->adapter->config_data.num_req_rx_qs = num_req_rx_q; + +if (adapter->virt_ver_maj <VIRTCHNL_VERSION_MAJOR_2 ) { + err = adapter->dev_ops.vc_ops.add_queues (vport, + num_req_tx_q,0 , + num_req_rx_q,0 ); + }else { + err = iecm_initiate_soft_reset(vport,
__IECM_SR_Q_CHANGE);
Quoted 4 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c line 263
Quoted 1 line
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +1
-0+ }One-liners, no need for braces.
The if exists across multiple lines so we would prefer to keep braces. As such the 'else' also gets them.
Quoted 371 lines
Quoted 14 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +14
-0+ +if (err) { +/* roll back queue change */ + vport->adapter->config_data.num_req_tx_qs = num_txq; + vport->adapter->config_data.num_req_rx_qs = num_rxq; + } + +return err; +} + +/** +* iecm_get_ringparam - Get ring parameters +* @netdev: network interface device structure +* @ring: ethtool ringparam structure drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +10
-0+* @kring: unused +* @ext_ack: unused +* +* Returns current ring parameters. TX and RX rings are reported +separately, +* but the number of rings is not reported. +*/ +static void iecm_get_ringparam(struct net_device *netdev, + struct ethtool_ringparam *ring, + __always_unused struct
kernel_ethtool_ringparam*kring,drivers/net/ethernet/intel/iecm/iecm_ethtool.c line 288
Quoted 1 line
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +1
-0+__always_unused struct netlink_ext_ack
*ext_ack)Same here for
__always_unused. +lines longer than 79.Quoted 12 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +12
-0+{ +struct iecm_vport *vport =iecm_netdev_to_vport (netdev); + + ring->rx_max_pending =IECM_MAX_RXQ_DESC ; + ring->tx_max_pending =IECM_MAX_TXQ_DESC ; + ring->rx_pending = vport->rxq_desc_count; + ring->tx_pending = vport->txq_desc_count; } + +/** +* iecm_set_ringparam - Set ring parameters +* @netdev: network interface device structure +* @ring: ethtool ringparam structure drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +10
-0+* @kring: unused +* @ext_ack: unused +* +* Sets ring parameters. TX and RX rings are controlled separately, +but the +* number of rings is not specified, so all rings get the same settings. +*/ +static int iecm_set_ringparam(struct net_device *netdev, + struct ethtool_ringparam *ring, + __always_unused struct
kernel_ethtool_ringparam*kring,drivers/net/ethernet/intel/iecm/iecm_ethtool.c line 311
Quoted 1 line
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +1
-0+__always_unused struct netlink_ext_ack
*ext_ack)Same.
drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 7 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +7
-0+{ +struct iecm_vport *vport =iecm_netdev_to_vport (netdev); +u32 new_rx_count, new_tx_count; +int i; + +if (iecm_is_queue_model_split (vport->rxq_model)) +/* When in splitq mode, any one RXQ needs to contain enough
drivers/net/ethernet/intel/iecm/iecm_ethtool.c line 326
Quoted 7 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +7
-0+* descriptors to service the 2 buffer queues associated with +* it. Since each buffer queue must be a multiple of 32, the +* RXQ then needs to be a multiple of 64 to be divided into +* multiples of 32 for each buffer queue +*/ + new_rx_count = ALIGN(ring->rx_pending, +
IECM_REQ_SPLITQ_RXQ_DESC_MULTIPLE);drivers/net/ethernet/intel/iecm/iecm_ethtool.c line 327
Quoted 2 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +2
-0+else + new_rx_count = ALIGN(ring->rx_pending,
IECM_REQ_DESC_MULTIPLE);drivers/net/ethernet/intel/iecm/iecm_ethtool.c line 329
Quoted 2 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +2
-0+ + new_tx_count = ALIGN(ring->tx_pending,
IECM_REQ_DESC_MULTIPLE);drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +10
-0+ +/* if nothing to do return success */ +if (new_tx_count == vport->txq_desc_count && + new_rx_count == vport->rxq_desc_count) +return 0 ; + + vport->adapter->config_data.num_req_txq_desc = new_tx_count; + vport->adapter->config_data.num_req_rxq_desc = new_rx_count; + +/* Since we adjusted the RX completion queue count, the RX buffer queue
drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 9 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +6
-0+* descriptor count needs to be adjusted as well +*/ +for (i =0 ; i < vport->num_bufqs_per_qgrp; i++) + vport->bufq_desc_count[i] = + IECM_RX_BUFQ_DESC_COUNT(new_rx_count, + vport-
num_bufqs_per_qgrp);drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +2
-0+ + return iecm_initiate_soft_reset(vport,
__IECM_SR_Q_DESC_CHANGE); }drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 9 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +9
-0+ +/** +* struct iecm_stats - definition for an ethtool statistic +* @stat_string: statistic name to display in ethtool -S output +* @sizeof_stat: the sizeof() the stat, must be no greater than +sizeof(u64) +* @stat_offset: offsetof() the stat from a base pointer +* +* This structure defines a statistic to be added to the ethtool stats buffer.
Quoted 21 lines
+ * It defines a statistic as offset from a common base pointer. Stats
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +20
-0+should + * be defined in constant arrays using the IECM_STAT macro, with +every element + * of the array using the same _type for calculating the sizeof_stat +and + * stat_offset. + * + * The @sizeof_stat is expected to be sizeof(u8), sizeof(u16), +sizeof (u32 ) or + * sizeof(u64). Other sizes are not expected and will produce a +WARN_ONCE from + * the iecm_add_ethtool_stat() helper function. + * + * The @stat_string is interpreted as a format string, allowing +formatted + * values to be inserted while looping over multiple structures for a +given + * statistics array. Thus, every statistic string in an array should +have the + * same type and number of format specifiers, to be formatted bydrivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +10
-0+variadic +* arguments to the iecm_add_stat_string() helper function. +*/ +struct iecm_stats { +char stat_string[ETH_GSTRING_LEN ]; +int sizeof_stat; +int stat_offset; +}; + +/* Helper macro to define an iecm_stat structure with proper size and type.
Quoted 16 lines
+ * Use this when defining constant statistics arrays. Note that
+ at_typeexpects
+ * only a type name and is used multiple times.
+ */drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +12
-0+#define IECM_STAT (_type, _name, _stat) { \ + .stat_string = _name, \ + .sizeof_stat = sizeof_field(_type, _stat), \ + .stat_offset = offsetof(_type, _stat) \ } + +/* Helper macro for defining some statistics related to queues */ +#define IECM_QUEUE_STAT (_name, _stat) \ + IECM_STAT(struct iecm_queue, _name, _stat) + +/* Stats associated with a Tx queue */ static const struct iecm_stats +iecm_gstrings_tx_queue_stats[] = { +IECM_QUEUE_STAT ("packets" , q_stats.tx.packets),drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +10
-0+IECM_QUEUE_STAT ("bytes" , q_stats.tx.bytes), + IECM_QUEUE_STAT("lso_pkts", q_stats.tx.lso_pkts), }; + +/* Stats associated with an Rx queue */ static const struct +iecm_stats iecm_gstrings_rx_queue_stats[] = { +IECM_QUEUE_STAT ("packets" , q_stats.rx.packets), +IECM_QUEUE_STAT ("bytes" , q_stats.rx.bytes), +IECM_QUEUE_STAT ("rsc_pkts" , q_stats.rx.rsc_pkts), }; + +#define IECM_TX_QUEUE_STATS_LEN
ARRAY_SIZE(iecm_gstrings_tx_queue_stats)Quoted 1 line
+#define
IECM_RX_QUEUE_STATS_LEN
ARRAY_SIZE(iecm_gstrings_rx_queue_stats)drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 6 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +6
-0+ +#define IECM_PORT_STAT (_name, _stat) \ + IECM_STAT(struct iecm_vport, _name, _stat) + +static const struct iecm_stats iecm_gstrings_port_stats[] = { + IECM_PORT_STAT("port-rx-csum_errors",port_stats.rx_hw_csum_err),
drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 6 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +6
-0+IECM_PORT_STAT ("port-rx-hsplit" , port_stats.rx_hsplit), +IECM_PORT_STAT ("port-rx-hsplit_hbo" , port_stats.rx_hsplit_hbo), +IECM_PORT_STAT ("tx-linearized_pkts" , port_stats.tx_linearize), +IECM_PORT_STAT ("rx-bad_descs" , port_stats.rx_bad_descs), +IECM_PORT_STAT ("port-rx_bytes" , port_stats.eth_stats.rx_bytes), + IECM_PORT_STAT("port-rx-unicast_pkts",port_stats.eth_stats.rx_unicast),
drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 1 line
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +1
-0+ IECM_PORT_STAT("port-rx-multicast_pkts",port_stats.eth_stats.rx_multicast),
drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 1 line
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +1
-0+ IECM_PORT_STAT("port-rx-broadcast_pkts",port_stats.eth_stats.rx_broadcast),
drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 2 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +2
-0+IECM_PORT_STAT ("port-rx-unknown_protocol" , +port_stats.eth_stats.rx_unknown_protocol),94-cols line.
drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 2 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +2
-0+IECM_PORT_STAT ("port-tx_bytes" , port_stats.eth_stats.tx_bytes), + IECM_PORT_STAT("port-tx-unicast_pkts",port_stats.eth_stats.tx_unicast),
drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 1 line
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +1
-0+ IECM_PORT_STAT("port-tx-multicast_pkts",port_stats.eth_stats.tx_multicast),
drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 1 line
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +1
-0+ IECM_PORT_STAT("port-tx-broadcast_pkts",port_stats.eth_stats.tx_broadcast),
drivers/net/ethernet/intel/iecm/iecm_ethtool.c line 425
Quoted 1 line
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +1
-0+ IECM_PORT_STAT("port-tx_errors", port_stats.eth_stats.tx_errors),};
Quoted 7 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +7
-0+ +#define IECM_PORT_STATS_LEN ARRAY_SIZE(iecm_gstrings_port_stats) + +struct iecm_priv_flags { +char flag_string[ETH_GSTRING_LEN ]; +bool read_only; +u32 bitno;drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +10
-0+}; + +#define IECM_PRIV_FLAG (_name, _bitno, _read_only) { \ + .read_only = _read_only, \ + .flag_string = _name, \ + .bitno = _bitno, \ +} + +static const struct iecm_priv_flags iecm_gstrings_priv_flags[] = { + IECM_PRIV_FLAG("header-split", __IECM_PRIV_FLAGS_HDR_SPLIT,0), };
drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 2 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +2
-0+ +#define IECM_PRIV_FLAGS_STR_LEN
ARRAY_SIZE(iecm_gstrings_priv_flags)Quoted 4 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +4
-0+ +/** +* __iecm_add_qstat_strings - copy stat strings into ethtool buffer +* @p: ethtool supplied buffer drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +10
-0+* @stats: stat definitions array +* @size: size of the stats array +* @type: stat type +* @idx: stat index +* +* Format and copy the strings described by stats into the buffer +pointed at +* by p. +*/ +static void __iecm_add_qstat_strings(u8 **p, const struct iecm_statsstats[],
Quoted 54 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +54
-0+ const unsigned int size, const char *type, + unsigned int idx) +{ + unsigned int i; + +for (i =0 ; i < size; i++) { +snprintf ((char *)*p,ETH_GSTRING_LEN , +"%2s-%u.%.17s" , type, idx, stats[i].stat_string); + *p +=ETH_GSTRING_LEN ; + } +} + +/** +* iecm_add_qstat_strings - Copy queue stat strings into ethtool +buffer +* @p: ethtool supplied buffer +* @stats: stat definitions array +* @type: stat type +* @idx: stat idx +* +* Format and copy the strings described by the const static stats +value into +* the buffer pointed at by p. +* +* The parameter @stats is evaluated twice, so parameters with side +effects +* should be avoided. Additionally, stats must be an array such that +* ARRAY_SIZE can be called on it. +*/ +#define iecm_add_qstat_strings (p, stats, type, idx) \ + __iecm_add_qstat_strings(p, stats, ARRAY_SIZE(stats), type, idx) + +/** +* iecm_add_port_stat_strings - Copy port stat strings into ethtool +buffer +* @p: ethtool buffer +* @stats: struct to copy from +*/ +static void iecm_add_port_stat_strings (u8 **p,const struct +iecm_stats stats[]) { +const unsigned int size =IECM_PORT_STATS_LEN ; +unsigned int i; + +for (i =0 ; i < size; i++) { +snprintf ((char *)*p,ETH_GSTRING_LEN ,"%.32s" , + stats[i].stat_string); + *p +=ETH_GSTRING_LEN ; + } +} + +/** +* iecm_get_stat_strings - Get stat strings +* @netdev: network interface device structure +* @data: buffer for string data drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +10
-0+* +* Builds the statistics string table */ static void +iecm_get_stat_strings (struct net_device *netdev,u8 *data) { +struct iecm_vport *vport =iecm_netdev_to_vport (netdev); +unsigned int i; +u16 max_q; + +iecm_add_port_stat_strings (&data, iecm_gstrings_port_stats); + +/* It's critical that we always report a constant number of strings and
drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 7 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +7
-0+* that the strings are reported in the same order regardless of how +* many queues are actually in use. +*/ + max_q = vport->adapter->max_queue_limit; + +for (i =0 ; i < max_q; i++) + iecm_add_qstat_strings(&data,
iecm_gstrings_tx_queue_stats,drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 3 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +3
-0+ "tx", i); +for (i =0 ; i < max_q; i++) + iecm_add_qstat_strings(&data,
iecm_gstrings_rx_queue_stats,Quoted 54 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +54
-0+ "rx", i); +} + +/** +* iecm_get_priv_flag_strings - Get private flag strings +* @netdev: network interface device structure +* @data: buffer for string data +* +* Builds the private flags string table */ static void +iecm_get_priv_flag_strings (struct net_device *netdev,u8 *data) { +unsigned int i; + +for (i =0 ; i <IECM_PRIV_FLAGS_STR_LEN ; i++) { +snprintf ((char *)data,ETH_GSTRING_LEN ,"%s" , + iecm_gstrings_priv_flags[i].flag_string); + data +=ETH_GSTRING_LEN ; + } +} + +/** +* iecm_get_priv_flags - report device private flags +* @dev: network interface device structure +* +* The get string set count and the string set should be matched for +each +* flag returned. Add new strings for each flag to the +iecm_gstrings_priv_flags +* array. +* +* Returns a u32 bitmap of flags. +**/ +static u32 iecm_get_priv_flags (struct net_device *dev) { +struct iecm_netdev_priv *np =netdev_priv (dev); +struct iecm_user_config_data *user_data; +struct iecm_vport *vport = np->vport; +u32 i, ret_flags =0 ; + + user_data = &vport->adapter->config_data; + +for (i =0 ; i <IECM_PRIV_FLAGS_STR_LEN ; i++) { +const struct iecm_priv_flags *priv_flag; + + priv_flag = &iecm_gstrings_priv_flags[i]; + +if (test_bit (priv_flag->bitno, user_data->user_flags)) + ret_flags |=BIT (i); + } + +return ret_flags; +} + +/** +* iecm_set_priv_flags - set private flags +* @dev: network interface device structure
Quoted 9 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c line 593
Quoted 6 lines
+ * @flags: bit flags to be set
+ **/drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +4
-0+static int iecm_set_priv_flags (struct net_device *dev,u32 flags) { +struct iecm_netdev_priv *np =netdev_priv (dev); +DECLARE_BITMAP (change_flags, __IECM_USER_FLAGS_NBITS); +DECLARE_BITMAP (orig_flags, __IECM_USER_FLAGS_NBITS);RCT.
Will fix.
Quoted 37 lines
Quoted 25 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +25
-0+struct iecm_user_config_data *user_data; +struct iecm_vport *vport = np->vport; +bool is_reset_needed; +int err =0 ; +u32 i; + +if (flags >BIT (IECM_PRIV_FLAGS_STR_LEN )) +return -EINVAL ; + + user_data = &vport->adapter->config_data; + +bitmap_copy (orig_flags, user_data->user_flags, +__IECM_USER_FLAGS_NBITS); + +for (i =0 ; i <IECM_PRIV_FLAGS_STR_LEN ; i++) { +const struct iecm_priv_flags *priv_flag; + + priv_flag = &iecm_gstrings_priv_flags[i]; + +if (flags &BIT (i)) { +/* If this is a read-only flag, it can't be changed */ +if (priv_flag->read_only) +return -EOPNOTSUPP ; + +set_bit (priv_flag->bitno, user_data->user_flags);drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +10
-0+ }else { +clear_bit (priv_flag->bitno, user_data->user_flags); + } + } + +bitmap_xor (change_flags, user_data->user_flags, + orig_flags, __IECM_USER_FLAGS_NBITS); + + is_reset_needed = + !!(test_bit(__IECM_PRIV_FLAGS_HDR_SPLIT,
change_flags));
Quoted 2 lines
Shorter name would allow avoiding line break.
For IECM_PRIV_FLAGS_HDR_SPLIT? Sure we're open to suggestion if you have a name that communicates the same level of information effectively.
Quoted 22 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 6 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +6
-0+ +/* Issue reset to cause things to take effect, as additional bits +* are added we will need to create a mask of bits requiring reset +*/ +if (is_reset_needed) + err = iecm_initiate_soft_reset(vport,
__IECM_SR_HSPLIT_CHANGE);Quoted 15 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +15
-0+ +return err; +} + +/** +* iecm_get_strings - Get string set +* @netdev: network interface device structure +* @sset: id of string set +* @data: buffer for string data +* +* Builds string tables for various string sets */ static void +iecm_get_strings (struct net_device *netdev,u32 sset,u8 *data) { +switch (sset) { +case ETH_SS_STATS : +iecm_get_stat_strings (netdev, data);
Quoted 9 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c line 656
Quoted 6 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +6
-0+break ; +case ETH_SS_PRIV_FLAGS : +iecm_get_priv_flag_strings (netdev, data); +break ; +default : +break ;Equivalent to not having a 'default' case.
Yes static tools will complain about uncaught switch without it.
Quoted 29 lines
Quoted 7 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +7
-0+ } +} + +/** +* iecm_get_sset_count - Get length of string set +* @netdev: network interface device structure +* @sset: id of string set drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +10
-0+* +* Reports size of various string tables. +*/ +static +int iecm_get_sset_count (struct net_device *netdev,int sset) { +if (sset ==ETH_SS_STATS ) { +struct iecm_vport *vport =iecm_netdev_to_vport (netdev); +u16 max_q; + +/* This size reported back here *must* be constant throughout
drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 2 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +2
-0+* the lifecycle of the netdevice, i.e. we must report the +* maximum length even for queues that don't technically exist.
drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 3 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +3
-0+* This is due to the fact that this userspace API uses three +* separate ioctl calls to get stats data but has no way to +* communicate back to userspace when that size has changed,
drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 1 line
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +1
-0+* which can typically happen as a result of changing number of
drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 1 line
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +1
-0+* queues. If the number/order of stats change in the middle of
Quoted 15 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c line 693
Quoted 12 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +12
-0+* this call chain it will lead to userspace crashing/accessing +* bad data through buffer under/overflow. +*/ + max_q = vport->adapter->max_queue_limit; + +return IECM_PORT_STATS_LEN + + (IECM_TX_QUEUE_STATS_LEN * max_q) + + (IECM_RX_QUEUE_STATS_LEN * max_q); + }else if (sset ==ETH_SS_PRIV_FLAGS ) { +return IECM_PRIV_FLAGS_STR_LEN ; + }else { +return -EINVAL ;Check for this at first and save 1 level of indentation for
ETH_SS_STATS.
So you would have it something like:
if (sset != ETH_SS_STATS && sset != ETH_SS_PRIV_FLAGS)
return -EINVAL
if (sset == ETH_SS_PRIV_FLAGS)
return IECM_PRIV_FLAGS_STR_LEN
/* if sset code */
This to me seems less readable because now the reader has to identify the bottom half of the function is actually for the SSET case whereas the way it is written currently, it's very explicit about what we're doing for what. I commend the intent to shave off indents where possible but many of these indent suggestions are teetering on excessive and sacrificing readability to save a tab.
Quoted 150 lines
Quoted 47 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +47
-0+ } +} + +/** +* iecm_add_one_ethtool_stat - copy the stat into the supplied buffer +* @data: location to store the stat value +* @pstat: old stat pointer to copy from +* @stat: the stat definition +* +* Copies the stat data defined by the pointer and stat structure +pair into +* the memory supplied as data. Used to implement +iecm_add_ethtool_stats and +* iecm_add_queue_stats. If the pointer is null, data will be zero'd. +*/ +static void +iecm_add_one_ethtool_stat (u64 *data,void *pstat, +const struct iecm_stats *stat) +{ +char *p; + +if (!pstat) { +/* Ensure that the ethtool data buffer is zero'd for any stats +* which don't have a valid pointer. +*/ + *data =0 ; +return ; + } + + p = (char *)pstat + stat->stat_offset; +switch (stat->sizeof_stat) { +case sizeof (u64): + *data = *((u64 *)p); +break ; +case sizeof (u32): + *data = *((u32 *)p); +break ; +case sizeof (u16): + *data = *((u16 *)p); +break ; +case sizeof (u8): + *data = *((u8 *)p); +break ; +default : +WARN_ONCE (1 ,"unexpected stat size for %s" , + stat->stat_string); + *data =0 ;drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +10
-0+ } +} + +/** +* iecm_add_queue_stats - copy queue statistics into supplied buffer +* @data: ethtool stats buffer +* @q: the queue to copy +* +* Queue statistics must be copied while protected by +* u64_stats_fetch_begin_irq, so we can't directly use
iecm_add_ethtool_stats.Quoted 24 lines
+ * Assumes that queue stats are defined in
iecm_gstrings_queue_stats.drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +23
-0+If the +* queue pointer is null, zero out the queue stat values and update +the data +* pointer. Otherwise safely copy the stats from the queue into the +supplied +* buffer and update the data pointer when finished. +* +* This function expects to be called while under rcu_read_lock(). +*/ +static void +iecm_add_queue_stats (u64 **data,struct iecm_queue *q) { +const struct iecm_stats *stats; +unsigned int start; +unsigned int size; +unsigned int i; + +if (q->q_type ==VIRTCHNL2_QUEUE_TYPE_RX ) { + size =IECM_RX_QUEUE_STATS_LEN ; + stats = iecm_gstrings_rx_queue_stats; + }else { + size =IECM_TX_QUEUE_STATS_LEN ; + stats = iecm_gstrings_tx_queue_stats; + }drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +10
-0+ +/* To avoid invalid statistics values, ensure that we keep retrying +* the copy until we get a consistent value according to +* u64_stats_fetch_retry_irq. But first, make sure our queue is +* non-null before attempting to access its syncp. +*/ + do { + start = u64_stats_fetch_begin_irq(&q->stats_sync); + for (i = 0; i < size; i++) + iecm_add_one_ethtool_stat(&(*data)[i], q,&stats[i]);
drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 3 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +3
-0+ }while (u64_stats_fetch_retry_irq (&q->stats_sync, start)); + +/* Once we successfully copy the stats in, update the data pointer */
Quoted 49 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +48
-0+ *data += size; +} + +/** +* iecm_add_empty_queue_stats - Add stats for a non-existent queue +* @data: pointer to data buffer +* @qtype: type of data queue +* +* We must report a constant length of stats back to userspace +regardless of +* how many queues are actually in use because stats collection +happens over +* three separate ioctls and there's no way to notify userspace the +size +* changed between those calls. This adds empty to data to the stats +since we +* don't have a real queue to refer to for this stats slot. +*/ +static void +iecm_add_empty_queue_stats (u64 **data,u16 qtype) { +unsigned int i; +int stats_len; + +if (qtype ==VIRTCHNL2_QUEUE_TYPE_RX ) + stats_len =IECM_RX_QUEUE_STATS_LEN ; +else + stats_len =IECM_TX_QUEUE_STATS_LEN ; + +for (i =0 ; i < stats_len; i++) + (*data)[i] =0 ; + *data += stats_len; +} + +/** +* iecm_add_port_stats - Copy port stats into ethtool buffer +* @vport: virtual port struct + * @data: ethtool buffer to copy into */ static void +iecm_add_port_stats(struct iecm_vport *vport, u64 **data) { + unsigned int size = IECM_PORT_STATS_LEN; + unsigned int start; + unsigned int i; + + /* To avoid invalid statistics values, ensure that we keep retrying + * the copy until we get a consistent value according to + * u64_stats_fetch_retry_irq. + */ + do { + start = u64_stats_fetch_begin_irq(&vport-port_stats.stats_sync);
drivers/net/ethernet/intel/iecm/iecm_ethtool.c line 836
Quoted 3 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +3
-0+for (i =0 ; i < size; i++) { + iecm_add_one_ethtool_stat(&(*data)[i], vport, +&iecm_gstrings_port_stats[i]);
Quoted 4 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 1 line
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +1
-0+ }Redundant braces.
I believe this is multi line with wrapping. Will not fix.
Quoted 380 lines
Quoted 6 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +6
-0+ }while (u64_stats_fetch_retry_irq (&vport->port_stats.stats_sync, +start)); + + *data += size; +} +drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +10
-0+/** +* iecm_get_ethtool_stats - report device statistics +* @netdev: network interface device structure +* @stats: ethtool statistics structure +* @data: pointer to data buffer +* +* All statistics are added to the data buffer as an array of u64. +*/ +static void iecm_get_ethtool_stats (struct net_device *netdev, + struct ethtool_stats __always_unused*stats,
Redundant
__always_unused.Quoted 18 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +18
-0+ u64 *data) +{ +struct iecm_vport *vport =iecm_netdev_to_vport (netdev); +unsigned int total =0 ; +unsigned int i, j; +u16 max_q, qtype; + +if (vport->adapter->state != __IECM_UP) +return ; + +set_bit (__IECM_MB_STATS_PENDING, vport->adapter->flags); + + max_q = vport->adapter->max_queue_limit; + +rcu_read_lock (); + +iecm_add_port_stats (vport, &data); +drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +10
-0+for (i =0 ; i < vport->num_txq_grp; i++) { +struct iecm_txq_group *txq_grp = &vport->txq_grps[i]; + + qtype =VIRTCHNL2_QUEUE_TYPE_TX ; + +for (j =0 ; j < txq_grp->num_txq; j++, total++) { +struct iecm_queue *txq = txq_grp->txqs[j]; + +if (!txq) + iecm_add_empty_queue_stats(&data,qtype);
drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 6 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +6
-0+else +iecm_add_queue_stats (&data, txq); + } + } +/* It is critical we provide a constant number of stats back to +* userspace regardless of how many queues are actually in use because
drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 1 line
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +1
-0+* there is no way to inform userspace the size has changed between
drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 4 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +4
-0+* ioctl calls. This will fill in any missing stats with zero. +*/ +for (; total < max_q; total++) + iecm_add_empty_queue_stats(&data,
VIRTCHNL2_QUEUE_TYPE_TX);Quoted 12 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +12
-0+ total =0 ; + +for (i =0 ; i < vport->num_rxq_grp; i++) { +struct iecm_rxq_group *rxq_grp = &vport->rxq_grps[i]; +int num_rxq; + + qtype =VIRTCHNL2_QUEUE_TYPE_RX ; + +if (iecm_is_queue_model_split (vport->rxq_model)) + num_rxq = rxq_grp->splitq.num_rxq_sets; +else + num_rxq = rxq_grp->singleq.num_rxq;drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +10
-0+ +for (j =0 ; j < num_rxq; j++, total++) { +struct iecm_queue *rxq; + +if (iecm_is_queue_model_split (vport->rxq_model)) + rxq = &rxq_grp->splitq.rxq_sets[j]->rxq; +else + rxq = rxq_grp->singleq.rxqs[j]; +if (!rxq) + iecm_add_empty_queue_stats(&data,qtype);
drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 6 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +6
-0+else +iecm_add_queue_stats (&data, rxq); + } + } +for (; total < max_q; total++) + iecm_add_empty_queue_stats(&data,
VIRTCHNL2_QUEUE_TYPE_RX);Quoted 70 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +61
-0+rcu_read_unlock (); +} + +/** +* iecm_find_rxq - find rxq from q index +* @vport: virtual port associated to queue +* @q_num: q index used to find queue +* +* returns pointer to rx queue +*/ +static struct iecm_queue * +iecm_find_rxq (struct iecm_vport *vport,int q_num) { +struct iecm_queue *rxq; + +if (iecm_is_queue_model_split (vport->rxq_model)) { +int q_grp, q_idx; + + q_grp = q_num /IECM_DFLT_SPLITQ_RXQ_PER_GROUP ; + q_idx = q_num %IECM_DFLT_SPLITQ_RXQ_PER_GROUP ; + + rxq = &vport->rxq_grps[q_grp].splitq.rxq_sets[q_idx]->rxq; + }else { + rxq = vport->rxq_grps->singleq.rxqs[q_num]; + } + +return rxq; +} + +/** +* iecm_find_txq - find txq from q index +* @vport: virtual port associated to queue +* @q_num: q index used to find queue +* +* returns pointer to tx queue +*/ +static struct iecm_queue * +iecm_find_txq (struct iecm_vport *vport,int q_num) { +struct iecm_queue *txq; + +if (iecm_is_queue_model_split (vport->txq_model)) { +int q_grp = q_num /IECM_DFLT_SPLITQ_TXQ_PER_GROUP ; + + txq = vport->txq_grps[q_grp].complq; + }else { + txq = vport->txqs[q_num]; + } + +return txq; +} + +/** +* __iecm_get_q_coalesce - get ITR values for specific queue +* @ec: ethtool structure to fill with driver's coalesce settings +* @q: quuee of Rx or Tx +*/ +static void +__iecm_get_q_coalesce (struct ethtool_coalesce *ec,struct iecm_queue +*q) { +if (q->q_type ==VIRTCHNL2_QUEUE_TYPE_RX ) { + ec->use_adaptive_rx_coalesce = + IECM_ITR_IS_DYNAMIC(q->q_vector-
rx_intr_mode);drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +4
-0+ ec->rx_coalesce_usecs = q->q_vector->rx_itr_value; + }else { + ec->use_adaptive_tx_coalesce = + IECM_ITR_IS_DYNAMIC(q->q_vector-
tx_intr_mode);drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +3
-0+ ec->tx_coalesce_usecs = q->q_vector->tx_itr_value; + } +}drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +10
-0+ +/** +* iecm_get_q_coalesce - get ITR values for specific queue +* @netdev: pointer to the netdev associated with this query +* @ec: coalesce settings to program the device with +* @q_num: update ITR/INTRL (coalesce) settings for this queue +number/index +* +* Return 0 on success, and negative on failure */ static int +iecm_get_q_coalesce(struct net_device *netdev, struct ethtool_coalesce*ec,
Quoted 24 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +24
-0+ u32 q_num) +{ +struct iecm_vport *vport =iecm_netdev_to_vport (netdev); + +if (vport->adapter->state != __IECM_UP) +return 0 ; + +if (q_num >= vport->num_rxq && q_num >= vport->num_txq) +return -EINVAL ; + +if (q_num < vport->num_rxq) { +struct iecm_queue *rxq =iecm_find_rxq (vport, q_num); + +__iecm_get_q_coalesce (ec, rxq); + } + +if (q_num < vport->num_txq) { +struct iecm_queue *txq =iecm_find_txq (vport, q_num); + +__iecm_get_q_coalesce (ec, txq); + } + +return 0 ; +}drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +10
-0+ +/** +* iecm_get_coalesce - get ITR values as requested by user +* @netdev: pointer to the netdev associated with this query +* @ec: coalesce settings to be filled +* @kec: unused +* @extack: unused +* +* Return 0 on success, and negative on failure */ static int +iecm_get_coalesce(struct net_device *netdev, struct ethtool_coalesce*ec,
drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 2 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +2
-0+struct kernel_ethtool_coalesce __always_unused *kec, + struct netlink_ext_ack __always_unused *extack)
__always_unused.Quoted 36 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +36
-0+{ +/* Return coalesce based on queue number zero */ +return iecm_get_q_coalesce (netdev, ec,0 ); } + +/** +* iecm_get_per_q_coalesce - get ITR values as requested by user +* @netdev: pointer to the netdev associated with this query +* @q_num: queue for which the itr values has to retrieved +* @ec: coalesce settings to be filled +* +* Return 0 on success, and negative on failure */ + +static int +iecm_get_per_q_coalesce (struct net_device *netdev,u32 q_num, +struct ethtool_coalesce *ec) +{ +return iecm_get_q_coalesce (netdev, ec, q_num); } + +/** +* __iecm_set_q_coalesce - set ITR values for specific queue +* @ec: ethtool structure from user to update ITR settings +* @q: queue for which itr values has to be set +* +* Returns 0 on success, negative otherwise. +*/ +static int +__iecm_set_q_coalesce (struct ethtool_coalesce *ec,struct iecm_queue +*q) { +u32 use_adaptive_coalesce, coalesce_usecs; +struct iecm_q_vector *qv = q->q_vector; +struct iecm_vport *vport; +bool is_dim_ena = false; + + vport = q->vport; +if (q->q_type ==VIRTCHNL2_QUEUE_TYPE_RX ) { + is_dim_ena =IECM_ITR_IS_DYNAMIC (qv->rx_intr_mode);drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +10
-0+ use_adaptive_coalesce = ec->use_adaptive_rx_coalesce; + coalesce_usecs = ec->rx_coalesce_usecs; + }else { + is_dim_ena =IECM_ITR_IS_DYNAMIC (qv->tx_intr_mode); + use_adaptive_coalesce = ec->use_adaptive_tx_coalesce; + coalesce_usecs = ec->tx_coalesce_usecs; + } + +if (coalesce_usecs && use_adaptive_coalesce) { + netdev_info(vport->netdev, "Cannot set coalesce usecs ifadaptive enabled\n");
Quoted 6 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +6
-0+return -EINVAL ; + } + +if (is_dim_ena && use_adaptive_coalesce) +return 0 ; +drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +10
-0+if (coalesce_usecs >IECM_ITR_MAX ) { +netdev_info (vport->netdev, +"Invalid value, %d-usecs range is 0-%d\n" , + coalesce_usecs,IECM_ITR_MAX ); +return -EINVAL ; + } + +if (coalesce_usecs %2 !=0 ) { + coalesce_usecs = coalesce_usecs &0xFFFFFFFE ; + netdev_info(vport->netdev, "HW only supports even ITRvalues, ITR rounded to %d\n",
Quoted 9 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +9
-0+ coalesce_usecs); + } + +if (q->q_type ==VIRTCHNL2_QUEUE_TYPE_RX ) { + qv->rx_itr_value = coalesce_usecs; +if (use_adaptive_coalesce) { + qv->rx_intr_mode =IECM_ITR_DYNAMIC ; + }else { + qv->rx_intr_mode = !IECM_ITR_DYNAMIC ;drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +10
-0+iecm_vport_intr_write_itr (qv, qv->rx_itr_value, + false); + } + }else { + qv->tx_itr_value = coalesce_usecs; +if (use_adaptive_coalesce) { + qv->tx_intr_mode =IECM_ITR_DYNAMIC ; + }else { + qv->tx_intr_mode = !IECM_ITR_DYNAMIC ; + iecm_vport_intr_write_itr(qv, qv->tx_itr_value,true);
Quoted 8 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +8
-0+ } + } +/* Update of static/dynamic itr will be taken care when interrupt is +* fired +*/ +return 0 ; +} +drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +10
-0+/** +* iecm_set_q_coalesce - set ITR values for specific queue +* @vport: vport associated to the queue that need updating +* @ec: coalesce settings to program the device with +* @q_num: update ITR/INTRL (coalesce) settings for this queue +number/index +* @is_rxq: is queue type rx +* +* Return 0 on success, and negative on failure */ static int +iecm_set_q_coalesce(struct iecm_vport *vport, struct ethtool_coalesce*ec,
Quoted 14 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +14
-0+ int q_num, bool is_rxq) +{ +struct iecm_queue *q; + +if (is_rxq) + q =iecm_find_rxq (vport, q_num); +else + q =iecm_find_txq (vport, q_num); + +if (q &&__iecm_set_q_coalesce (ec, q)) +return -EINVAL ; + +return 0 ; +}drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +10
-0+ +/** +* iecm_set_coalesce - set ITR values as requested by user +* @netdev: pointer to the netdev associated with this query +* @ec: coalesce settings to program the device with +* @kec: unused +* @extack: unused +* +* Return 0 on success, and negative on failure */ static int +iecm_set_coalesce(struct net_device *netdev, struct ethtool_coalesce*ec,
Quoted 38 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +38
-0+struct kernel_ethtool_coalesce __always_unused *kec, + struct netlink_ext_ack __always_unused *extack) { + struct iecm_vport *vport = iecm_netdev_to_vport(netdev); +int i, err; + +if (vport->adapter->state != __IECM_UP) +return 0 ;Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Quoted 9 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 2 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +2
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
err = iecm_set_q_coalesce(vport, ec, q_num, false); if (err) return err; return iecm_set_q_coalesce(vport, ec, q_num, true);
Will fix
Quoted 108 lines
Quoted 108 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +108
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Quoted 9 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 5 lines
3 lines not shown · raw message
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +2
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
2 lines not shown · raw message
60 lines not shown · raw message
Parts of this message are not shown here. View the raw message.
PATCH 15/19 iecm: implement ethtool callbacks
From: Alan Brady <[email protected]>
Date: Thu, 3 Feb 2022 03:13:41 +0100
Quoted 67 lines
Quoted 67 lines
-----Original Message-----
From: Lobakin, Alexandr <[email protected]>
Sent: Friday, January 28, 2022 10:14 AM
To: Brady, Alan <[email protected]>
Cc: Lobakin, Alexandr <[email protected]>; intel-wired- lan at lists.osuosl.org; Burra, Phani R <[email protected]>; Chittim, Madhu <[email protected]>; Linga, Pavan Kumar <[email protected]>
Subject: Re: [Intel-wired-lan] [PATCH net-next 15/19] iecm: implement ethtool callbacksFrom: Alan Brady <[email protected]>
Date: Thu, 27 Jan 2022 16:10:05 -0800Quoted 4 lines
This does everything needed to handle ethtool ops minus a few stubs for cloud filters and other advanced features which will be added in later in this series.
Quoted 8 lines
Signed-off-by Phani Burra <[email protected]>Signed-off-by Joshua Hay <[email protected]>Signed-off-by Madhu Chittim <[email protected]>Signed-off-by Pavan Kumar Linga <[email protected]>Signed-off-by Alan Brady <[email protected]>--- drivers/net/ethernet/intel/iecm/Makefile | 1 + .../net/ethernet/intel/iecm/iecm_ethtool.c | 1325+++++++++++++++++
Quoted 29 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c | 11 +- drivers/net/ethernet/intel/include/iecm.h | 1 + 4 files changed, 1337 insertions(+), 1 deletion(-) create mode100644
drivers/net/ethernet/intel/iecm/iecm_ethtool.cdrivers/net/ethernet/intel/iecm/Makefile +1
-0@@ -15,6 +15,7 @@ iecm-y := \ iecm_virtchnl.o \ iecm_txrx.o \ iecm_singleq_txrx.o \ + iecm_ethtool.o \ iecm_controlq.o \ iecm_controlq_setup.o \ iecm_main.odrivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +4
-0@@ -0,0 +1,1325 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* Copyright (C) 2019 Intel Corporation */ + +#include "iecm.h" drivers/net/ethernet/intel/iecm/iecm_ethtool.c line 14
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +10
-0+ +/** +* iecm_get_rxnfc - command to get RX flow classification rules +* @netdev: network interface device structure +* @cmd: ethtool rxnfc command +* @rule_locs: pointer to store rule locations +* +* Returns Success if the command is supported. +*/ +static int iecm_get_rxnfc(struct net_device *netdev, struct ethtool_rxnfc*cmd,
Quoted 8 lines
Quoted 6 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c line 15
Quoted 1 line
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +1
-0+ u32 __always_unused *rule_locs)Kernel
Kbuildsystem tell compilers to not complain on unused function arguments.
It's pointless to add__always_unusedhere.Sparse does complain about it (e.g. make ... C=2) and it's present in other (non-Intel) network drivers. I think I need a better argument to remove it.
No, it doesn't.
No, it's not.
Mellanox and ChelsIO almost never mark unused arguments, see e.g. to [0] and [1] for reference.
And their drivers build cleanly with the latest sparse 0.6.4.
I've been using it for more than two years already and can't recall a single episode when it would've complained about unused arguments. If you talk about OOT, please clearly state this, to not confuse me and other reviewers.
Marking unused arguments as __always_unused is at least a deprecation and is not recommended for any new code. Kbuild (kernel build system) explicitly sets -Wno-unused-parameter ([2]) to disable this warning when building with -Wextra (W=1+).
This is due to that almost any driver has at least one (usually much more) callback, and if we would've marked every unused argument with this attribute, there would've been 1.5 times more lines of code.
Is this enough?
Quoted 3 lines
Quoted 3 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c line 17
Quoted 3 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +2
-0+{ +struct iecm_vport *vport =iecm_netdev_to_vport (netdev);
--- 8< ---
Quoted 7 lines
Quoted 7 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 6 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +6
-0+if (adapter->virt_ver_maj <VIRTCHNL_VERSION_MAJOR_2 ) { + err = adapter->dev_ops.vc_ops.add_queues (vport, + num_req_tx_q,0 , + num_req_rx_q,0 ); + }else { + err = iecm_initiate_soft_reset(vport,
__IECM_SR_Q_CHANGE);
Quoted 6 lines
Quoted 4 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c line 24
Quoted 1 line
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +1
-0+ }One-liners, no need for braces.
The
ifexists across multiple lines so we would prefer to keep braces. As such the 'else' also gets them.
Please refer to my previous messages. There shouldn't be any braces, unless they're required for code to work properly (except for symmetrical if-else).
Quoted 3 lines
Quoted 3 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c line 26
Quoted 3 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +2
-0+ +if (err) {
--- 8< ---
Quoted 9 lines
Quoted 7 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 3 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +3
-0+ + is_reset_needed = + !!(test_bit(__IECM_PRIV_FLAGS_HDR_SPLIT,
change_flags));Shorter name would allow avoiding line break.
For
IECM_PRIV_FLAGS_HDR_SPLIT? Sure we're open to suggestion if you have a name that communicates the same level of information effectively.
For is_reset_needed. HDR_SPLIT is perfect to me.
Quoted 3 lines
Quoted 3 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c line 629
Quoted 3 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +2
-0+ +/* Issue reset to cause things to take effect, as additional bits
--- 8< ---
Quoted 10 lines
Quoted 8 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c line 656
Quoted 5 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +5
-0+case ETH_SS_PRIV_FLAGS : +iecm_get_priv_flag_strings (netdev, data); +break ; +default : +break ;Equivalent to not having a 'default' case.
Yes static tools will complain about uncaught switch without it.
Such as? Can I get some more details please?
Is this again for OOT or for the upstream kernel as well? I think I can recall some initiatives in the past to enable -Wswitch-default, but all of them were cancelled due to that it's pointless to have default just to satisfy some checkers and, unlike e.g. fallthrough, this has a very little benefit.
Now you can get it only on W=3 level which nobody takes seriosly.
Quoted 6 lines
Quoted 6 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c line 661
Quoted 6 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +5
-0+ } +} + +/** +* iecm_get_sset_count - Get length of string set
--- 8< ---
Quoted 17 lines
Quoted 11 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c line 693
Quoted 8 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +8
-0+ +return IECM_PORT_STATS_LEN + + (IECM_TX_QUEUE_STATS_LEN * max_q) + + (IECM_RX_QUEUE_STATS_LEN * max_q); + }else if (sset ==ETH_SS_PRIV_FLAGS ) { +return IECM_PRIV_FLAGS_STR_LEN ; + }else { +return -EINVAL ;Check for this at first and save 1 level of indentation for
ETH_SS_STATS.So you would have it something like:
if (sset !=
ETH_SS_STATS&& sset !=ETH_SS_PRIV_FLAGS)
return-EINVAL
Quoted 6 lines
if (sset ==
ETH_SS_PRIV_FLAGS)
returnIECM_PRIV_FLAGS_STR_LEN/* if sset code */
This to me seems less readable because now the reader has to identify the bottom half of the function is actually for the SSET case whereas the way it is written currently, it's very explicit about what we're doing for what. I commend the intent to shave off indents where possible but many of these indent suggestions are teetering on excessive and sacrificing readability to save a tab.
You guessed a correct comment block here, if you feel that some code is not super-intuitive, you can always add a short comment to give a hint.
What more important for readability is to keep the code as flat as possible, otherwise the main eye focus should be moved to the right, plus 79-col limits starts wrapping more and more lines which doesn't improve readability either.
It means that the longest code blocks should usually have a single Tab indent.
I'm not speaking for this particular function right now -- I'm fine with having all of it at 2 Tabs, it's just a big comment block which makes it look like a big chunk of code. But at least make it a switch-case then I guess?
Quoted 6 lines
Quoted 6 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c line 698
Quoted 6 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +5
-0+ } +} + +/** +* iecm_add_one_ethtool_stat - copy the stat into the supplied buffer
--- 8< ---
Quoted 7 lines
Quoted 7 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c line 836
Quoted 6 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +2
-0+ do { + start = u64_stats_fetch_begin_irq(&vport-port_stats.stats_sync);
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +3
-0+for (i =0 ; i < size; i++) { + iecm_add_one_ethtool_stat(&(*data)[i], vport, +&iecm_gstrings_port_stats[i]);
Quoted 6 lines
Quoted 4 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 1 line
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +1
-0+ }Redundant braces.
I believe this is multi line with wrapping. Will not fix.
Explained previously.
Quoted 9 lines
Quoted 9 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c line 841
Quoted 9 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +8
-0+ }while (u64_stats_fetch_retry_irq (&vport->port_stats.stats_sync, +start)); + + *data += size; +} + +/** +* iecm_get_ethtool_stats - report device statistics
--- 8< ---
Quoted 8 lines
Quoted 6 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c
Quoted 2 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c new file +2
-0+void iecm_set_ethtool_ops (struct net_device *netdev) { + netdev->ethtool_ops = &iecm_ethtool_ops; }Declaring @iecm_ethtool_ops as external and directly assigning it in
iecm_cfg_netdev()would result in smaller code size than this.It seems trivial either way, but I'm having a hard time justifying this function, so will fix.
Some people believe ops structs should be not only const, but also static. I don't really get why, but it's somewhat common across different subsystems.
There's nothing bad in having ethtool_ops global, at the same time global functions really occupy much more space than global variables, so just a suggestion here to avoid that.
Quoted 2 lines
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +0
-0
--- 8< ---
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
--
2.33.0
I'm sorry, I'll get back to your replies on patch #16 and further in about 14 hours.
Quoted 3 lines
Quoted 3 lines
Thanks,
Al
[0] https://elixir.bootlin.com/linux/v5.17-rc2/source/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c#L1736
[1] https://elixir.bootlin.com/linux/v5.17-rc2/source/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/tx.c#L10
[2] https://elixir.bootlin.com/linux/v5.17-rc2/source/scripts/Makefile.extrawarn#L25
Thanks,
Al
PATCH 16/19 iecm: implement flow director
In reply to Alan BradyFrom: Haiyue Wang <[email protected]>
This adds everthing needed to do flow director commands.
--- .../net/ethernet/intel/iecm/iecm_ethtool.c | 17 +- drivers/net/ethernet/intel/iecm/iecm_lib.c | 1528 ++++++++++++++++- .../net/ethernet/intel/iecm/iecm_virtchnl.c | 119 ++ drivers/net/ethernet/intel/include/iecm.h | 112 ++ 4 files changed, 1770 insertions(+), 6 deletions(-)
drivers/net/ethernet/intel/iecm/iecm_ethtool.c +12 -5
@@ -15,6 +15,7 @@ static int iecm_get_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd, u32 __always_unused *rule_locs) {struct iecm_vport *vport =iecm_netdev_to_vport (netdev); +struct iecm_adapter *adapter = vport->adapter;int ret = -EOPNOTSUPP ;switch (cmd->cmd) {
@@ -23,14 +24,19 @@ static int iecm_get_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd, ret =0 ;break ;case ETHTOOL_GRXCLSRLCNT : -/* stub */ +if (!iecm_is_cap_ena (adapter,IECM_OTHER_CAPS , +VIRTCHNL2_CAP_FDIR )) +break ; + cmd->rule_cnt = + adapter->config_data.fdir_config.num_active_filters; + cmd->data =IECM_MAX_FDIR_FILTERS ; ret =0 ;break ;case ETHTOOL_GRXCLSRULE : -/* stub */ + ret =iecm_get_fdir_fltr_entry (vport, cmd);break ;case ETHTOOL_GRXCLSRLALL : -/* stub */ + ret =iecm_get_fdir_fltr_ids (vport, cmd, (u32 *)rule_locs);break ;case ETHTOOL_GRXFH :/* stub */
@@ -51,14 +57,15 @@ static int iecm_get_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd,*/ static int iecm_set_rxnfc (struct net_device *netdev,struct ethtool_rxnfc *cmd) { +struct iecm_vport *vport =iecm_netdev_to_vport (netdev);int ret = -EOPNOTSUPP ;switch (cmd->cmd) {case ETHTOOL_SRXCLSRLINS : -/* stub */ + ret =iecm_add_fdir_fltr (vport, cmd);break ;case ETHTOOL_SRXCLSRLDEL : -/* stub */ + ret =iecm_del_fdir_fltr (vport, cmd);break ;case ETHTOOL_SRXFH :/* stub */
drivers/net/ethernet/intel/iecm/iecm_lib.c +1527 -1
1,570 lines not on this page · raw message
drivers/net/ethernet/intel/iecm/iecm_virtchnl.c +119 -0
125 lines not on this page · raw message
drivers/net/ethernet/intel/include/iecm.h +112 -0
136 lines not on this page · raw message
Signature · 1 line
2.33.0
PATCH 16/19 iecm: implement flow director
From: Alan Brady <[email protected]>
Date: Thu, 27 Jan 2022 16:10:06 -0800
Quoted 83 lines
From: Haiyue Wang <[email protected]>
This adds everthing needed to do flow director commands.
Signed-off-by Haiyue Wang <[email protected]>--- .../net/ethernet/intel/iecm/iecm_ethtool.c | 17 +- drivers/net/ethernet/intel/iecm/iecm_lib.c | 1528 ++++++++++++++++- .../net/ethernet/intel/iecm/iecm_virtchnl.c | 119 ++ drivers/net/ethernet/intel/include/iecm.h | 112 ++ 4 files changed, 1770 insertions(+), 6 deletions(-)drivers/net/ethernet/intel/iecm/iecm_ethtool.c +12
-5@@ -15,6 +15,7 @@ static int iecm_get_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd, u32 __always_unused *rule_locs) {struct iecm_vport *vport =iecm_netdev_to_vport (netdev); +struct iecm_adapter *adapter = vport->adapter;int ret = -EOPNOTSUPP ;switch (cmd->cmd) {@@ -23,14 +24,19 @@ static int iecm_get_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd, ret =0 ;break ;case ETHTOOL_GRXCLSRLCNT : -/* stub */ +if (!iecm_is_cap_ena (adapter,IECM_OTHER_CAPS , +VIRTCHNL2_CAP_FDIR )) +break ; + cmd->rule_cnt = + adapter->config_data.fdir_config.num_active_filters; + cmd->data =IECM_MAX_FDIR_FILTERS ; ret =0 ;break ;case ETHTOOL_GRXCLSRULE : -/* stub */ + ret =iecm_get_fdir_fltr_entry (vport, cmd);break ;case ETHTOOL_GRXCLSRLALL : -/* stub */ + ret =iecm_get_fdir_fltr_ids (vport, cmd, (u32 *)rule_locs);break ;case ETHTOOL_GRXFH :/* stub */ @@ -51,14 +57,15 @@ static int iecm_get_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd,*/ static int iecm_set_rxnfc (struct net_device *netdev,struct ethtool_rxnfc *cmd) { +struct iecm_vport *vport =iecm_netdev_to_vport (netdev);int ret = -EOPNOTSUPP ;switch (cmd->cmd) {case ETHTOOL_SRXCLSRLINS : -/* stub */ + ret =iecm_add_fdir_fltr (vport, cmd);break ;case ETHTOOL_SRXCLSRLDEL : -/* stub */ + ret =iecm_del_fdir_fltr (vport, cmd);break ;case ETHTOOL_SRXFH :/* stub */ drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0@@ -967,6 +967,56 @@ static void iecm_remove_vlan_filters(struct iecm_vport *vport) } } +/** +* iecm_remove_fdir_filters - Remove all Flow Director filters +* @vport: vport structure +*/ +static void iecm_remove_fdir_filters (struct iecm_vport *vport) +{ +struct iecm_adapter *adapter = vport->adapter; +struct iecm_fdir_fltr_config *fdir_config; + +if (!iecm_is_cap_ena (adapter,IECM_OTHER_CAPS ,VIRTCHNL2_CAP_FDIR ))
drivers/net/ethernet/intel/iecm/iecm_lib.c static void iecm_remove_vlan_filters(struct iecm_vport *vport) · line 989
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+return ; + + fdir_config = &adapter->config_data.fdir_config; +if (!list_empty (&fdir_config->fdir_fltr_list)) { +struct iecm_fdir_fltr *fdir; + +spin_lock_bh (&adapter->fdir_fltr_list_lock); +list_for_each_entry (fdir, &fdir_config->fdir_fltr_list, list) { + fdir->remove = true; + }
Braces are redundant here.
drivers/net/ethernet/intel/iecm/iecm_lib.c static void iecm_remove_vlan_filters(struct iecm_vport *vport) · line 992
Quoted 3 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +3
-0+spin_unlock_bh (&adapter->fdir_fltr_list_lock); +iecm_send_del_fdir_filter_msg (vport); + }
if (list_empty()) return; spin_lock_bh(...
-1 indent level.
Quoted 50 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +36
-0+} + +/** +* iecm_del_all_fdir_filters - delete all Flow Director filters +* @vport: vport structure +* +* This function will loop through the list of Flow Director filters and +* deletes them. +**/ +static void iecm_del_all_fdir_filters (struct iecm_vport *vport) +{ +struct iecm_adapter *adapter = vport->adapter; +struct iecm_fdir_fltr_config *fdir_config; +struct iecm_fdir_fltr *fdir, *fdir_tmp; + + fdir_config = &adapter->config_data.fdir_config; + +spin_lock_bh (&adapter->fdir_fltr_list_lock); +list_for_each_entry_safe (fdir, fdir_tmp, &fdir_config->fdir_fltr_list, + list) { +list_del (&fdir->list); +kfree (fdir); + } + fdir_config->num_active_filters =0 ; +spin_unlock_bh (&adapter->fdir_fltr_list_lock); +} +/** * iecm_vport_stop - Disable a vport * @vport: vport to disable @@ -997,6 +1047,8 @@ static void iecm_vport_stop(struct iecm_vport *vport)if (!test_bit (__IECM_REL_RES_IN_PROG, adapter->flags))iecm_remove_vlan_filters (vport); +iecm_remove_fdir_filters (vport); + adapter->link_up = false;iecm_vport_intr_deinit (vport);iecm_vport_intr_rel (vport);@@ -1206,6 +1258,28 @@ static void iecm_restore_vlans(struct iecm_vport *vport)iecm_set_all_vlans (vport); } +/** +* iecm_restore_fdir_filters - Restore all Flow Director filters +* @vport: vport structure +*/ +static void iecm_restore_fdir_filters (struct iecm_vport *vport) +{ +struct iecm_adapter *adapter = vport->adapter;
drivers/net/ethernet/intel/iecm/iecm_lib.c static void iecm_restore_vlans(struct iecm_vport *vport) · line 1277
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+struct iecm_fdir_fltr_config *fdir_config; + + fdir_config = &adapter->config_data.fdir_config; +if (!list_empty (&fdir_config->fdir_fltr_list)) { +struct iecm_fdir_fltr *fdir; + +spin_lock_bh (&adapter->fdir_fltr_list_lock); +list_for_each_entry (fdir, &fdir_config->fdir_fltr_list, list) { + fdir->add = true; + }
Braces are redundant for one-liners.
drivers/net/ethernet/intel/iecm/iecm_lib.c static void iecm_restore_vlans(struct iecm_vport *vport) · line 1280
Quoted 3 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +3
-0+spin_unlock_bh (&adapter->fdir_fltr_list_lock); +iecm_send_add_fdir_filter_msg (vport); + }
Invert the condition -> -1 indent level.
Quoted 44 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +17
-1+} +/** * iecm_restore_features - Restore feature configs * @vport: virtual port structure @@ -1227,6 +1301,9 @@ static void iecm_restore_features(struct iecm_vport *vport)if (iecm_set_promiscuous (adapter))dev_info (&adapter->pdev->dev,"Failed to restore promiscuous settings\n" ); } + +if (iecm_is_cap_ena (adapter,IECM_OTHER_CAPS ,VIRTCHNL2_CAP_FDIR )) +iecm_restore_fdir_filters (vport); }/** @@ -2014,6 +2091,7 @@ int iecm_probe(struct pci_dev *pdev,INIT_LIST_HEAD (&adapter->config_data.mac_filter_list);INIT_LIST_HEAD (&adapter->config_data.vlan_filter_list);INIT_LIST_HEAD (&adapter->config_data.adv_rss_list); +INIT_LIST_HEAD (&adapter->config_data.fdir_config.fdir_fltr_list);INIT_DELAYED_WORK (&adapter->stats_task, iecm_statistics_task);INIT_DELAYED_WORK (&adapter->serv_task, iecm_service_task);@@ -2052,7 +2130,17 @@ EXPORT_SYMBOL(iecm_probe);*/ static void iecm_del_user_cfg_data (struct iecm_adapter *adapter) { -/* stub */ +int i; + +if (!adapter->vports) +return ; + +for (i =0 ; i < adapter->num_alloc_vport; i++) { +if (!adapter->vports[i]) +continue ; + +iecm_del_all_fdir_filters (adapter->vports[i]); + } }/** @@ -2647,6 +2735,1444 @@ static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type,return err;
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 2745
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +8
-0} +/** +* iecm_pkt_udp_no_pay_len - the length of UDP packet without payload +* @fltr: Flow Director filter data structure +*/ +static u16 iecm_pkt_udp_no_pay_len (struct iecm_fdir_fltr *fltr) +{ + return sizeof(struct ethhdr) + + (fltr->ip_ver == 4 ? sizeof(struct iphdr)
IPv4 hdr may have extensions.
Quoted 7 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +7
-0+ : sizeof(struct ipv6hdr)) + +sizeof (struct udphdr ); +} + +/** +* iecm_fill_fdir_gtpu_hdr - fill the GTP-U protocol header +* @fltr: Flow Director filter data structure
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 2762
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+* @proto_hdrs: Flow Director protocol headers data structure +* +* Returns 0 if the GTP-U protocol header is set successfully +*/ +static int +iecm_fill_fdir_gtpu_hdr (struct iecm_fdir_fltr *fltr, +struct virtchnl_proto_hdrs *proto_hdrs) +{ +struct virtchnl_proto_hdr *uhdr = &proto_hdrs->proto_hdr[proto_hdrs->count -1 ]; +struct virtchnl_proto_hdr *ghdr = &proto_hdrs->proto_hdr[proto_hdrs->count++];
Lines over 79.
Quoted 8 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +8
-0+struct virtchnl_proto_hdr *ehdr =NULL ; +u16 adj_offs, hdr_offs; +int i; + +VIRTCHNL_SET_PROTO_HDR_TYPE (ghdr,GTPU_IP ); + + adj_offs =iecm_pkt_udp_no_pay_len (fltr); +
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 2780
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+for (i =0 ; i < fltr->flex_cnt; i++) { +#define IECM_GTPU_HDR_TEID_OFFS0 4 +#define IECM_GTPU_HDR_TEID_OFFS1 6 +#define IECM_GTPU_HDR_N_PDU_AND_NEXT_EXTHDR_OFFS 10 +#define IECM_GTPU_HDR_NEXT_EXTHDR_TYPE_MASK 0x00FF/* skip N_PDU */ +/* PDU Session Container Extension Header (PSC) */ +#define IECM_GTPU_PSC_EXTHDR_TYPE 0x85 +#define IECM_GTPU_HDR_PSC_PDU_TYPE_AND_QFI_OFFS 13 +#define IECM_GTPU_HDR_PSC_PDU_QFI_MASK 0x3F/* skip Type */ +#define IECM_GTPU_EH_QFI_IDX 1
It's better to define them outside the function.
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 2790
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+ +if (fltr->flex_words[i].offset < adj_offs) +return -EINVAL ; + + hdr_offs = fltr->flex_words[i].offset - adj_offs; + +switch (hdr_offs) { +case IECM_GTPU_HDR_TEID_OFFS0 : +case IECM_GTPU_HDR_TEID_OFFS1 : { +__be16 *pay_word = (__force __be16 *)ghdr->buffer;
I'd declare @pay_word outside of switch-case (which is recommended) to remove braces around the body.
Quoted 12 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +12
-0+ + pay_word[hdr_offs >>1 ] = +htons (fltr->flex_words[i].word); +VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (ghdr,GTPU_IP ,TEID ); + } +break ; +case IECM_GTPU_HDR_N_PDU_AND_NEXT_EXTHDR_OFFS : +if ((fltr->flex_words[i].word & +IECM_GTPU_HDR_NEXT_EXTHDR_TYPE_MASK ) != +IECM_GTPU_PSC_EXTHDR_TYPE ) +return -EOPNOTSUPP ; +if (!ehdr)
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 2812
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+ ehdr = + &proto_hdrs->proto_hdr[proto_hdrs->count++]; +VIRTCHNL_SET_PROTO_HDR_TYPE (ehdr,GTPU_EH ); +break ; +case IECM_GTPU_HDR_PSC_PDU_TYPE_AND_QFI_OFFS : +if (!ehdr) +return -EINVAL ; + ehdr->buffer[IECM_GTPU_EH_QFI_IDX ] = + fltr->flex_words[i].word & +IECM_GTPU_HDR_PSC_PDU_QFI_MASK ;
Inconsistent indentation here, filtr-> and IECM_ should be on the same level.
Quoted 18 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +18
-0+VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (ehdr,GTPU_EH ,QFI ); +break ; +default : +return -EINVAL ; + } + } + +/* The PF ignores the UDP header fields */ + uhdr->field_selector =0 ; + +return 0 ; +} + +/** +* iecm_fill_fdir_pfcp_hdr - fill the PFCP protocol header +* @fltr: Flow Director filter data structure +* @proto_hdrs: Flow Director protocol headers data structure +*
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 2840
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+* Returns 0 if the PFCP protocol header is set successfully +*/ +static int +iecm_fill_fdir_pfcp_hdr (struct iecm_fdir_fltr *fltr, +struct virtchnl_proto_hdrs *proto_hdrs) +{ +struct virtchnl_proto_hdr *uhdr = + &proto_hdrs->proto_hdr[proto_hdrs->count -1 ]; +struct virtchnl_proto_hdr *hdr = + &proto_hdrs->proto_hdr[proto_hdrs->count++];
Both could be declared and assigned separately to avoid line breaks.
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 2849
Quoted 9 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +9
-0+u16 adj_offs, hdr_offs; +int i; + +VIRTCHNL_SET_PROTO_HDR_TYPE (hdr,PFCP ); + + adj_offs =iecm_pkt_udp_no_pay_len (fltr); + +for (i =0 ; i < fltr->flex_cnt; i++) { +#define IECM_PFCP_HDR_SFIELD_AND_MSG_TYPE_OFFS 0
Better to define outside the function.
Quoted 29 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +8
-0+if (fltr->flex_words[i].offset < adj_offs) +return -EINVAL ; + + hdr_offs = fltr->flex_words[i].offset - adj_offs; + +switch (hdr_offs) { +case IECM_PFCP_HDR_SFIELD_AND_MSG_TYPE_OFFS : + hdr->buffer[0 ] = (fltr->flex_words[i].word >>8 ) &0xff ;Quoted 1 line
8 and &
0xffare candidates forFIELD_GET(GENMASK(15, 8)).drivers/net/ethernet/intel/iecm/iecm_lib.c +18
-0+VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (hdr,PFCP ,S_FIELD ); +break ; +default : +return -EINVAL ; + } + } + +/* The PF ignores the UDP header fields */ + uhdr->field_selector =0 ; + +return 0 ; +} + +/** +* iecm_fill_fdir_nat_t_esp_hdr - fill the NAT-T-ESP protocol header +* @fltr: Flow Director filter data structure +* @proto_hdrs: Flow Director protocol headers data structure +*
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 2885
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+* Returns 0 if the NAT-T-ESP protocol header is set successfully +*/ +static int +iecm_fill_fdir_nat_t_esp_hdr (struct iecm_fdir_fltr *fltr, +struct virtchnl_proto_hdrs *proto_hdrs) +{ +struct virtchnl_proto_hdr *uhdr = + &proto_hdrs->proto_hdr[proto_hdrs->count -1 ]; +struct virtchnl_proto_hdr *hdr = + &proto_hdrs->proto_hdr[proto_hdrs->count++];
Same here about line wraps.
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 2896
Quoted 11 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +11
-0+u16 adj_offs, hdr_offs; +u32 spi =0 ; +int i; + +VIRTCHNL_SET_PROTO_HDR_TYPE (hdr,ESP ); + + adj_offs =iecm_pkt_udp_no_pay_len (fltr); + +for (i =0 ; i < fltr->flex_cnt; i++) { +#define IECM_NAT_T_ESP_SPI_OFFS0 0 +#define IECM_NAT_T_ESP_SPI_OFFS1 2
Same here about definitions. It would be harder to look for them later (not counting grep and Elixir).
Quoted 34 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +34
-0+if (fltr->flex_words[i].offset < adj_offs) +return -EINVAL ; + + hdr_offs = fltr->flex_words[i].offset - adj_offs; + +switch (hdr_offs) { +case IECM_NAT_T_ESP_SPI_OFFS0 : + spi |= fltr->flex_words[i].word <<16 ; +break ; +case IECM_NAT_T_ESP_SPI_OFFS1 : + spi |= fltr->flex_words[i].word; +break ; +default : +return -EINVAL ; + } + } + +/* Not support IKE Header Format with SPI 0 */ +if (!spi) +return -EOPNOTSUPP ; + + *(__force __be32 *)hdr->buffer =htonl (spi); +VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (hdr,ESP ,SPI ); + +/* The PF ignores the UDP header fields */ + uhdr->field_selector =0 ; + +return 0 ; +} + +/** +* iecm_fill_fdir_udp_flex_pay_hdr - fill the UDP payload header +* @fltr: Flow Director filter data structure +* @proto_hdrs: Flow Director protocol headers data structure
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 2940
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+* +* Returns 0 if the UDP payload defined protocol header is set successfully +*/ +static int +iecm_fill_fdir_udp_flex_pay_hdr (struct iecm_fdir_fltr *fltr, +struct virtchnl_proto_hdrs *proto_hdrs) +{ +#define IECM_GTPU_PORT 2152 +#define IECM_NAT_T_ESP_PORT 4500 +#define IECM_PFCP_PORT 8805
Same for those, they don't belong here at all.
Quoted 5 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +5
-0+int err; + +switch (ntohs (fltr->ip_data.dst_port)) { +case IECM_GTPU_PORT : + err =iecm_fill_fdir_gtpu_hdr (fltr, proto_hdrs);
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 2955
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+break ; +case IECM_NAT_T_ESP_PORT : + err =iecm_fill_fdir_nat_t_esp_hdr (fltr, proto_hdrs); +break ; +case IECM_PFCP_PORT : + err =iecm_fill_fdir_pfcp_hdr (fltr, proto_hdrs); +break ; +default : + err = -EOPNOTSUPP ; +break ;
All of those should be converted to just
return iecm_ ...
directly, rather than assigning it to err just to return err.
Quoted 7 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +7
-0+ } + +return err; +} + +/** +* iecm_fill_fdir_ip4_hdr - fill the IPv4 protocol header
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 2972
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+* @fltr: Flow Director filter data structure +* @proto_hdrs: Flow Director protocol headers data structure +* +* Returns 0 if the IPv4 protocol header is set successfully +*/ +static int iecm_fill_fdir_ip4_hdr (struct iecm_fdir_fltr *fltr, +struct virtchnl_proto_hdrs *proto_hdrs) +{ +struct virtchnl_proto_hdr *hdr = + &proto_hdrs->proto_hdr[proto_hdrs->count++];
Same for this about line break.
Quoted 35 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +35
-0+struct iphdr *iph = (struct iphdr *)hdr->buffer; + +VIRTCHNL_SET_PROTO_HDR_TYPE (hdr,IPV4 ); + +if (fltr->ip_mask.tos ==U8_MAX ) { + iph->tos = fltr->ip_data.tos; +VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (hdr,IPV4 ,DSCP ); + } + +if (fltr->ip_mask.proto ==U8_MAX ) { + iph->protocol = fltr->ip_data.proto; +VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (hdr,IPV4 ,PROT ); + } + +if (fltr->ip_mask.v4_addrs.src_ip ==htonl (U32_MAX )) { + iph->saddr = fltr->ip_data.v4_addrs.src_ip; +VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (hdr,IPV4 ,SRC ); + } + +if (fltr->ip_mask.v4_addrs.dst_ip ==htonl (U32_MAX )) { + iph->daddr = fltr->ip_data.v4_addrs.dst_ip; +VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (hdr,IPV4 ,DST ); + } + + fltr->ip_ver =4 ; + +return 0 ; +} + +/** +* iecm_fill_fdir_ip6_hdr - fill the IPv6 protocol header +* @fltr: Flow Director filter data structure +* @proto_hdrs: Flow Director protocol headers data structure +* +* Returns 0 if the IPv6 protocol header is set successfully
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 3017
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+*/ +static int +iecm_fill_fdir_ip6_hdr (struct iecm_fdir_fltr *fltr, +struct virtchnl_proto_hdrs *proto_hdrs) +{ +static const struct in6_addr ipv6_addr_full_mask = { + .in6_u = { + .u6_addr8 = { +0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF , +0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,
Lowercase is generally more preferred for hex constants.
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 3022
Quoted 5 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +5
-0+ } + } + }; +struct virtchnl_proto_hdr *hdr = + &proto_hdrs->proto_hdr[proto_hdrs->count++];
Same.
Quoted 37 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +37
-0+struct ipv6hdr *iph = (struct ipv6hdr *)hdr->buffer; + +VIRTCHNL_SET_PROTO_HDR_TYPE (hdr,IPV6 ); + +if (fltr->ip_mask.tclass ==U8_MAX ) { + iph->priority = (fltr->ip_data.tclass >>4 ) &0xF ; + iph->flow_lbl[0 ] = (fltr->ip_data.tclass <<4 ) &0xF0 ; +VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (hdr,IPV6 ,TC ); + } + +if (fltr->ip_mask.proto ==U8_MAX ) { + iph->nexthdr = fltr->ip_data.proto; +VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (hdr,IPV6 ,PROT ); + } + +if (!memcmp (&fltr->ip_mask.v6_addrs.src_ip, &ipv6_addr_full_mask, +sizeof (struct in6_addr ))) { +memcpy (&iph->saddr, &fltr->ip_data.v6_addrs.src_ip, +sizeof (struct in6_addr )); +VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (hdr,IPV6 ,SRC ); + } + +if (!memcmp (&fltr->ip_mask.v6_addrs.dst_ip, &ipv6_addr_full_mask, +sizeof (struct in6_addr ))) { +memcpy (&iph->daddr, &fltr->ip_data.v6_addrs.dst_ip, +sizeof (struct in6_addr )); +VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (hdr,IPV6 ,DST ); + } + + fltr->ip_ver =6 ; + +return 0 ; +} + +/** +* iecm_fill_fdir_tcp_hdr - fill the TCP protocol header +* @fltr: Flow Director filter data structure
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 3069
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+* @proto_hdrs: Flow Director protocol headers data structure +* +* Returns 0 if the TCP protocol header is set successfully +*/ +static int +iecm_fill_fdir_tcp_hdr (struct iecm_fdir_fltr *fltr, +struct virtchnl_proto_hdrs *proto_hdrs) +{ +struct virtchnl_proto_hdr *hdr = + &proto_hdrs->proto_hdr[proto_hdrs->count++];
Same.
Quoted 30 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +30
-0+struct tcphdr *tcph = (struct tcphdr *)hdr->buffer; + +VIRTCHNL_SET_PROTO_HDR_TYPE (hdr,TCP ); + +if (fltr->ip_mask.src_port ==htons (U16_MAX )) { + tcph->source = fltr->ip_data.src_port; +VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (hdr,TCP ,SRC_PORT ); + } + +if (fltr->ip_mask.dst_port ==htons (U16_MAX )) { + tcph->dest = fltr->ip_data.dst_port; +VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (hdr,TCP ,DST_PORT ); + } + +return 0 ; +} + +/** +* iecm_fill_fdir_udp_hdr - fill the UDP protocol header +* @fltr: Flow Director filter data structure +* @proto_hdrs: Flow Director protocol headers data structure +* +* Returns 0 if the UDP protocol header is set successfully +*/ +static int +iecm_fill_fdir_udp_hdr (struct iecm_fdir_fltr *fltr, +struct virtchnl_proto_hdrs *proto_hdrs) +{ +struct virtchnl_proto_hdr *hdr = + &proto_hdrs->proto_hdr[proto_hdrs->count++];
...
Quoted 33 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +33
-0+struct udphdr *udph = (struct udphdr *)hdr->buffer; + +VIRTCHNL_SET_PROTO_HDR_TYPE (hdr,UDP ); + +if (fltr->ip_mask.src_port ==htons (U16_MAX )) { + udph->source = fltr->ip_data.src_port; +VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (hdr,UDP ,SRC_PORT ); + } + +if (fltr->ip_mask.dst_port ==htons (U16_MAX )) { + udph->dest = fltr->ip_data.dst_port; +VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (hdr,UDP ,DST_PORT ); + } + +if (!fltr->flex_cnt) +return 0 ; + +return iecm_fill_fdir_udp_flex_pay_hdr (fltr, proto_hdrs); +} + +/** +* iecm_fill_fdir_sctp_hdr - fill the SCTP protocol header +* @fltr: Flow Director filter data structure +* @proto_hdrs: Flow Director protocol headers data structure +* +* Returns 0 if the SCTP protocol header is set successfully +*/ +static int +iecm_fill_fdir_sctp_hdr (struct iecm_fdir_fltr *fltr, +struct virtchnl_proto_hdrs *proto_hdrs) +{ +struct virtchnl_proto_hdr *hdr = + &proto_hdrs->proto_hdr[proto_hdrs->count++];
...
Quoted 30 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +30
-0+struct sctphdr *sctph = (struct sctphdr *)hdr->buffer; + +VIRTCHNL_SET_PROTO_HDR_TYPE (hdr,SCTP ); + +if (fltr->ip_mask.src_port ==htons (U16_MAX )) { + sctph->source = fltr->ip_data.src_port; +VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (hdr,SCTP ,SRC_PORT ); + } + +if (fltr->ip_mask.dst_port ==htons (U16_MAX )) { + sctph->dest = fltr->ip_data.dst_port; +VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (hdr,SCTP ,DST_PORT ); + } + +return 0 ; +} + +/** +* iecm_fill_fdir_ah_hdr - fill the AH protocol header +* @fltr: Flow Director filter data structure +* @proto_hdrs: Flow Director protocol headers data structure +* +* Returns 0 if the AH protocol header is set successfully +*/ +static int +iecm_fill_fdir_ah_hdr (struct iecm_fdir_fltr *fltr, +struct virtchnl_proto_hdrs *proto_hdrs) +{ +struct virtchnl_proto_hdr *hdr = + &proto_hdrs->proto_hdr[proto_hdrs->count++];
...
Quoted 25 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +25
-0+struct ip_auth_hdr *ah = (struct ip_auth_hdr *)hdr->buffer; + +VIRTCHNL_SET_PROTO_HDR_TYPE (hdr,AH ); + +if (fltr->ip_mask.spi ==htonl (U32_MAX )) { + ah->spi = fltr->ip_data.spi; +VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (hdr,AH ,SPI ); + } + +return 0 ; +} + +/** +* iecm_fill_fdir_esp_hdr - fill the ESP protocol header +* @fltr: Flow Director filter data structure +* @proto_hdrs: Flow Director protocol headers data structure +* +* Returns 0 if the ESP protocol header is set successfully +*/ +static int +iecm_fill_fdir_esp_hdr (struct iecm_fdir_fltr *fltr, +struct virtchnl_proto_hdrs *proto_hdrs) +{ +struct virtchnl_proto_hdr *hdr = + &proto_hdrs->proto_hdr[proto_hdrs->count++];
...
Quoted 20 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +20
-0+struct ip_esp_hdr *esph = (struct ip_esp_hdr *)hdr->buffer; + +VIRTCHNL_SET_PROTO_HDR_TYPE (hdr,ESP ); + +if (fltr->ip_mask.spi ==htonl (U32_MAX )) { + esph->spi = fltr->ip_data.spi; +VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (hdr,ESP ,SPI ); + } + +return 0 ; +} + +/** +* iecm_fill_fdir_l4_hdr - fill the L4 protocol header +* @fltr: Flow Director filter data structure +* @proto_hdrs: Flow Director protocol headers data structure +* +* Returns 0 if the L4 protocol header is set successfully +*/ +static int
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 3217
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+iecm_fill_fdir_l4_hdr(struct iecm_fdir_fltr *fltr, + struct virtchnl_proto_hdrs *proto_hdrs) +{ + struct virtchnl_proto_hdr *hdr; +__be32 *l4_4_data; + +if (!fltr->ip_mask.proto)/* IPv4/IPv6 header only */ +return 0 ; + + hdr = &proto_hdrs->proto_hdr[proto_hdrs->count++];
Here's a good example: assignment occurs separately from the declaration and doesn't cause a line wrap.
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 3229
Quoted 12 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +12
-0+ l4_4_data = (__force __be32 *)hdr->buffer; + +/* L2TPv3 over IP with 'Session ID' */ +if (fltr->ip_data.proto ==IPPROTO_L2TP && + fltr->ip_mask.l4_header ==htonl (U32_MAX )) { +VIRTCHNL_SET_PROTO_HDR_TYPE (hdr,L2TPV3 ); +VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (hdr,L2TPV3 ,SESS_ID ); + + *l4_4_data = fltr->ip_data.l4_header; + }else { +return -EOPNOTSUPP ; + }
if (!= || !=) return -EOPNOTSUPP; VIRTCHNL_SET_ ...
-1 level this way.
Quoted 7 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +7
-0+ +return 0 ; +} + +/** +* iecm_fill_fdir_eth_hdr - fill the Ethernet protocol header +* @fltr: Flow Director filter data structure
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 3246
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+* @proto_hdrs: Flow Director protocol headers data structure +* +* Returns 0 if the Ethernet protocol header is set successfully +*/ +static int +iecm_fill_fdir_eth_hdr (struct iecm_fdir_fltr *fltr, +struct virtchnl_proto_hdrs *proto_hdrs) +{ +struct virtchnl_proto_hdr *hdr = + &proto_hdrs->proto_hdr[proto_hdrs->count++];
Here's a bad example again.
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 3258
Quoted 12 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +12
-0+struct ethhdr *ehdr = (struct ethhdr *)hdr->buffer; + +VIRTCHNL_SET_PROTO_HDR_TYPE (hdr,ETH ); + +if (fltr->eth_mask.etype ==htons (U16_MAX )) { +if (fltr->eth_data.etype ==htons (ETH_P_IP ) || + fltr->eth_data.etype ==htons (ETH_P_IPV6 )) +return -EOPNOTSUPP ; + + ehdr->h_proto = fltr->eth_data.etype; +VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (hdr,ETH ,ETHERTYPE ); + }
This can be inverted as well.
Quoted 9 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +9
-0+ +return 0 ; +} + +/** +* iecm_fill_fdir_add_msg - fill the Flow Director filter into virtchnl message +* @vport: vport structure +* @fltr: Flow Director filter data structure +*
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 3277
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+* Returns 0 if the add Flow Director virtchnl message is filled successfully +*/ +static int +iecm_fill_fdir_add_msg (struct iecm_vport *vport,struct iecm_fdir_fltr *fltr) +{ +struct virtchnl_fdir_add *vc_msg = &fltr->vc_add_msg; +struct virtchnl_proto_hdrs *proto_hdrs; +int err; + + proto_hdrs = &vc_msg->rule_cfg.proto_hdrs;
And here's good.
Quoted 123 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +123
-0+ + err =iecm_fill_fdir_eth_hdr (fltr, proto_hdrs);/* L2 always exists */ +if (err) +return err; + +switch (fltr->flow_type) { +case IECM_FDIR_FLOW_IPV4_TCP : + err =iecm_fill_fdir_ip4_hdr (fltr, proto_hdrs) | +iecm_fill_fdir_tcp_hdr (fltr, proto_hdrs); +break ; +case IECM_FDIR_FLOW_IPV4_UDP : + err =iecm_fill_fdir_ip4_hdr (fltr, proto_hdrs) | +iecm_fill_fdir_udp_hdr (fltr, proto_hdrs); +break ; +case IECM_FDIR_FLOW_IPV4_SCTP : + err =iecm_fill_fdir_ip4_hdr (fltr, proto_hdrs) | +iecm_fill_fdir_sctp_hdr (fltr, proto_hdrs); +break ; +case IECM_FDIR_FLOW_IPV4_AH : + err =iecm_fill_fdir_ip4_hdr (fltr, proto_hdrs) | +iecm_fill_fdir_ah_hdr (fltr, proto_hdrs); +break ; +case IECM_FDIR_FLOW_IPV4_ESP : + err =iecm_fill_fdir_ip4_hdr (fltr, proto_hdrs) | +iecm_fill_fdir_esp_hdr (fltr, proto_hdrs); +break ; +case IECM_FDIR_FLOW_IPV4_OTHER : + err =iecm_fill_fdir_ip4_hdr (fltr, proto_hdrs) | +iecm_fill_fdir_l4_hdr (fltr, proto_hdrs); +break ; +case IECM_FDIR_FLOW_IPV6_TCP : + err =iecm_fill_fdir_ip6_hdr (fltr, proto_hdrs) | +iecm_fill_fdir_tcp_hdr (fltr, proto_hdrs); +break ; +case IECM_FDIR_FLOW_IPV6_UDP : + err =iecm_fill_fdir_ip6_hdr (fltr, proto_hdrs) | +iecm_fill_fdir_udp_hdr (fltr, proto_hdrs); +break ; +case IECM_FDIR_FLOW_IPV6_SCTP : + err =iecm_fill_fdir_ip6_hdr (fltr, proto_hdrs) | +iecm_fill_fdir_sctp_hdr (fltr, proto_hdrs); +break ; +case IECM_FDIR_FLOW_IPV6_AH : + err =iecm_fill_fdir_ip6_hdr (fltr, proto_hdrs) | +iecm_fill_fdir_ah_hdr (fltr, proto_hdrs); +break ; +case IECM_FDIR_FLOW_IPV6_ESP : + err =iecm_fill_fdir_ip6_hdr (fltr, proto_hdrs) | +iecm_fill_fdir_esp_hdr (fltr, proto_hdrs); +break ; +case IECM_FDIR_FLOW_IPV6_OTHER : + err =iecm_fill_fdir_ip6_hdr (fltr, proto_hdrs) | +iecm_fill_fdir_l4_hdr (fltr, proto_hdrs); +break ; +case IECM_FDIR_FLOW_NON_IP_L2 : +break ; +default : + err = -EINVAL ; +break ; + } + +if (err) +return err; + + vc_msg->vsi_id = vport->vport_id; + vc_msg->rule_cfg.action_set.count =1 ; + vc_msg->rule_cfg.action_set.actions[0 ].type = fltr->action; + vc_msg->rule_cfg.action_set.actions[0 ].act_conf.queue.index = + fltr->q_index; + +return 0 ; +} + +/** +* iecm_fdir_flow_proto_name - get the flow protocol name +* @flow_type: Flow Director filter flow type +**/ +static const char * +iecm_fdir_flow_proto_name (enum iecm_fdir_flow_type flow_type) +{ +switch (flow_type) { +case IECM_FDIR_FLOW_IPV4_TCP : +case IECM_FDIR_FLOW_IPV6_TCP : +return "TCP" ; +case IECM_FDIR_FLOW_IPV4_UDP : +case IECM_FDIR_FLOW_IPV6_UDP : +return "UDP" ; +case IECM_FDIR_FLOW_IPV4_SCTP : +case IECM_FDIR_FLOW_IPV6_SCTP : +return "SCTP" ; +case IECM_FDIR_FLOW_IPV4_AH : +case IECM_FDIR_FLOW_IPV6_AH : +return "AH" ; +case IECM_FDIR_FLOW_IPV4_ESP : +case IECM_FDIR_FLOW_IPV6_ESP : +return "ESP" ; +case IECM_FDIR_FLOW_IPV4_OTHER : +case IECM_FDIR_FLOW_IPV6_OTHER : +return "Other" ; +case IECM_FDIR_FLOW_NON_IP_L2 : +return "Ethernet" ; +default : +return NULL ; + } +} + +/** +* iecm_dump_fdir_fltr +* @vport: vport structure +* @fltr: Flow Director filter to print +* +* Print the Flow Director filter +**/ +static void +iecm_dump_fdir_fltr (struct iecm_vport *vport,struct iecm_fdir_fltr *fltr) +{ +const char *proto =iecm_fdir_flow_proto_name (fltr->flow_type); +struct device *dev = &vport->adapter->pdev->dev; + +if (!proto) +return ; + +switch (fltr->flow_type) {
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 3410
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+case IECM_FDIR_FLOW_IPV4_TCP : +case IECM_FDIR_FLOW_IPV4_UDP : +case IECM_FDIR_FLOW_IPV4_SCTP : +dev_info (dev,"Rule ID: %u dst_ip: %pI4 src_ip %pI4 %s: dst_port %hu src_port %hu\n" , + fltr->loc, + &fltr->ip_data.v4_addrs.dst_ip, + &fltr->ip_data.v4_addrs.src_ip, + proto, +ntohs (fltr->ip_data.dst_port), +ntohs (fltr->ip_data.src_port));
Some of those can fit into previous line, there's no need to put each argument onto separate one.
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 3419
Quoted 9 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +9
-0+break ; +case IECM_FDIR_FLOW_IPV4_AH : +case IECM_FDIR_FLOW_IPV4_ESP : +dev_info (dev,"Rule ID: %u dst_ip: %pI4 src_ip %pI4 %s: SPI %u\n" , + fltr->loc, + &fltr->ip_data.v4_addrs.dst_ip, + &fltr->ip_data.v4_addrs.src_ip, + proto, +ntohl (fltr->ip_data.spi));
Same here.
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 3427
Quoted 8 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +8
-0+break ; +case IECM_FDIR_FLOW_IPV4_OTHER : +dev_info (dev,"Rule ID: %u dst_ip: %pI4 src_ip %pI4 proto: %u L4_bytes: 0x%x\n" , + fltr->loc, + &fltr->ip_data.v4_addrs.dst_ip, + &fltr->ip_data.v4_addrs.src_ip, + fltr->ip_data.proto, +ntohl (fltr->ip_data.l4_header));
And here.
Quoted 11 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +11
-0+break ; +case IECM_FDIR_FLOW_IPV6_TCP : +case IECM_FDIR_FLOW_IPV6_UDP : +case IECM_FDIR_FLOW_IPV6_SCTP : +dev_info (dev,"Rule ID: %u dst_ip: %pI6 src_ip %pI6 %s: dst_port %hu src_port %hu\n" , + fltr->loc, + &fltr->ip_data.v6_addrs.dst_ip, + &fltr->ip_data.v6_addrs.src_ip, + proto, +ntohs (fltr->ip_data.dst_port), +ntohs (fltr->ip_data.src_port));
...
Quoted 9 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +9
-0+break ; +case IECM_FDIR_FLOW_IPV6_AH : +case IECM_FDIR_FLOW_IPV6_ESP : +dev_info (dev,"Rule ID: %u dst_ip: %pI6 src_ip %pI6 %s: SPI %u\n" , + fltr->loc, + &fltr->ip_data.v6_addrs.dst_ip, + &fltr->ip_data.v6_addrs.src_ip, + proto, +ntohl (fltr->ip_data.spi));
...
Quoted 8 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +8
-0+break ; +case IECM_FDIR_FLOW_IPV6_OTHER : +dev_info (dev,"Rule ID: %u dst_ip: %pI6 src_ip %pI6 proto: %u L4_bytes: 0x%x\n" , + fltr->loc, + &fltr->ip_data.v6_addrs.dst_ip, + &fltr->ip_data.v6_addrs.src_ip, + fltr->ip_data.proto, +ntohl (fltr->ip_data.l4_header));
...
Quoted 5 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +5
-0+break ; +case IECM_FDIR_FLOW_NON_IP_L2 : +dev_info (dev,"Rule ID: %u eth_type: 0x%x\n" , + fltr->loc, +ntohs (fltr->eth_data.etype));
...
Quoted 44 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +44
-0+break ; +default : +break ; + } +} + +/** +* iecm_fdir_is_dup_fltr - test if filter is already in list +* @adapter: board private structure +* @fltr: Flow Director filter data structure +* +* Returns true if the filter is found in the list +*/ +static bool +iecm_fdir_is_dup_fltr (struct iecm_adapter *adapter, +struct iecm_fdir_fltr *fltr) +{ +struct iecm_fdir_fltr_config *fdir_config; +struct iecm_fdir_fltr *tmp; + + fdir_config = &adapter->config_data.fdir_config; +list_for_each_entry (tmp, &fdir_config->fdir_fltr_list, list) { +if (tmp->flow_type != fltr->flow_type) +continue ; + +if (!memcmp (&tmp->eth_data, &fltr->eth_data, +sizeof (fltr->eth_data)) && + !memcmp (&tmp->ip_data, &fltr->ip_data, +sizeof (fltr->ip_data)) && + !memcmp (&tmp->ext_data, &fltr->ext_data, +sizeof (fltr->ext_data))) +return true; + } + +return false; +} + +/** +* iecm_find_fdir_fltr_by_loc - find filter with location +* @adapter: board private structure +* @loc: location to find. +* +* Returns pointer to Flow Director filter if found or null +*/
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 3514
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+static struct iecm_fdir_fltr * +iecm_find_fdir_fltr_by_loc (struct iecm_adapter *adapter,u32 loc) +{ +struct iecm_fdir_fltr_config *fdir_config; +struct iecm_fdir_fltr *rule; + + fdir_config = &adapter->config_data.fdir_config; +list_for_each_entry (rule, &fdir_config->fdir_fltr_list, list) +if (rule->loc == loc) +return rule;
Here's a good example that a single if statement shouldn't be placed into a pair of braces.
Quoted 62 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +62
-0+ +return NULL ; +} + +/** +* iecm_fdir_list_add_fltr - add a new node to the flow director filter list +* @adapter: board private structure +* @fltr: filter node to add to structure +*/ +static void +iecm_fdir_list_add_fltr (struct iecm_adapter *adapter, +struct iecm_fdir_fltr *fltr) +{ +struct iecm_fdir_fltr *rule, *parent =NULL ; +struct iecm_fdir_fltr_config *fdir_config; + + fdir_config = &adapter->config_data.fdir_config; + +spin_lock_bh (&adapter->fdir_fltr_list_lock); +list_for_each_entry (rule, &fdir_config->fdir_fltr_list, list) { +if (rule->loc >= fltr->loc) +break ; + parent = rule; + } + +if (parent) +list_add (&fltr->list, &parent->list); +else +list_add (&fltr->list, &fdir_config->fdir_fltr_list); + fltr->add = true; +spin_unlock_bh (&adapter->fdir_fltr_list_lock); +} + +/** +* iecm_fltr_to_ethtool_flow - convert filter type values to ethtool +* flow type values +* @flow: filter type to be converted +* +* Returns the corresponding ethtool flow type. +*/ +static int iecm_fltr_to_ethtool_flow (enum iecm_fdir_flow_type flow) +{ +switch (flow) { +case IECM_FDIR_FLOW_IPV4_TCP : +return TCP_V4_FLOW ; +case IECM_FDIR_FLOW_IPV4_UDP : +return UDP_V4_FLOW ; +case IECM_FDIR_FLOW_IPV4_SCTP : +return SCTP_V4_FLOW ; +case IECM_FDIR_FLOW_IPV4_AH : +return AH_V4_FLOW ; +case IECM_FDIR_FLOW_IPV4_ESP : +return ESP_V4_FLOW ; +case IECM_FDIR_FLOW_IPV4_OTHER : +return IPV4_USER_FLOW ; +case IECM_FDIR_FLOW_IPV6_TCP : +return TCP_V6_FLOW ; +case IECM_FDIR_FLOW_IPV6_UDP : +return UDP_V6_FLOW ; +case IECM_FDIR_FLOW_IPV6_SCTP : +return SCTP_V6_FLOW ; +case IECM_FDIR_FLOW_IPV6_AH :
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 3586
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+return AH_V6_FLOW ; +case IECM_FDIR_FLOW_IPV6_ESP : +return ESP_V6_FLOW ; +case IECM_FDIR_FLOW_IPV6_OTHER : +return IPV6_USER_FLOW ; +case IECM_FDIR_FLOW_NON_IP_L2 : +return ETHER_FLOW ; +default : +/* 0 is undefined ethtool flow */ +return 0 ;
This switch-case can be converted to an array to reduce code size.
Quoted 30 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +30
-0+ } +} + +/** +* iecm_ethtool_flow_to_fltr - convert ethtool flow type to filter enum +* @eth: Ethtool flow type to be converted +* +* Returns flow enum +*/ +static enum iecm_fdir_flow_type iecm_ethtool_flow_to_fltr (int eth) +{ +switch (eth) { +case TCP_V4_FLOW : +return IECM_FDIR_FLOW_IPV4_TCP ; +case UDP_V4_FLOW : +return IECM_FDIR_FLOW_IPV4_UDP ; +case SCTP_V4_FLOW : +return IECM_FDIR_FLOW_IPV4_SCTP ; +case AH_V4_FLOW : +return IECM_FDIR_FLOW_IPV4_AH ; +case ESP_V4_FLOW : +return IECM_FDIR_FLOW_IPV4_ESP ; +case IPV4_USER_FLOW : +return IECM_FDIR_FLOW_IPV4_OTHER ; +case TCP_V6_FLOW : +return IECM_FDIR_FLOW_IPV6_TCP ; +case UDP_V6_FLOW : +return IECM_FDIR_FLOW_IPV6_UDP ; +case SCTP_V6_FLOW : +return IECM_FDIR_FLOW_IPV6_SCTP ;
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 3626
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+case AH_V6_FLOW : +return IECM_FDIR_FLOW_IPV6_AH ; +case ESP_V6_FLOW : +return IECM_FDIR_FLOW_IPV6_ESP ; +case IPV6_USER_FLOW : +return IECM_FDIR_FLOW_IPV6_OTHER ; +case ETHER_FLOW : +return IECM_FDIR_FLOW_NON_IP_L2 ; +default : +return IECM_FDIR_FLOW_NONE ;
Same here.
Quoted 5 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +5
-0+ } +} + +/** +* iecm_is_mask_valid - check mask field set
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 3641
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+* @mask: full mask to check +* @field: field for which mask should be valid +* +* If the mask is fully set return true. If it is not valid for field return +* false. +*/ +static bool iecm_is_mask_valid (u64 mask,u64 field) +{ +return (mask & field) == field; +}
That is something really basic and should at least be placed somewhere in the headers and used module-wide.
Quoted 13 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +13
-0+ +/** +* iecm_parse_rx_flow_user_data - deconstruct user-defined data +* @fsp: pointer to ethtool Rx flow specification +* @fltr: pointer to Flow Director filter for userdef data storage +* +* Returns 0 on success, negative error value on failure +*/ +static int +iecm_parse_rx_flow_user_data (struct ethtool_rx_flow_spec *fsp, +struct iecm_fdir_fltr *fltr) +{ +struct iecm_flex_word *flex;
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 3664
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+int i, cnt =0 ; + +if (!(fsp->flow_type &FLOW_EXT )) +return 0 ; + +for (i =0 ; i <IECM_FLEX_WORD_NUM ; i++) { +#define IECM_USERDEF_FLEX_WORD_M GENMASK(15, 0) +#define IECM_USERDEF_FLEX_OFFS_S 16 +#define IECM_USERDEF_FLEX_OFFS_M GENMASK(31, IECM_USERDEF_FLEX_OFFS_S) +#define IECM_USERDEF_FLEX_FLTR_M GENMASK(31, 0)
1. Should be placed outside the function.
2. Candidates for FIELD_{GET,PREP}().
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 3677
Quoted 13 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +13
-0+u32 value =be32_to_cpu (fsp->h_ext.data[i]); +u32 mask =be32_to_cpu (fsp->m_ext.data[i]); + +if (!value || !mask) +continue ; + +if (!iecm_is_mask_valid (mask,IECM_USERDEF_FLEX_FLTR_M )) +return -EINVAL ; + +/* 504 is the maximum value for offsets, and offset is measured +* from the start of the MAC address. +*/ +#define IECM_USERDEF_FLEX_MAX_OFFS_VAL 504
Same.
Quoted 36 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +36
-0+ flex = &fltr->flex_words[cnt++]; + flex->word = value &IECM_USERDEF_FLEX_WORD_M ; + flex->offset = (value &IECM_USERDEF_FLEX_OFFS_M ) >> +IECM_USERDEF_FLEX_OFFS_S ; +if (flex->offset >IECM_USERDEF_FLEX_MAX_OFFS_VAL ) +return -EINVAL ; + } + + fltr->flex_cnt = cnt; + +return 0 ; +} + +/** +* iecm_fill_rx_flow_ext_data - fill the additional data +* @fsp: pointer to ethtool Rx flow specification +* @fltr: pointer to Flow Director filter to get additional data +*/ +static void +iecm_fill_rx_flow_ext_data (struct ethtool_rx_flow_spec *fsp, +struct iecm_fdir_fltr *fltr) +{ +if (!fltr->ext_mask.usr_def[0 ] && !fltr->ext_mask.usr_def[1 ]) +return ; + + fsp->flow_type |=FLOW_EXT ; + +memcpy (fsp->h_ext.data, fltr->ext_data.usr_def, +sizeof (fsp->h_ext.data)); +memcpy (fsp->m_ext.data, fltr->ext_mask.usr_def, +sizeof (fsp->m_ext.data)); +} + +/** +* iecm_get_fdir_fltr_entry - fill ethtool structure with Flow Director +* filter data
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 3723
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+* @vport: vport structure +* @cmd: ethtool command data structure to receive the filter data +* +* Returns 0 as expected for success by ethtool +*/ +int +iecm_get_fdir_fltr_entry (struct iecm_vport *vport,struct ethtool_rxnfc *cmd) +{ +struct ethtool_rx_flow_spec *fsp = + (struct ethtool_rx_flow_spec *)&cmd->fs;
struct ethtool_rx_flow_spec *fsp = (typeof(fsp))&cmd->fs;
drivers/net/ethernet/intel/iecm/iecm_virtchnl.c
Quoted 500 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +452
-0+struct iecm_adapter *adapter = vport->adapter; +struct iecm_fdir_fltr *rule; +int ret =0 ; + +if (adapter->state != __IECM_UP) +return -EIO ; + +if (!iecm_is_cap_ena (adapter,IECM_OTHER_CAPS ,VIRTCHNL2_CAP_FDIR )) +return -EOPNOTSUPP ; + +spin_lock_bh (&adapter->fdir_fltr_list_lock); + + rule =iecm_find_fdir_fltr_by_loc (adapter, fsp->location); +if (!rule) { + ret = -EINVAL ; + goto release_lock; + } + + fsp->flow_type =iecm_fltr_to_ethtool_flow (rule->flow_type); + +memset (&fsp->m_u,0 ,sizeof (fsp->m_u)); +memset (&fsp->m_ext,0 ,sizeof (fsp->m_ext)); + +switch (fsp->flow_type) { +case TCP_V4_FLOW : +case UDP_V4_FLOW : +case SCTP_V4_FLOW : + fsp->h_u.tcp_ip4_spec.ip4src = rule->ip_data.v4_addrs.src_ip; + fsp->h_u.tcp_ip4_spec.ip4dst = rule->ip_data.v4_addrs.dst_ip; + fsp->h_u.tcp_ip4_spec.psrc = rule->ip_data.src_port; + fsp->h_u.tcp_ip4_spec.pdst = rule->ip_data.dst_port; + fsp->h_u.tcp_ip4_spec.tos = rule->ip_data.tos; + fsp->m_u.tcp_ip4_spec.ip4src = rule->ip_mask.v4_addrs.src_ip; + fsp->m_u.tcp_ip4_spec.ip4dst = rule->ip_mask.v4_addrs.dst_ip; + fsp->m_u.tcp_ip4_spec.psrc = rule->ip_mask.src_port; + fsp->m_u.tcp_ip4_spec.pdst = rule->ip_mask.dst_port; + fsp->m_u.tcp_ip4_spec.tos = rule->ip_mask.tos; +break ; +case AH_V4_FLOW : +case ESP_V4_FLOW : + fsp->h_u.ah_ip4_spec.ip4src = rule->ip_data.v4_addrs.src_ip; + fsp->h_u.ah_ip4_spec.ip4dst = rule->ip_data.v4_addrs.dst_ip; + fsp->h_u.ah_ip4_spec.spi = rule->ip_data.spi; + fsp->h_u.ah_ip4_spec.tos = rule->ip_data.tos; + fsp->m_u.ah_ip4_spec.ip4src = rule->ip_mask.v4_addrs.src_ip; + fsp->m_u.ah_ip4_spec.ip4dst = rule->ip_mask.v4_addrs.dst_ip; + fsp->m_u.ah_ip4_spec.spi = rule->ip_mask.spi; + fsp->m_u.ah_ip4_spec.tos = rule->ip_mask.tos; +break ; +case IPV4_USER_FLOW : + fsp->h_u.usr_ip4_spec.ip4src = rule->ip_data.v4_addrs.src_ip; + fsp->h_u.usr_ip4_spec.ip4dst = rule->ip_data.v4_addrs.dst_ip; + fsp->h_u.usr_ip4_spec.l4_4_bytes = rule->ip_data.l4_header; + fsp->h_u.usr_ip4_spec.tos = rule->ip_data.tos; + fsp->h_u.usr_ip4_spec.ip_ver =ETH_RX_NFC_IP4 ; + fsp->h_u.usr_ip4_spec.proto = rule->ip_data.proto; + fsp->m_u.usr_ip4_spec.ip4src = rule->ip_mask.v4_addrs.src_ip; + fsp->m_u.usr_ip4_spec.ip4dst = rule->ip_mask.v4_addrs.dst_ip; + fsp->m_u.usr_ip4_spec.l4_4_bytes = rule->ip_mask.l4_header; + fsp->m_u.usr_ip4_spec.tos = rule->ip_mask.tos; + fsp->m_u.usr_ip4_spec.ip_ver =0xFF ; + fsp->m_u.usr_ip4_spec.proto = rule->ip_mask.proto; +break ; +case TCP_V6_FLOW : +case UDP_V6_FLOW : +case SCTP_V6_FLOW : +memcpy (fsp->h_u.usr_ip6_spec.ip6src, + &rule->ip_data.v6_addrs.src_ip,sizeof (struct in6_addr )); +memcpy (fsp->h_u.usr_ip6_spec.ip6dst, + &rule->ip_data.v6_addrs.dst_ip,sizeof (struct in6_addr )); + fsp->h_u.tcp_ip6_spec.psrc = rule->ip_data.src_port; + fsp->h_u.tcp_ip6_spec.pdst = rule->ip_data.dst_port; + fsp->h_u.tcp_ip6_spec.tclass = rule->ip_data.tclass; +memcpy (fsp->m_u.usr_ip6_spec.ip6src, + &rule->ip_mask.v6_addrs.src_ip,sizeof (struct in6_addr )); +memcpy (fsp->m_u.usr_ip6_spec.ip6dst, + &rule->ip_mask.v6_addrs.dst_ip,sizeof (struct in6_addr )); + fsp->m_u.tcp_ip6_spec.psrc = rule->ip_mask.src_port; + fsp->m_u.tcp_ip6_spec.pdst = rule->ip_mask.dst_port; + fsp->m_u.tcp_ip6_spec.tclass = rule->ip_mask.tclass; +break ; +case AH_V6_FLOW : +case ESP_V6_FLOW : +memcpy (fsp->h_u.ah_ip6_spec.ip6src, + &rule->ip_data.v6_addrs.src_ip,sizeof (struct in6_addr )); +memcpy (fsp->h_u.ah_ip6_spec.ip6dst, + &rule->ip_data.v6_addrs.dst_ip,sizeof (struct in6_addr )); + fsp->h_u.ah_ip6_spec.spi = rule->ip_data.spi; + fsp->h_u.ah_ip6_spec.tclass = rule->ip_data.tclass; +memcpy (fsp->m_u.ah_ip6_spec.ip6src, + &rule->ip_mask.v6_addrs.src_ip,sizeof (struct in6_addr )); +memcpy (fsp->m_u.ah_ip6_spec.ip6dst, + &rule->ip_mask.v6_addrs.dst_ip,sizeof (struct in6_addr )); + fsp->m_u.ah_ip6_spec.spi = rule->ip_mask.spi; + fsp->m_u.ah_ip6_spec.tclass = rule->ip_mask.tclass; +break ; +case IPV6_USER_FLOW : +memcpy (fsp->h_u.usr_ip6_spec.ip6src, + &rule->ip_data.v6_addrs.src_ip,sizeof (struct in6_addr )); +memcpy (fsp->h_u.usr_ip6_spec.ip6dst, + &rule->ip_data.v6_addrs.dst_ip,sizeof (struct in6_addr )); + fsp->h_u.usr_ip6_spec.l4_4_bytes = rule->ip_data.l4_header; + fsp->h_u.usr_ip6_spec.tclass = rule->ip_data.tclass; + fsp->h_u.usr_ip6_spec.l4_proto = rule->ip_data.proto; +memcpy (fsp->m_u.usr_ip6_spec.ip6src, + &rule->ip_mask.v6_addrs.src_ip,sizeof (struct in6_addr )); +memcpy (fsp->m_u.usr_ip6_spec.ip6dst, + &rule->ip_mask.v6_addrs.dst_ip,sizeof (struct in6_addr )); + fsp->m_u.usr_ip6_spec.l4_4_bytes = rule->ip_mask.l4_header; + fsp->m_u.usr_ip6_spec.tclass = rule->ip_mask.tclass; + fsp->m_u.usr_ip6_spec.l4_proto = rule->ip_mask.proto; +break ; +case ETHER_FLOW : + fsp->h_u.ether_spec.h_proto = rule->eth_data.etype; + fsp->m_u.ether_spec.h_proto = rule->eth_mask.etype; +break ; +default : + ret = -EINVAL ; +break ; + } + +iecm_fill_rx_flow_ext_data (fsp, rule); + +if (rule->action ==VIRTCHNL_ACTION_DROP ) + fsp->ring_cookie =RX_CLS_FLOW_DISC ; +else + fsp->ring_cookie = rule->q_index; + +release_lock: +spin_unlock_bh (&adapter->fdir_fltr_list_lock); +return ret; +} + +/** +* iecm_get_fdir_fltr_ids - fill buffer with filter IDs of active filters +* @vport: vport structure +* @cmd: ethtool command data structure +* @rule_locs: ethtool array passed in from OS to receive filter IDs +* +* Returns 0 as expected for success by ethtool +*/ +int +iecm_get_fdir_fltr_ids (struct iecm_vport *vport,struct ethtool_rxnfc *cmd, +u32 *rule_locs) +{ +struct iecm_adapter *adapter = vport->adapter; +struct iecm_fdir_fltr_config *fdir_config; +struct iecm_fdir_fltr *fltr; +unsigned int cnt =0 ; +int ret =0 ; + +if (adapter->state != __IECM_UP) +return -EIO ; + +if (!iecm_is_cap_ena (adapter,IECM_OTHER_CAPS ,VIRTCHNL2_CAP_FDIR )) +return -EOPNOTSUPP ; + + cmd->data =IECM_MAX_FDIR_FILTERS ; + + fdir_config = &adapter->config_data.fdir_config; + +spin_lock_bh (&adapter->fdir_fltr_list_lock); + +list_for_each_entry (fltr, &fdir_config->fdir_fltr_list, list) { +if (cnt == cmd->rule_cnt) { + ret = -EMSGSIZE ; + goto release_lock; + } + rule_locs[cnt] = fltr->loc; + cnt++; + } + +release_lock: +spin_unlock_bh (&adapter->fdir_fltr_list_lock); +if (!ret) + cmd->rule_cnt = cnt; + +return ret; +} + +/** +* iecm_add_fdir_fltr_info - Set the input set for Flow Director filter +* @vport: vport structure +* @fsp: pointer to ethtool Rx flow specification +* @fltr: filter structure +*/ +static int +iecm_add_fdir_fltr_info (struct iecm_vport *vport, +struct ethtool_rx_flow_spec *fsp, +struct iecm_fdir_fltr *fltr) +{ +struct iecm_adapter *adapter = vport->adapter; +u32 flow_type, q_index =0 ; +enum virtchnl_action act; +int err; + +if (fsp->ring_cookie ==RX_CLS_FLOW_DISC ) { + act =VIRTCHNL_ACTION_DROP ; + }else { + q_index = fsp->ring_cookie; +if (q_index >= vport->num_rxq) +return -EINVAL ; + + act =VIRTCHNL_ACTION_QUEUE ; + } + + fltr->action = act; + fltr->loc = fsp->location; + fltr->q_index = q_index; + +if (fsp->flow_type &FLOW_EXT ) { +memcpy (fltr->ext_data.usr_def, fsp->h_ext.data, +sizeof (fltr->ext_data.usr_def)); +memcpy (fltr->ext_mask.usr_def, fsp->m_ext.data, +sizeof (fltr->ext_mask.usr_def)); + } + + flow_type = fsp->flow_type & ~(FLOW_EXT |FLOW_MAC_EXT |FLOW_RSS ); + fltr->flow_type =iecm_ethtool_flow_to_fltr (flow_type); + +switch (flow_type) { +case TCP_V4_FLOW : +case UDP_V4_FLOW : +case SCTP_V4_FLOW : + fltr->ip_data.v4_addrs.src_ip = fsp->h_u.tcp_ip4_spec.ip4src; + fltr->ip_data.v4_addrs.dst_ip = fsp->h_u.tcp_ip4_spec.ip4dst; + fltr->ip_data.src_port = fsp->h_u.tcp_ip4_spec.psrc; + fltr->ip_data.dst_port = fsp->h_u.tcp_ip4_spec.pdst; + fltr->ip_data.tos = fsp->h_u.tcp_ip4_spec.tos; + fltr->ip_mask.v4_addrs.src_ip = fsp->m_u.tcp_ip4_spec.ip4src; + fltr->ip_mask.v4_addrs.dst_ip = fsp->m_u.tcp_ip4_spec.ip4dst; + fltr->ip_mask.src_port = fsp->m_u.tcp_ip4_spec.psrc; + fltr->ip_mask.dst_port = fsp->m_u.tcp_ip4_spec.pdst; + fltr->ip_mask.tos = fsp->m_u.tcp_ip4_spec.tos; +break ; +case AH_V4_FLOW : +case ESP_V4_FLOW : + fltr->ip_data.v4_addrs.src_ip = fsp->h_u.ah_ip4_spec.ip4src; + fltr->ip_data.v4_addrs.dst_ip = fsp->h_u.ah_ip4_spec.ip4dst; + fltr->ip_data.spi = fsp->h_u.ah_ip4_spec.spi; + fltr->ip_data.tos = fsp->h_u.ah_ip4_spec.tos; + fltr->ip_mask.v4_addrs.src_ip = fsp->m_u.ah_ip4_spec.ip4src; + fltr->ip_mask.v4_addrs.dst_ip = fsp->m_u.ah_ip4_spec.ip4dst; + fltr->ip_mask.spi = fsp->m_u.ah_ip4_spec.spi; + fltr->ip_mask.tos = fsp->m_u.ah_ip4_spec.tos; +break ; +case IPV4_USER_FLOW : + fltr->ip_data.v4_addrs.src_ip = fsp->h_u.usr_ip4_spec.ip4src; + fltr->ip_data.v4_addrs.dst_ip = fsp->h_u.usr_ip4_spec.ip4dst; + fltr->ip_data.l4_header = fsp->h_u.usr_ip4_spec.l4_4_bytes; + fltr->ip_data.tos = fsp->h_u.usr_ip4_spec.tos; + fltr->ip_data.proto = fsp->h_u.usr_ip4_spec.proto; + fltr->ip_mask.v4_addrs.src_ip = fsp->m_u.usr_ip4_spec.ip4src; + fltr->ip_mask.v4_addrs.dst_ip = fsp->m_u.usr_ip4_spec.ip4dst; + fltr->ip_mask.l4_header = fsp->m_u.usr_ip4_spec.l4_4_bytes; + fltr->ip_mask.tos = fsp->m_u.usr_ip4_spec.tos; + fltr->ip_mask.proto = fsp->m_u.usr_ip4_spec.proto; +break ; +case TCP_V6_FLOW : +case UDP_V6_FLOW : +case SCTP_V6_FLOW : +memcpy (&fltr->ip_data.v6_addrs.src_ip, + fsp->h_u.usr_ip6_spec.ip6src,sizeof (struct in6_addr )); +memcpy (&fltr->ip_data.v6_addrs.dst_ip, + fsp->h_u.usr_ip6_spec.ip6dst,sizeof (struct in6_addr )); + fltr->ip_data.src_port = fsp->h_u.tcp_ip6_spec.psrc; + fltr->ip_data.dst_port = fsp->h_u.tcp_ip6_spec.pdst; + fltr->ip_data.tclass = fsp->h_u.tcp_ip6_spec.tclass; +memcpy (&fltr->ip_mask.v6_addrs.src_ip, + fsp->m_u.usr_ip6_spec.ip6src,sizeof (struct in6_addr )); +memcpy (&fltr->ip_mask.v6_addrs.dst_ip, + fsp->m_u.usr_ip6_spec.ip6dst,sizeof (struct in6_addr )); + fltr->ip_mask.src_port = fsp->m_u.tcp_ip6_spec.psrc; + fltr->ip_mask.dst_port = fsp->m_u.tcp_ip6_spec.pdst; + fltr->ip_mask.tclass = fsp->m_u.tcp_ip6_spec.tclass; +break ; +case AH_V6_FLOW : +case ESP_V6_FLOW : +memcpy (&fltr->ip_data.v6_addrs.src_ip, + fsp->h_u.ah_ip6_spec.ip6src,sizeof (struct in6_addr )); +memcpy (&fltr->ip_data.v6_addrs.dst_ip, + fsp->h_u.ah_ip6_spec.ip6dst,sizeof (struct in6_addr )); + fltr->ip_data.spi = fsp->h_u.ah_ip6_spec.spi; + fltr->ip_data.tclass = fsp->h_u.ah_ip6_spec.tclass; +memcpy (&fltr->ip_mask.v6_addrs.src_ip, + fsp->m_u.ah_ip6_spec.ip6src,sizeof (struct in6_addr )); +memcpy (&fltr->ip_mask.v6_addrs.dst_ip, + fsp->m_u.ah_ip6_spec.ip6dst,sizeof (struct in6_addr )); + fltr->ip_mask.spi = fsp->m_u.ah_ip6_spec.spi; + fltr->ip_mask.tclass = fsp->m_u.ah_ip6_spec.tclass; +break ; +case IPV6_USER_FLOW : +memcpy (&fltr->ip_data.v6_addrs.src_ip, + fsp->h_u.usr_ip6_spec.ip6src,sizeof (struct in6_addr )); +memcpy (&fltr->ip_data.v6_addrs.dst_ip, + fsp->h_u.usr_ip6_spec.ip6dst,sizeof (struct in6_addr )); + fltr->ip_data.l4_header = fsp->h_u.usr_ip6_spec.l4_4_bytes; + fltr->ip_data.tclass = fsp->h_u.usr_ip6_spec.tclass; + fltr->ip_data.proto = fsp->h_u.usr_ip6_spec.l4_proto; +memcpy (&fltr->ip_mask.v6_addrs.src_ip, + fsp->m_u.usr_ip6_spec.ip6src,sizeof (struct in6_addr )); +memcpy (&fltr->ip_mask.v6_addrs.dst_ip, + fsp->m_u.usr_ip6_spec.ip6dst,sizeof (struct in6_addr )); + fltr->ip_mask.l4_header = fsp->m_u.usr_ip6_spec.l4_4_bytes; + fltr->ip_mask.tclass = fsp->m_u.usr_ip6_spec.tclass; + fltr->ip_mask.proto = fsp->m_u.usr_ip6_spec.l4_proto; +break ; +case ETHER_FLOW : + fltr->eth_data.etype = fsp->h_u.ether_spec.h_proto; + fltr->eth_mask.etype = fsp->m_u.ether_spec.h_proto; +break ; +default : +/* not doing un-parsed flow types */ +return -EINVAL ; + } + +if (iecm_fdir_is_dup_fltr (adapter, fltr)) +return -EEXIST ; + + err =iecm_parse_rx_flow_user_data (fsp, fltr); +if (err) +return err; + +return iecm_fill_fdir_add_msg (vport, fltr); +} + +/** +* iecm_add_fdir_fltr - add Flow Director filter +* @vport: vport structure +* @cmd: command to add Flow Director filter +* +* Returns 0 on success and negative values for failure +*/ +int iecm_add_fdir_fltr (struct iecm_vport *vport,struct ethtool_rxnfc *cmd) +{ +struct iecm_adapter *adapter = vport->adapter; +struct ethtool_rx_flow_spec *fsp = &cmd->fs; +struct iecm_fdir_fltr_config *fdir_config; +struct iecm_fdir_fltr *fltr; +int err; + +if (adapter->state != __IECM_UP) +return -EIO ; + +if (!iecm_is_cap_ena (adapter,IECM_OTHER_CAPS ,VIRTCHNL2_CAP_FDIR )) +return -EOPNOTSUPP ; + +if (fsp->flow_type &FLOW_MAC_EXT ) +return -EINVAL ; + + fdir_config = &adapter->config_data.fdir_config; +if (fdir_config->num_active_filters >=IECM_MAX_FDIR_FILTERS ) { +dev_err (&adapter->pdev->dev, +"Unable to add Flow Director filter because vport reached the limit of max allowed filters (%u)\n" , +IECM_MAX_FDIR_FILTERS ); +return -ENOSPC ; + }Lines of this file are not shown. View the raw message.
drivers/net/ethernet/intel/iecm/iecm_virtchnl.c +37
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
if (!fdir->add)
5 lines not shown · raw message
243 lines not shown · raw message
Parts of this message are not shown here. View the raw message.
Brady
PATCH 16/19 iecm: implement flow director
Quoted 107 lines
-----Original Message-----
From: Lobakin, Alexandr <[email protected]>
Sent: Friday, January 28, 2022 11:04 AM
To: Brady, Alan <[email protected]>
Cc: Lobakin, Alexandr <[email protected]>; Wang, Haiyue <[email protected]>; Burra, Phani R <[email protected]>; Chittim, Madhu <[email protected]>; Linga, Pavan Kumar <[email protected]>; intel-wired-lan at lists.osuosl.org
Subject: Re: [Intel-wired-lan] [PATCH net-next 16/19] iecm: implement flow directorFrom: Alan Brady <[email protected]>
Date: Thu, 27 Jan 2022 16:10:06 -0800Quoted 8 lines
From: Haiyue Wang <[email protected]>
This adds everthing needed to do flow director commands.
Signed-off-by Haiyue Wang <[email protected]>--- .../net/ethernet/intel/iecm/iecm_ethtool.c | 17 +- drivers/net/ethernet/intel/iecm/iecm_lib.c | 1528++++++++++++++++-
Review
Quoted 5 lines
.../net/ethernet/intel/iecm/iecm_virtchnl.c | 119 ++ drivers/net/ethernet/intel/include/iecm.h | 112 ++ 4 files changed, 1770 insertions(+), 6 deletions(-)(quoted diff) +0
-0
b/drivers/net/ethernet/intel/iecm/iecm_ethtool.cdrivers/net/ethernet/intel/iecm/iecm_ethtool.c static int iecm_get_rxnfc(struct net_device *netdev,
Quoted 4 lines
index
32d905fb1bb6..7e252b25e02d100644drivers/net/ethernet/intel/iecm/iecm_ethtool.c +0
-0@@ -15,6 +15,7 @@ static int iecm_get_rxnfc(struct net_device *netdev,struct
ethtool_rxnfc*cmd,drivers/net/ethernet/intel/iecm/iecm_ethtool.c static int iecm_get_rxnfc(struct net_device
Quoted 8 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c +1
-0u32 __always_unused *rule_locs) {struct iecm_vport *vport =iecm_netdev_to_vport (netdev); +struct iecm_adapter *adapter = vport->adapter;int ret = -EOPNOTSUPP ;switch (cmd->cmd) {@@ -23,14 +24,19 @@ static int iecm_get_rxnfc(struct net_device*netdev, struct
ethtool_rxnfc*cmd,drivers/net/ethernet/intel/iecm/iecm_ethtool.c static int iecm_get_rxnfc(struct net_device
Quoted 24 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c +8
-3ret =0 ;break ;case ETHTOOL_GRXCLSRLCNT : -/* stub */ +if (!iecm_is_cap_ena (adapter,IECM_OTHER_CAPS , +VIRTCHNL2_CAP_FDIR )) +break ; + cmd->rule_cnt = + adapter- config_data.fdir_config.num_active_filters; + cmd->data =IECM_MAX_FDIR_FILTERS ; ret =0 ;break ;case ETHTOOL_GRXCLSRULE : -/* stub */ + ret =iecm_get_fdir_fltr_entry (vport, cmd);break ;case ETHTOOL_GRXCLSRLALL : -/* stub */ + ret =iecm_get_fdir_fltr_ids (vport, cmd, (u32 *)rule_locs);break ;case ETHTOOL_GRXFH :drivers/net/ethernet/intel/iecm/iecm_ethtool.c +0
-0/* stub */ @@ -51,14 +57,15 @@ static int iecm_get_rxnfc(struct net_device*netdev, struct
ethtool_rxnfc*cmd,drivers/net/ethernet/intel/iecm/iecm_ethtool.c static int iecm_get_rxnfc(struct net_device · line 58
Quoted 2 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c +0
-0*/ static int iecm_set_rxnfc(struct net_device *netdev, struct ethtool_rxnfc*cmd)
Review
Quoted 16 lines
drivers/net/ethernet/intel/iecm/iecm_ethtool.c +3
-2{ +struct iecm_vport *vport =iecm_netdev_to_vport (netdev);int ret = -EOPNOTSUPP ;switch (cmd->cmd) {case ETHTOOL_SRXCLSRLINS : -/* stub */ + ret =iecm_add_fdir_fltr (vport, cmd);break ;case ETHTOOL_SRXCLSRLDEL : -/* stub */ + ret =iecm_del_fdir_fltr (vport, cmd);break ;case ETHTOOL_SRXFH :/* stub */ (quoted diff) +0
-0
b/drivers/net/ethernet/intel/iecm/iecm_lib.cdrivers/net/ethernet/intel/iecm/iecm_lib.c static void iecm_remove_vlan_filters(struct
Quoted 4 lines
index
c5900723b018..35c0cbc42ebe100644drivers/net/ethernet/intel/iecm/iecm_lib.c +0
-0@@ -967,6 +967,56 @@ static void iecm_remove_vlan_filters(struct
iecm_vport*vport)drivers/net/ethernet/intel/iecm/iecm_lib.c static void iecm_remove_vlan_filters(struct iecm_vport *vport)
Quoted 13 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0} } +/** +* iecm_remove_fdir_filters - Remove all Flow Director filters +* @vport: vport structure +*/ +static void iecm_remove_fdir_filters(struct iecm_vport *vport) +{ + struct iecm_adapter *adapter = vport->adapter; + struct iecm_fdir_fltr_config *fdir_config; + + if (!iecm_is_cap_ena(adapter, IECM_OTHER_CAPS,
VIRTCHNL2_CAP_FDIR))
Quoted 13 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c static void iecm_remove_vlan_filters(struct iecm_vport *vport) · line 989
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+return ; + + fdir_config = &adapter->config_data.fdir_config; +if (!list_empty (&fdir_config->fdir_fltr_list)) { +struct iecm_fdir_fltr *fdir; + +spin_lock_bh (&adapter->fdir_fltr_list_lock); +list_for_each_entry (fdir, &fdir_config->fdir_fltr_list, list) { + fdir->remove = true; + }Braces are redundant here.
Will fix
Quoted 11 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c static void iecm_remove_vlan_filters(struct iecm_vport *vport) · line 992
Quoted 3 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +3
-0+spin_unlock_bh (&adapter->fdir_fltr_list_lock); +iecm_send_del_fdir_filter_msg (vport); + }if (list_empty()) return; spin_lock_bh(...-1 indent level.
Yeah there's probably a bunch of these. Will fix.
Quoted 124 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c static void iecm_vport_stop(struct iecm_vport
Quoted 31 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +27
-0+} + +/** +* iecm_del_all_fdir_filters - delete all Flow Director filters +* @vport: vport structure +* +* This function will loop through the list of Flow Director filters and +* deletes them. +**/ +static void iecm_del_all_fdir_filters (struct iecm_vport *vport) +{ +struct iecm_adapter *adapter = vport->adapter; +struct iecm_fdir_fltr_config *fdir_config; +struct iecm_fdir_fltr *fdir, *fdir_tmp; + + fdir_config = &adapter->config_data.fdir_config; + +spin_lock_bh (&adapter->fdir_fltr_list_lock); +list_for_each_entry_safe (fdir, fdir_tmp, &fdir_config->fdir_fltr_list, + list) { +list_del (&fdir->list); +kfree (fdir); + } + fdir_config->num_active_filters =0 ; +spin_unlock_bh (&adapter->fdir_fltr_list_lock); +} +/** * iecm_vport_stop - Disable a vport * @vport: vport to disable @@ -997,6 +1047,8 @@ static void iecm_vport_stop(struct iecm_vport*vport)
drivers/net/ethernet/intel/iecm/iecm_lib.c static void iecm_restore_vlans(struct
Quoted 9 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +2
-0if (!test_bit (__IECM_REL_RES_IN_PROG, adapter->flags))iecm_remove_vlan_filters (vport); +iecm_remove_fdir_filters (vport); + adapter->link_up = false;iecm_vport_intr_deinit (vport);iecm_vport_intr_rel (vport);@@ -1206,6 +1258,28 @@ static void iecm_restore_vlans(struct
iecm_vport*vport)Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +7
-0iecm_set_all_vlans (vport); } +/** +* iecm_restore_fdir_filters - Restore all Flow Director filters +* @vport: vport structure +*/ +static void iecm_restore_fdir_filters (struct iecm_vport *vport) +{ +struct iecm_adapter *adapter = vport->adapter;drivers/net/ethernet/intel/iecm/iecm_lib.c static void iecm_restore_vlans(struct iecm_vport *vport) · line 1277
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+struct iecm_fdir_fltr_config *fdir_config; + + fdir_config = &adapter->config_data.fdir_config; +if (!list_empty (&fdir_config->fdir_fltr_list)) { +struct iecm_fdir_fltr *fdir; + +spin_lock_bh (&adapter->fdir_fltr_list_lock); +list_for_each_entry (fdir, &fdir_config->fdir_fltr_list, list) { + fdir->add = true; + }Braces are redundant for one-liners.
drivers/net/ethernet/intel/iecm/iecm_lib.c static void iecm_restore_vlans(struct iecm_vport *vport) · line 1280
Quoted 3 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +3
-0+spin_unlock_bh (&adapter->fdir_fltr_list_lock); +iecm_send_add_fdir_filter_msg (vport); + }Invert the condition -> -1 indent level.
drivers/net/ethernet/intel/iecm/iecm_lib.c static void iecm_restore_features(struct
Quoted 6 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +2
-0+} +/** * iecm_restore_features - Restore feature configs * @vport: virtual port structure @@ -1227,6 +1301,9 @@ static void iecm_restore_features(struct
iecm_vport*vport)drivers/net/ethernet/intel/iecm/iecm_lib.c static void iecm_restore_features(struct · line 1302
Quoted 2 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +0
-0if (iecm_set_promiscuous (adapter)) dev_info(&adapter->pdev->dev, "Failed to restorepromiscuous settings\n");
drivers/net/ethernet/intel/iecm/iecm_lib.c static void iecm_remove_vlan_filters(struct iecm_vport *vport)
Quoted 3 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +2
-0} + + if (iecm_is_cap_ena(adapter, IECM_OTHER_CAPS,
VIRTCHNL2_CAP_FDIR))drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device
Quoted 32 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +13
-1+iecm_restore_fdir_filters (vport); }/** @@ -2014,6 +2091,7 @@ int iecm_probe(struct pci_dev *pdev,INIT_LIST_HEAD (&adapter->config_data.mac_filter_list);INIT_LIST_HEAD (&adapter->config_data.vlan_filter_list);INIT_LIST_HEAD (&adapter->config_data.adv_rss_list); +INIT_LIST_HEAD (&adapter->config_data.fdir_config.fdir_fltr_list);INIT_DELAYED_WORK (&adapter->stats_task, iecm_statistics_task);INIT_DELAYED_WORK (&adapter->serv_task, iecm_service_task);@@ -2052,7 +2130,17 @@ EXPORT_SYMBOL(iecm_probe);*/ static void iecm_del_user_cfg_data (struct iecm_adapter *adapter) { -/* stub */ +int i; + +if (!adapter->vports) +return ; + +for (i =0 ; i < adapter->num_alloc_vport; i++) { +if (!adapter->vports[i]) +continue ; + +iecm_del_all_fdir_filters (adapter->vports[i]); + } }/** @@ -2647,6 +2735,1444 @@ static int iecm_setup_tc(struct net_device*netdev, enum
tc_setup_typetype,drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type,
Quoted 5 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +2
-0return err; } +/** +* iecm_pkt_udp_no_pay_len - the length of UDP packet without payload
Quoted 9 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 2745
Quoted 6 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +6
-0+* @fltr: Flow Director filter data structure +*/ +static u16 iecm_pkt_udp_no_pay_len (struct iecm_fdir_fltr *fltr) +{ + return sizeof(struct ethhdr) + + (fltr->ip_ver == 4 ? sizeof(struct iphdr)IPv4 hdr may have extensions.
This one I'm not confident on. Will have to check.
Quoted 40 lines
Quoted 9 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +9
-0+ : sizeof(struct ipv6hdr)) + +sizeof (struct udphdr ); +} + +/** +* iecm_fill_fdir_gtpu_hdr - fill the GTP-U protocol header +* @fltr: Flow Director filter data structure +* @proto_hdrs: Flow Director protocol headers data structure +* drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type,
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +8
-0+* Returns 0 if the GTP-U protocol header is set successfully +*/ +static int +iecm_fill_fdir_gtpu_hdr (struct iecm_fdir_fltr *fltr, +struct virtchnl_proto_hdrs *proto_hdrs) +{ +struct virtchnl_proto_hdr *uhdr = &proto_hdrs- proto_hdr[proto_hdrs->count -1 ]; +struct virtchnl_proto_hdr *ghdr = &proto_hdrs- proto_hdr[proto_hdrs->count++];Lines over 79.
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type,
Quoted 13 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +13
-0+struct virtchnl_proto_hdr *ehdr =NULL ; +u16 adj_offs, hdr_offs; +int i; + +VIRTCHNL_SET_PROTO_HDR_TYPE (ghdr,GTPU_IP ); + + adj_offs =iecm_pkt_udp_no_pay_len (fltr); + +for (i =0 ; i < fltr->flex_cnt; i++) { +#define IECM_GTPU_HDR_TEID_OFFS0 4 +#define IECM_GTPU_HDR_TEID_OFFS1 6 +#define IECM_GTPU_HDR_N_PDU_AND_NEXT_EXTHDR_OFFS 10 +#define IECM_GTPU_HDR_NEXT_EXTHDR_TYPE_MASK 0x00FF /* skip N_PDU */drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type,
Quoted 3 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +3
-0+/* PDU Session Container Extension Header (PSC) */ +#define IECM_GTPU_PSC_EXTHDR_TYPE 0x85 +#define IECM_GTPU_HDR_PSC_PDU_TYPE_AND_QFI_OFFS 13
Quoted 6 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device · line 2781
Quoted 1 line
drivers/net/ethernet/intel/iecm/iecm_lib.c +1
-0+#define IECM_GTPU_HDR_PSC_PDU_QFI_MASK 0x3F/* skip Type */
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 2780
Quoted 1 line
drivers/net/ethernet/intel/iecm/iecm_lib.c +1
-0+#define IECM_GTPU_EH_QFI_IDX 1It's better to define them outside the function.
I'll take a look.
Quoted 6 lines
Quoted 6 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +6
-0+ +if (fltr->flex_words[i].offset < adj_offs) +return -EINVAL ; + + hdr_offs = fltr->flex_words[i].offset - adj_offs; +
Quoted 9 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type,
Quoted 5 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +4
-0+switch (hdr_offs) { +case IECM_GTPU_HDR_TEID_OFFS0 : +case IECM_GTPU_HDR_TEID_OFFS1 : { +__be16 *pay_word = (__force __be16 *)ghdr- buffer;I'd declare @pay_word outside of switch-case (which is recommended) to remove braces around the body.
Sure will fix.
Quoted 28 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type,
Quoted 4 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +4
-0+ + pay_word[hdr_offs >>1 ] = +htons (fltr->flex_words[i].word); + VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(ghdr,
GTPU_IP, TEID);drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type,
Quoted 5 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +5
-0+ } +break ; +case IECM_GTPU_HDR_N_PDU_AND_NEXT_EXTHDR_OFFS : +if ((fltr->flex_words[i].word & + IECM_GTPU_HDR_NEXT_EXTHDR_TYPE_MASK)!=
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device · line 2803
Quoted 1 line
drivers/net/ethernet/intel/iecm/iecm_lib.c +1
-0+
IECM_GTPU_PSC_EXTHDR_TYPE)drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 2819
Quoted 13 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +4
-0+return -EOPNOTSUPP ; +if (!ehdr) + ehdr = + &proto_hdrs->proto_hdr[proto_hdrs-count++];
drivers/net/ethernet/intel/iecm/iecm_lib.c +8
-0+VIRTCHNL_SET_PROTO_HDR_TYPE (ehdr,GTPU_EH ); +break ; +case IECM_GTPU_HDR_PSC_PDU_TYPE_AND_QFI_OFFS : +if (!ehdr) +return -EINVAL ; + ehdr->buffer[IECM_GTPU_EH_QFI_IDX ] = + fltr->flex_words[i].word & +IECM_GTPU_HDR_PSC_PDU_QFI_MASK;
Quoted 3 lines
Inconsistent indentation here, filtr-> and
IECM_should be on the same level.
Will fix
Quoted 34 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c
Quoted 1 line
drivers/net/ethernet/intel/iecm/iecm_lib.c +1
-0+ VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(ehdr,
GTPU_EH, QFI);Quoted 28 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +25
-0+break ; +default : +return -EINVAL ; + } + } + +/* The PF ignores the UDP header fields */ + uhdr->field_selector =0 ; + +return 0 ; +} + +/** +* iecm_fill_fdir_pfcp_hdr - fill the PFCP protocol header +* @fltr: Flow Director filter data structure +* @proto_hdrs: Flow Director protocol headers data structure +* +* Returns 0 if the PFCP protocol header is set successfully +*/ +static int +iecm_fill_fdir_pfcp_hdr (struct iecm_fdir_fltr *fltr, +struct virtchnl_proto_hdrs *proto_hdrs) +{ +struct virtchnl_proto_hdr *uhdr = + &proto_hdrs->proto_hdr[proto_hdrs-count - 1];
drivers/net/ethernet/intel/iecm/iecm_lib.c +2
-0+struct virtchnl_proto_hdr *hdr = + &proto_hdrs->proto_hdr[proto_hdrs-Quoted 1 line
count++];
Both could be declared and assigned separately to avoid line breaks.
Quoted 12 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 2849
Quoted 9 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +9
-0+u16 adj_offs, hdr_offs; +int i; + +VIRTCHNL_SET_PROTO_HDR_TYPE (hdr,PFCP ); + + adj_offs =iecm_pkt_udp_no_pay_len (fltr); + +for (i =0 ; i < fltr->flex_cnt; i++) { +#define IECM_PFCP_HDR_SFIELD_AND_MSG_TYPE_OFFS 0Better to define outside the function.
Sure
Quoted 12 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type,
Quoted 8 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +8
-0+if (fltr->flex_words[i].offset < adj_offs) +return -EINVAL ; + + hdr_offs = fltr->flex_words[i].offset - adj_offs; + +switch (hdr_offs) { +case IECM_PFCP_HDR_SFIELD_AND_MSG_TYPE_OFFS : + hdr->buffer[0] = (fltr->flex_words[i].word >> 8) &
0xff;Quoted 1 line
Quoted 1 line
8 and &
0xffare candidates forFIELD_GET(GENMASK(15, 8)).
Will fix
Quoted 115 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c
Quoted 1 line
drivers/net/ethernet/intel/iecm/iecm_lib.c +1
-0+ VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, PFCP,
S_FIELD);Quoted 28 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +25
-0+break ; +default : +return -EINVAL ; + } + } + +/* The PF ignores the UDP header fields */ + uhdr->field_selector =0 ; + +return 0 ; +} + +/** +* iecm_fill_fdir_nat_t_esp_hdr - fill the NAT-T-ESP protocol header +* @fltr: Flow Director filter data structure +* @proto_hdrs: Flow Director protocol headers data structure +* +* Returns 0 if the NAT-T-ESP protocol header is set successfully +*/ +static int +iecm_fill_fdir_nat_t_esp_hdr (struct iecm_fdir_fltr *fltr, +struct virtchnl_proto_hdrs *proto_hdrs) +{ +struct virtchnl_proto_hdr *uhdr = + &proto_hdrs->proto_hdr[proto_hdrs-count - 1];
drivers/net/ethernet/intel/iecm/iecm_lib.c +2
-0+struct virtchnl_proto_hdr *hdr = + &proto_hdrs->proto_hdr[proto_hdrs-Quoted 1 line
count++];
Same here about line wraps.
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 2896
Quoted 11 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +11
-0+u16 adj_offs, hdr_offs; +u32 spi =0 ; +int i; + +VIRTCHNL_SET_PROTO_HDR_TYPE (hdr,ESP ); + + adj_offs =iecm_pkt_udp_no_pay_len (fltr); + +for (i =0 ; i < fltr->flex_cnt; i++) { +#define IECM_NAT_T_ESP_SPI_OFFS0 0 +#define IECM_NAT_T_ESP_SPI_OFFS1 2Same here about definitions. It would be harder to look for them later (not counting grep and Elixir).
Quoted 26 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +26
-0+if (fltr->flex_words[i].offset < adj_offs) +return -EINVAL ; + + hdr_offs = fltr->flex_words[i].offset - adj_offs; + +switch (hdr_offs) { +case IECM_NAT_T_ESP_SPI_OFFS0 : + spi |= fltr->flex_words[i].word <<16 ; +break ; +case IECM_NAT_T_ESP_SPI_OFFS1 : + spi |= fltr->flex_words[i].word; +break ; +default : +return -EINVAL ; + } + } + +/* Not support IKE Header Format with SPI 0 */ +if (!spi) +return -EOPNOTSUPP ; + + *(__force __be32 *)hdr->buffer =htonl (spi); +VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (hdr,ESP ,SPI ); + +/* The PF ignores the UDP header fields */ + uhdr->field_selector =0 ;drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type,
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+ +return 0 ; +} + +/** +* iecm_fill_fdir_udp_flex_pay_hdr - fill the UDP payload header +* @fltr: Flow Director filter data structure +* @proto_hdrs: Flow Director protocol headers data structure +* +* Returns 0 if the UDP payload defined protocol header is set successfully
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 2940
Quoted 8 lines
+ */
drivers/net/ethernet/intel/iecm/iecm_lib.c +7
-0+static int +iecm_fill_fdir_udp_flex_pay_hdr (struct iecm_fdir_fltr *fltr, +struct virtchnl_proto_hdrs *proto_hdrs) +{ +#define IECM_GTPU_PORT 2152 +#define IECM_NAT_T_ESP_PORT 4500 +#define IECM_PFCP_PORT 8805Same for those, they don't belong here at all.
Quoted 5 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +5
-0+int err; + +switch (ntohs (fltr->ip_data.dst_port)) { +case IECM_GTPU_PORT : + err =iecm_fill_fdir_gtpu_hdr (fltr, proto_hdrs);drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 2955
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+break ; +case IECM_NAT_T_ESP_PORT : + err =iecm_fill_fdir_nat_t_esp_hdr (fltr, proto_hdrs); +break ; +case IECM_PFCP_PORT : + err =iecm_fill_fdir_pfcp_hdr (fltr, proto_hdrs); +break ; +default : + err = -EOPNOTSUPP ; +break ;All of those should be converted to just
Quoted 4 lines
return
iecm_...directly, rather than assigning it to err just to return err.
Sure will fix.
Quoted 66 lines
Quoted 17 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +17
-0+ } + +return err; +} + +/** +* iecm_fill_fdir_ip4_hdr - fill the IPv4 protocol header +* @fltr: Flow Director filter data structure +* @proto_hdrs: Flow Director protocol headers data structure +* +* Returns 0 if the IPv4 protocol header is set successfully +*/ +static int iecm_fill_fdir_ip4_hdr (struct iecm_fdir_fltr *fltr, +struct virtchnl_proto_hdrs *proto_hdrs) +{ +struct virtchnl_proto_hdr *hdr = + &proto_hdrs->proto_hdr[proto_hdrs-Quoted 1 line
count++];
Same for this about line break.
Quoted 34 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +34
-0+struct iphdr *iph = (struct iphdr *)hdr->buffer; + +VIRTCHNL_SET_PROTO_HDR_TYPE (hdr,IPV4 ); + +if (fltr->ip_mask.tos ==U8_MAX ) { + iph->tos = fltr->ip_data.tos; +VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (hdr,IPV4 ,DSCP ); + } + +if (fltr->ip_mask.proto ==U8_MAX ) { + iph->protocol = fltr->ip_data.proto; +VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (hdr,IPV4 ,PROT ); + } + +if (fltr->ip_mask.v4_addrs.src_ip ==htonl (U32_MAX )) { + iph->saddr = fltr->ip_data.v4_addrs.src_ip; +VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (hdr,IPV4 ,SRC ); + } + +if (fltr->ip_mask.v4_addrs.dst_ip ==htonl (U32_MAX )) { + iph->daddr = fltr->ip_data.v4_addrs.dst_ip; +VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (hdr,IPV4 ,DST ); + } + + fltr->ip_ver =4 ; + +return 0 ; +} + +/** +* iecm_fill_fdir_ip6_hdr - fill the IPv6 protocol header +* @fltr: Flow Director filter data structure +* @proto_hdrs: Flow Director protocol headers data structure +* drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type,
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+* Returns 0 if the IPv6 protocol header is set successfully +*/ +static int +iecm_fill_fdir_ip6_hdr (struct iecm_fdir_fltr *fltr, +struct virtchnl_proto_hdrs *proto_hdrs) +{ +static const struct in6_addr ipv6_addr_full_mask = { + .in6_u = { + .u6_addr8 = { +0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,
0xFF,
Quoted 5 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c
Quoted 1 line
drivers/net/ethernet/intel/iecm/iecm_lib.c +1
-0+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF,Lowercase is generally more preferred for hex constants.
Will fix.
Quoted 448 lines
Quoted 6 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +5
-0+ } + } + }; +struct virtchnl_proto_hdr *hdr = + &proto_hdrs->proto_hdr[proto_hdrs-count++];
Same.
Quoted 6 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +6
-0+struct ipv6hdr *iph = (struct ipv6hdr *)hdr->buffer; + +VIRTCHNL_SET_PROTO_HDR_TYPE (hdr,IPV6 ); + +if (fltr->ip_mask.tclass ==U8_MAX ) { + iph->priority = (fltr->ip_data.tclass >>4 ) &0xF ;drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type,
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+ iph->flow_lbl[0 ] = (fltr->ip_data.tclass <<4 ) &0xF0 ; +VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (hdr,IPV6 ,TC ); + } + +if (fltr->ip_mask.proto ==U8_MAX ) { + iph->nexthdr = fltr->ip_data.proto; +VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (hdr,IPV6 ,PROT ); + } + + if (!memcmp(&fltr->ip_mask.v6_addrs.src_ip,
&ipv6_addr_full_mask,drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type,
Quoted 7 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +7
-0+ sizeof(struct in6_addr))) { +memcpy (&iph->saddr, &fltr->ip_data.v6_addrs.src_ip, +sizeof (struct in6_addr )); +VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (hdr,IPV6 ,SRC ); + } + + if (!memcmp(&fltr->ip_mask.v6_addrs.dst_ip,
&ipv6_addr_full_mask,Quoted 24 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +24
-0+ sizeof(struct in6_addr))) { +memcpy (&iph->daddr, &fltr->ip_data.v6_addrs.dst_ip, +sizeof (struct in6_addr )); +VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (hdr,IPV6 ,DST ); + } + + fltr->ip_ver =6 ; + +return 0 ; +} + +/** +* iecm_fill_fdir_tcp_hdr - fill the TCP protocol header +* @fltr: Flow Director filter data structure +* @proto_hdrs: Flow Director protocol headers data structure +* +* Returns 0 if the TCP protocol header is set successfully +*/ +static int +iecm_fill_fdir_tcp_hdr (struct iecm_fdir_fltr *fltr, +struct virtchnl_proto_hdrs *proto_hdrs) +{ +struct virtchnl_proto_hdr *hdr = + &proto_hdrs->proto_hdr[proto_hdrs-Quoted 1 line
count++];
Same.
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type,
Quoted 7 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +7
-0+struct tcphdr *tcph = (struct tcphdr *)hdr->buffer; + +VIRTCHNL_SET_PROTO_HDR_TYPE (hdr,TCP ); + +if (fltr->ip_mask.src_port ==htons (U16_MAX )) { + tcph->source = fltr->ip_data.src_port; + VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, TCP,
SRC_PORT);drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type,
Quoted 5 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +5
-0+ } + +if (fltr->ip_mask.dst_port ==htons (U16_MAX )) { + tcph->dest = fltr->ip_data.dst_port; + VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, TCP,
DST_PORT);Quoted 19 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +18
-0+ } + +return 0 ; +} + +/** +* iecm_fill_fdir_udp_hdr - fill the UDP protocol header +* @fltr: Flow Director filter data structure +* @proto_hdrs: Flow Director protocol headers data structure +* +* Returns 0 if the UDP protocol header is set successfully +*/ +static int +iecm_fill_fdir_udp_hdr (struct iecm_fdir_fltr *fltr, +struct virtchnl_proto_hdrs *proto_hdrs) +{ +struct virtchnl_proto_hdr *hdr = + &proto_hdrs->proto_hdr[proto_hdrs-count++];
...
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type,
Quoted 7 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +7
-0+struct udphdr *udph = (struct udphdr *)hdr->buffer; + +VIRTCHNL_SET_PROTO_HDR_TYPE (hdr,UDP ); + +if (fltr->ip_mask.src_port ==htons (U16_MAX )) { + udph->source = fltr->ip_data.src_port; + VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, UDP,
SRC_PORT);drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type,
Quoted 5 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +5
-0+ } + +if (fltr->ip_mask.dst_port ==htons (U16_MAX )) { + udph->dest = fltr->ip_data.dst_port; + VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, UDP,
DST_PORT);Quoted 22 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +21
-0+ } + +if (!fltr->flex_cnt) +return 0 ; + +return iecm_fill_fdir_udp_flex_pay_hdr (fltr, proto_hdrs); +} + +/** +* iecm_fill_fdir_sctp_hdr - fill the SCTP protocol header +* @fltr: Flow Director filter data structure +* @proto_hdrs: Flow Director protocol headers data structure +* +* Returns 0 if the SCTP protocol header is set successfully +*/ +static int +iecm_fill_fdir_sctp_hdr (struct iecm_fdir_fltr *fltr, +struct virtchnl_proto_hdrs *proto_hdrs) +{ +struct virtchnl_proto_hdr *hdr = + &proto_hdrs->proto_hdr[proto_hdrs-count++];
...
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type,
Quoted 7 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +7
-0+struct sctphdr *sctph = (struct sctphdr *)hdr->buffer; + +VIRTCHNL_SET_PROTO_HDR_TYPE (hdr,SCTP ); + +if (fltr->ip_mask.src_port ==htons (U16_MAX )) { + sctph->source = fltr->ip_data.src_port; + VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, SCTP,
SRC_PORT);drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type,
Quoted 5 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +5
-0+ } + +if (fltr->ip_mask.dst_port ==htons (U16_MAX )) { + sctph->dest = fltr->ip_data.dst_port; + VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, SCTP,
DST_PORT);Quoted 19 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +18
-0+ } + +return 0 ; +} + +/** +* iecm_fill_fdir_ah_hdr - fill the AH protocol header +* @fltr: Flow Director filter data structure +* @proto_hdrs: Flow Director protocol headers data structure +* +* Returns 0 if the AH protocol header is set successfully +*/ +static int +iecm_fill_fdir_ah_hdr (struct iecm_fdir_fltr *fltr, +struct virtchnl_proto_hdrs *proto_hdrs) +{ +struct virtchnl_proto_hdr *hdr = + &proto_hdrs->proto_hdr[proto_hdrs-count++];
...
Quoted 26 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +25
-0+struct ip_auth_hdr *ah = (struct ip_auth_hdr *)hdr->buffer; + +VIRTCHNL_SET_PROTO_HDR_TYPE (hdr,AH ); + +if (fltr->ip_mask.spi ==htonl (U32_MAX )) { + ah->spi = fltr->ip_data.spi; +VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (hdr,AH ,SPI ); + } + +return 0 ; +} + +/** +* iecm_fill_fdir_esp_hdr - fill the ESP protocol header +* @fltr: Flow Director filter data structure +* @proto_hdrs: Flow Director protocol headers data structure +* +* Returns 0 if the ESP protocol header is set successfully +*/ +static int +iecm_fill_fdir_esp_hdr (struct iecm_fdir_fltr *fltr, +struct virtchnl_proto_hdrs *proto_hdrs) +{ +struct virtchnl_proto_hdr *hdr = + &proto_hdrs->proto_hdr[proto_hdrs-count++];
...
Quoted 20 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +20
-0+struct ip_esp_hdr *esph = (struct ip_esp_hdr *)hdr->buffer; + +VIRTCHNL_SET_PROTO_HDR_TYPE (hdr,ESP ); + +if (fltr->ip_mask.spi ==htonl (U32_MAX )) { + esph->spi = fltr->ip_data.spi; +VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (hdr,ESP ,SPI ); + } + +return 0 ; +} + +/** +* iecm_fill_fdir_l4_hdr - fill the L4 protocol header +* @fltr: Flow Director filter data structure +* @proto_hdrs: Flow Director protocol headers data structure +* +* Returns 0 if the L4 protocol header is set successfully +*/ +static intdrivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 3217
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+iecm_fill_fdir_l4_hdr(struct iecm_fdir_fltr *fltr, + struct virtchnl_proto_hdrs *proto_hdrs) +{ + struct virtchnl_proto_hdr *hdr; +__be32 *l4_4_data; + +if (!fltr->ip_mask.proto)/* IPv4/IPv6 header only */ +return 0 ; + + hdr = &proto_hdrs->proto_hdr[proto_hdrs->count++];Here's a good example: assignment occurs separately from the declaration and doesn't cause a line wrap.
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type,
Quoted 7 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +7
-0+ l4_4_data = (__force __be32 *)hdr->buffer; + +/* L2TPv3 over IP with 'Session ID' */ +if (fltr->ip_data.proto ==IPPROTO_L2TP && + fltr->ip_mask.l4_header ==htonl (U32_MAX )) { +VIRTCHNL_SET_PROTO_HDR_TYPE (hdr,L2TPV3 ); + VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, L2TPV3,
SESS_ID);drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 3229
Quoted 5 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +5
-0+ + *l4_4_data = fltr->ip_data.l4_header; + }else { +return -EOPNOTSUPP ; + }if (!= || !=) return -EOPNOTSUPP; VIRTCHNL_SET_ ...-1 level this way.
Quoted 17 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +17
-0+ +return 0 ; +} + +/** +* iecm_fill_fdir_eth_hdr - fill the Ethernet protocol header +* @fltr: Flow Director filter data structure +* @proto_hdrs: Flow Director protocol headers data structure +* +* Returns 0 if the Ethernet protocol header is set successfully +*/ +static int +iecm_fill_fdir_eth_hdr (struct iecm_fdir_fltr *fltr, +struct virtchnl_proto_hdrs *proto_hdrs) +{ +struct virtchnl_proto_hdr *hdr = + &proto_hdrs->proto_hdr[proto_hdrs-Quoted 1 line
count++];
Here's a bad example again.
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type,
Quoted 11 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +11
-0+struct ethhdr *ehdr = (struct ethhdr *)hdr->buffer; + +VIRTCHNL_SET_PROTO_HDR_TYPE (hdr,ETH ); + +if (fltr->eth_mask.etype ==htons (U16_MAX )) { +if (fltr->eth_data.etype ==htons (ETH_P_IP ) || + fltr->eth_data.etype ==htons (ETH_P_IPV6 )) +return -EOPNOTSUPP ; + + ehdr->h_proto = fltr->eth_data.etype; + VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, ETH,ETHERTYPE);
drivers/net/ethernet/intel/iecm/iecm_lib.c
Quoted 1 line
drivers/net/ethernet/intel/iecm/iecm_lib.c +1
-0+ }This can be inverted as well.
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type,
Quoted 6 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +6
-0+ +return 0 ; +} + +/** +* iecm_fill_fdir_add_msg - fill the Flow Director filter into virtchnl message
Quoted 4 lines
+ * @vport: vport structure
+ * @fltr: Flow Director filter data structure
+ *
+ * Returns 0 if the add Flow Director virtchnl message is filledsuccessfully
drivers/net/ethernet/intel/iecm/iecm_lib.c
Quoted 3 lines
+ */
drivers/net/ethernet/intel/iecm/iecm_lib.c +2
-0+static int +iecm_fill_fdir_add_msg(struct iecm_vport *vport, struct iecm_fdir_fltr*fltr)
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 3277
Quoted 6 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +6
-0+{ +struct virtchnl_fdir_add *vc_msg = &fltr->vc_add_msg; +struct virtchnl_proto_hdrs *proto_hdrs; +int err; + + proto_hdrs = &vc_msg->rule_cfg.proto_hdrs;And here's good.
Quoted 105 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +105
-0+ + err =iecm_fill_fdir_eth_hdr (fltr, proto_hdrs);/* L2 always exists */ +if (err) +return err; + +switch (fltr->flow_type) { +case IECM_FDIR_FLOW_IPV4_TCP : + err =iecm_fill_fdir_ip4_hdr (fltr, proto_hdrs) | +iecm_fill_fdir_tcp_hdr (fltr, proto_hdrs); +break ; +case IECM_FDIR_FLOW_IPV4_UDP : + err =iecm_fill_fdir_ip4_hdr (fltr, proto_hdrs) | +iecm_fill_fdir_udp_hdr (fltr, proto_hdrs); +break ; +case IECM_FDIR_FLOW_IPV4_SCTP : + err =iecm_fill_fdir_ip4_hdr (fltr, proto_hdrs) | +iecm_fill_fdir_sctp_hdr (fltr, proto_hdrs); +break ; +case IECM_FDIR_FLOW_IPV4_AH : + err =iecm_fill_fdir_ip4_hdr (fltr, proto_hdrs) | +iecm_fill_fdir_ah_hdr (fltr, proto_hdrs); +break ; +case IECM_FDIR_FLOW_IPV4_ESP : + err =iecm_fill_fdir_ip4_hdr (fltr, proto_hdrs) | +iecm_fill_fdir_esp_hdr (fltr, proto_hdrs); +break ; +case IECM_FDIR_FLOW_IPV4_OTHER : + err =iecm_fill_fdir_ip4_hdr (fltr, proto_hdrs) | +iecm_fill_fdir_l4_hdr (fltr, proto_hdrs); +break ; +case IECM_FDIR_FLOW_IPV6_TCP : + err =iecm_fill_fdir_ip6_hdr (fltr, proto_hdrs) | +iecm_fill_fdir_tcp_hdr (fltr, proto_hdrs); +break ; +case IECM_FDIR_FLOW_IPV6_UDP : + err =iecm_fill_fdir_ip6_hdr (fltr, proto_hdrs) | +iecm_fill_fdir_udp_hdr (fltr, proto_hdrs); +break ; +case IECM_FDIR_FLOW_IPV6_SCTP : + err =iecm_fill_fdir_ip6_hdr (fltr, proto_hdrs) | +iecm_fill_fdir_sctp_hdr (fltr, proto_hdrs); +break ; +case IECM_FDIR_FLOW_IPV6_AH : + err =iecm_fill_fdir_ip6_hdr (fltr, proto_hdrs) | +iecm_fill_fdir_ah_hdr (fltr, proto_hdrs); +break ; +case IECM_FDIR_FLOW_IPV6_ESP : + err =iecm_fill_fdir_ip6_hdr (fltr, proto_hdrs) | +iecm_fill_fdir_esp_hdr (fltr, proto_hdrs); +break ; +case IECM_FDIR_FLOW_IPV6_OTHER : + err =iecm_fill_fdir_ip6_hdr (fltr, proto_hdrs) | +iecm_fill_fdir_l4_hdr (fltr, proto_hdrs); +break ; +case IECM_FDIR_FLOW_NON_IP_L2 : +break ; +default : + err = -EINVAL ; +break ; + } + +if (err) +return err; + + vc_msg->vsi_id = vport->vport_id; + vc_msg->rule_cfg.action_set.count =1 ; + vc_msg->rule_cfg.action_set.actions[0 ].type = fltr->action; + vc_msg->rule_cfg.action_set.actions[0 ].act_conf.queue.index = + fltr->q_index; + +return 0 ; +} + +/** +* iecm_fdir_flow_proto_name - get the flow protocol name +* @flow_type: Flow Director filter flow type +**/ +static const char * +iecm_fdir_flow_proto_name (enum iecm_fdir_flow_type flow_type) +{ +switch (flow_type) { +case IECM_FDIR_FLOW_IPV4_TCP : +case IECM_FDIR_FLOW_IPV6_TCP : +return "TCP" ; +case IECM_FDIR_FLOW_IPV4_UDP : +case IECM_FDIR_FLOW_IPV6_UDP : +return "UDP" ; +case IECM_FDIR_FLOW_IPV4_SCTP : +case IECM_FDIR_FLOW_IPV6_SCTP : +return "SCTP" ; +case IECM_FDIR_FLOW_IPV4_AH : +case IECM_FDIR_FLOW_IPV6_AH : +return "AH" ; +case IECM_FDIR_FLOW_IPV4_ESP : +case IECM_FDIR_FLOW_IPV6_ESP : +return "ESP" ; +case IECM_FDIR_FLOW_IPV4_OTHER : +case IECM_FDIR_FLOW_IPV6_OTHER : +return "Other" ; +case IECM_FDIR_FLOW_NON_IP_L2 : +return "Ethernet" ; +default : +return NULL ; + } +}drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type,
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+ +/** +* iecm_dump_fdir_fltr +* @vport: vport structure +* @fltr: Flow Director filter to print +* +* Print the Flow Director filter +**/ +static void +iecm_dump_fdir_fltr(struct iecm_vport *vport, struct iecm_fdir_fltr*fltr)
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type,
Quoted 12 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +12
-0+{ +const char *proto =iecm_fdir_flow_proto_name (fltr->flow_type); +struct device *dev = &vport->adapter->pdev->dev; + +if (!proto) +return ; + +switch (fltr->flow_type) { +case IECM_FDIR_FLOW_IPV4_TCP : +case IECM_FDIR_FLOW_IPV4_UDP : +case IECM_FDIR_FLOW_IPV4_SCTP : + dev_info(dev, "Rule ID: %u dst_ip: %pI4 src_ip %pI4 %s:
dst_port%husrc_port%hu\n",
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 3410
Quoted 6 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +6
-0+ fltr->loc, + &fltr->ip_data.v4_addrs.dst_ip, + &fltr->ip_data.v4_addrs.src_ip, + proto, +ntohs (fltr->ip_data.dst_port), + ntohs(fltr->ip_data.src_port));Some of those can fit into previous line, there's no need to put each argument onto separate one.
It technically can fit on one line, but it's much easier for humans to parse what's going where the way it's written now.
Quoted 65 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type,
Quoted 4 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +4
-0+break ; +case IECM_FDIR_FLOW_IPV4_AH : +case IECM_FDIR_FLOW_IPV4_ESP : + dev_info(dev, "Rule ID: %u dst_ip: %pI4 src_ip %pI4 %s: SPI%u\n",
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 3419
Quoted 5 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +5
-0+ fltr->loc, + &fltr->ip_data.v4_addrs.dst_ip, + &fltr->ip_data.v4_addrs.src_ip, + proto, + ntohl(fltr->ip_data.spi));Same here.
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type,
Quoted 3 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +3
-0+break ; +case IECM_FDIR_FLOW_IPV4_OTHER : + dev_info(dev, "Rule ID: %u dst_ip: %pI4 src_ip %pI4 proto:%u
L4_bytes: 0x%x\n",drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 3427
Quoted 5 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +5
-0+ fltr->loc, + &fltr->ip_data.v4_addrs.dst_ip, + &fltr->ip_data.v4_addrs.src_ip, + fltr->ip_data.proto, + ntohl(fltr->ip_data.l4_header));And here.
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type,
Quoted 5 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +5
-0+break ; +case IECM_FDIR_FLOW_IPV6_TCP : +case IECM_FDIR_FLOW_IPV6_UDP : +case IECM_FDIR_FLOW_IPV6_SCTP : + dev_info(dev, "Rule ID: %u dst_ip: %pI6 src_ip %pI6 %s:
dst_port%husrc_port%hu\n",Quoted 6 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +6
-0+ fltr->loc, + &fltr->ip_data.v6_addrs.dst_ip, + &fltr->ip_data.v6_addrs.src_ip, + proto, +ntohs (fltr->ip_data.dst_port), + ntohs(fltr->ip_data.src_port));...
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type,
Quoted 4 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +4
-0+break ; +case IECM_FDIR_FLOW_IPV6_AH : +case IECM_FDIR_FLOW_IPV6_ESP : + dev_info(dev, "Rule ID: %u dst_ip: %pI6 src_ip %pI6 %s: SPI%u\n",
Quoted 5 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +5
-0+ fltr->loc, + &fltr->ip_data.v6_addrs.dst_ip, + &fltr->ip_data.v6_addrs.src_ip, + proto, + ntohl(fltr->ip_data.spi));...
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type,
Quoted 3 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +3
-0+break ; +case IECM_FDIR_FLOW_IPV6_OTHER : + dev_info(dev, "Rule ID: %u dst_ip: %pI6 src_ip %pI6 proto:%u
L4_bytes: 0x%x\n",Quoted 5 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +5
-0+ fltr->loc, + &fltr->ip_data.v6_addrs.dst_ip, + &fltr->ip_data.v6_addrs.src_ip, + fltr->ip_data.proto, + ntohl(fltr->ip_data.l4_header));...
Quoted 8 lines
Quoted 5 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +5
-0+break ; +case IECM_FDIR_FLOW_NON_IP_L2 : +dev_info (dev,"Rule ID: %u eth_type: 0x%x\n" , + fltr->loc, +ntohs (fltr->eth_data.etype));...
This one probably doesn't need it will fix.
Quoted 49 lines
Quoted 49 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +49
-0+break ; +default : +break ; + } +} + +/** +* iecm_fdir_is_dup_fltr - test if filter is already in list +* @adapter: board private structure +* @fltr: Flow Director filter data structure +* +* Returns true if the filter is found in the list +*/ +static bool +iecm_fdir_is_dup_fltr (struct iecm_adapter *adapter, +struct iecm_fdir_fltr *fltr) +{ +struct iecm_fdir_fltr_config *fdir_config; +struct iecm_fdir_fltr *tmp; + + fdir_config = &adapter->config_data.fdir_config; +list_for_each_entry (tmp, &fdir_config->fdir_fltr_list, list) { +if (tmp->flow_type != fltr->flow_type) +continue ; + +if (!memcmp (&tmp->eth_data, &fltr->eth_data, +sizeof (fltr->eth_data)) && + !memcmp (&tmp->ip_data, &fltr->ip_data, +sizeof (fltr->ip_data)) && + !memcmp (&tmp->ext_data, &fltr->ext_data, +sizeof (fltr->ext_data))) +return true; + } + +return false; +} + +/** +* iecm_find_fdir_fltr_by_loc - find filter with location +* @adapter: board private structure +* @loc: location to find. +* +* Returns pointer to Flow Director filter if found or null +*/ +static struct iecm_fdir_fltr * +iecm_find_fdir_fltr_by_loc (struct iecm_adapter *adapter,u32 loc) +{ +struct iecm_fdir_fltr_config *fdir_config; +struct iecm_fdir_fltr *rule;
Quoted 9 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 3514
Quoted 5 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +5
-0+ + fdir_config = &adapter->config_data.fdir_config; +list_for_each_entry (rule, &fdir_config->fdir_fltr_list, list) +if (rule->loc == loc) +return rule;Here's a good example that a single
ifstatement shouldn't be placed into a pair of braces.
You're right it does need some braces on the list_for_each, will fix.
Quoted 66 lines
Quoted 66 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +66
-0+ +return NULL ; +} + +/** +* iecm_fdir_list_add_fltr - add a new node to the flow director filter list +* @adapter: board private structure +* @fltr: filter node to add to structure +*/ +static void +iecm_fdir_list_add_fltr (struct iecm_adapter *adapter, +struct iecm_fdir_fltr *fltr) +{ +struct iecm_fdir_fltr *rule, *parent =NULL ; +struct iecm_fdir_fltr_config *fdir_config; + + fdir_config = &adapter->config_data.fdir_config; + +spin_lock_bh (&adapter->fdir_fltr_list_lock); +list_for_each_entry (rule, &fdir_config->fdir_fltr_list, list) { +if (rule->loc >= fltr->loc) +break ; + parent = rule; + } + +if (parent) +list_add (&fltr->list, &parent->list); +else +list_add (&fltr->list, &fdir_config->fdir_fltr_list); + fltr->add = true; +spin_unlock_bh (&adapter->fdir_fltr_list_lock); +} + +/** +* iecm_fltr_to_ethtool_flow - convert filter type values to ethtool +* flow type values +* @flow: filter type to be converted +* +* Returns the corresponding ethtool flow type. +*/ +static int iecm_fltr_to_ethtool_flow (enum iecm_fdir_flow_type flow) +{ +switch (flow) { +case IECM_FDIR_FLOW_IPV4_TCP : +return TCP_V4_FLOW ; +case IECM_FDIR_FLOW_IPV4_UDP : +return UDP_V4_FLOW ; +case IECM_FDIR_FLOW_IPV4_SCTP : +return SCTP_V4_FLOW ; +case IECM_FDIR_FLOW_IPV4_AH : +return AH_V4_FLOW ; +case IECM_FDIR_FLOW_IPV4_ESP : +return ESP_V4_FLOW ; +case IECM_FDIR_FLOW_IPV4_OTHER : +return IPV4_USER_FLOW ; +case IECM_FDIR_FLOW_IPV6_TCP : +return TCP_V6_FLOW ; +case IECM_FDIR_FLOW_IPV6_UDP : +return UDP_V6_FLOW ; +case IECM_FDIR_FLOW_IPV6_SCTP : +return SCTP_V6_FLOW ; +case IECM_FDIR_FLOW_IPV6_AH : +return AH_V6_FLOW ; +case IECM_FDIR_FLOW_IPV6_ESP : +return ESP_V6_FLOW ; +case IECM_FDIR_FLOW_IPV6_OTHER :
Quoted 9 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 3586
Quoted 6 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +6
-0+return IPV6_USER_FLOW ; +case IECM_FDIR_FLOW_NON_IP_L2 : +return ETHER_FLOW ; +default : +/* 0 is undefined ethtool flow */ +return 0 ;This switch-case can be converted to an array to reduce code size.
Seems reasonable, will look.
Quoted 53 lines
Quoted 30 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +30
-0+ } +} + +/** +* iecm_ethtool_flow_to_fltr - convert ethtool flow type to filter enum +* @eth: Ethtool flow type to be converted +* +* Returns flow enum +*/ +static enum iecm_fdir_flow_type iecm_ethtool_flow_to_fltr (int eth) +{ +switch (eth) { +case TCP_V4_FLOW : +return IECM_FDIR_FLOW_IPV4_TCP ; +case UDP_V4_FLOW : +return IECM_FDIR_FLOW_IPV4_UDP ; +case SCTP_V4_FLOW : +return IECM_FDIR_FLOW_IPV4_SCTP ; +case AH_V4_FLOW : +return IECM_FDIR_FLOW_IPV4_AH ; +case ESP_V4_FLOW : +return IECM_FDIR_FLOW_IPV4_ESP ; +case IPV4_USER_FLOW : +return IECM_FDIR_FLOW_IPV4_OTHER ; +case TCP_V6_FLOW : +return IECM_FDIR_FLOW_IPV6_TCP ; +case UDP_V6_FLOW : +return IECM_FDIR_FLOW_IPV6_UDP ; +case SCTP_V6_FLOW : +return IECM_FDIR_FLOW_IPV6_SCTP ;drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 3626
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+case AH_V6_FLOW : +return IECM_FDIR_FLOW_IPV6_AH ; +case ESP_V6_FLOW : +return IECM_FDIR_FLOW_IPV6_ESP ; +case IPV6_USER_FLOW : +return IECM_FDIR_FLOW_IPV6_OTHER ; +case ETHER_FLOW : +return IECM_FDIR_FLOW_NON_IP_L2 ; +default : +return IECM_FDIR_FLOW_NONE ;Same here.
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+ } +} + +/** +* iecm_is_mask_valid - check mask field set +* @mask: full mask to check +* @field: field for which mask should be valid +* +* If the mask is fully set return true. If it is not valid for field return +* false.
Quoted 9 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 3641
Quoted 5 lines
+ */
drivers/net/ethernet/intel/iecm/iecm_lib.c +4
-0+static bool iecm_is_mask_valid (u64 mask,u64 field) +{ +return (mask & field) == field; +}That is something really basic and should at least be placed somewhere in the headers and used module-wide.
I'm not convinced it makes sense to do that if it's not actually being used module wide. I'm pretty sure this is only validating user input for flow director filters.
Quoted 23 lines
Quoted 12 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +12
-0+ +/** +* iecm_parse_rx_flow_user_data - deconstruct user-defined data +* @fsp: pointer to ethtool Rx flow specification +* @fltr: pointer to Flow Director filter for userdef data storage +* +* Returns 0 on success, negative error value on failure +*/ +static int +iecm_parse_rx_flow_user_data (struct ethtool_rx_flow_spec *fsp, +struct iecm_fdir_fltr *fltr) +{drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type,
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+struct iecm_flex_word *flex; +int i, cnt =0 ; + +if (!(fsp->flow_type &FLOW_EXT )) +return 0 ; + +for (i =0 ; i <IECM_FLEX_WORD_NUM ; i++) { +#define IECM_USERDEF_FLEX_WORD_M GENMASK(15, 0) +#define IECM_USERDEF_FLEX_OFFS_S 16 +#define IECM_USERDEF_FLEX_OFFS_M GENMASK(31,
IECM_USERDEF_FLEX_OFFS_S)
Quoted 5 lines
Quoted 1 line
+#define
IECM_USERDEF_FLEX_FLTR_MGENMASK(31, 0)1. Should be placed outside the function.
2. Candidates for FIELD_{GET,PREP}().
Sure will fix.
920 lines not shown · raw message
Part of this message is not shown here. View the raw message.
PATCH 16/19 iecm: implement flow director
From: Alan Brady <[email protected]>
Date: Thu, 3 Feb 2022 03:41:26 +0100
Quoted 22 lines
Quoted 22 lines
-----Original Message-----
From: Lobakin, Alexandr <[email protected]>
Sent: Friday, January 28, 2022 11:04 AM
To: Brady, Alan <[email protected]>
Cc: Lobakin, Alexandr <[email protected]>; Wang, Haiyue <[email protected]>; Burra, Phani R <[email protected]>; Chittim, Madhu <[email protected]>; Linga, Pavan Kumar <[email protected]>; intel-wired-lan at lists.osuosl.org
Subject: Re: [Intel-wired-lan] [PATCH net-next 16/19] iecm: implement flow directorFrom: Alan Brady <[email protected]>
Date: Thu, 27 Jan 2022 16:10:06 -0800Quoted 8 lines
From: Haiyue Wang <[email protected]>
This adds everthing needed to do flow director commands.
Signed-off-by Haiyue Wang <[email protected]>--- .../net/ethernet/intel/iecm/iecm_ethtool.c | 17 +- drivers/net/ethernet/intel/iecm/iecm_lib.c | 1528
Quoted 5 lines
Quoted 5 lines
++++++++++++++++-
Quoted 4 lines
.../net/ethernet/intel/iecm/iecm_virtchnl.c | 119 ++ drivers/net/ethernet/intel/include/iecm.h | 112 ++ 4 files changed, 1770 insertions(+), 6 deletions(-)
--- 8< ---
Quoted 17 lines
Quoted 6 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type,
Quoted 5 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +5
-0+switch (fltr->flow_type) { +case IECM_FDIR_FLOW_IPV4_TCP : +case IECM_FDIR_FLOW_IPV4_UDP : +case IECM_FDIR_FLOW_IPV4_SCTP : + dev_info(dev, "Rule ID: %u dst_ip: %pI4 src_ip %pI4 %s:
dst_port%husrc_port%hu\n",Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 3410
Quoted 6 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +6
-0+ fltr->loc, + &fltr->ip_data.v4_addrs.dst_ip, + &fltr->ip_data.v4_addrs.src_ip, + proto, +ntohs (fltr->ip_data.dst_port), + ntohs(fltr->ip_data.src_port));Some of those can fit into previous line, there's no need to put each argument onto separate one.
Quoted 1 line
It technically can fit on one line, but it's much easier for humans to parse what's going where the way it's written now.
Not sure there's a choice here, usually it's preferred to compress lines if there's a possibility.
Quoted 3 lines
Quoted 3 lines
Review
Quoted 3 lines
(quoted diff) +2
-0+ break; + case IECM_FDIR_FLOW_IPV4_AH:
--- 8< ---
Quoted 10 lines
Quoted 8 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 3514
Quoted 4 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +4
-0+ fdir_config = &adapter->config_data.fdir_config; +list_for_each_entry (rule, &fdir_config->fdir_fltr_list, list) +if (rule->loc == loc) +return rule;Here's a good example that a single
ifstatement shouldn't be placed into a pair of braces.You're right it does need some braces on the
list_for_each, will fix.
I said the opposite, please don't present your opinion as mine. I'm not sure it's a correct thing to do during the review. As mentioned previously plenty of times, braces are expected only when they're purely necessary. Your approach doesn't even improve the readability as you claim.
Quoted 7 lines
Quoted 7 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 3520
Quoted 7 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +6
-0+ +return NULL ; +} + +/** +* iecm_fdir_list_add_fltr - add a new node to the flow director filter list
--- 8< ---
Quoted 12 lines
Quoted 11 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 3641
Quoted 7 lines
+ * If the mask is fully set return true. If it is not valid for field return
+ * false.
+ */drivers/net/ethernet/intel/iecm/iecm_lib.c +4
-0+static bool iecm_is_mask_valid (u64 mask,u64 field) +{ +return (mask & field) == field; +}That is something really basic and should at least be placed somewhere in the headers and used module-wide.
Quoted 1 line
I'm not convinced it makes sense to do that if it's not actually being used module wide. I'm pretty sure this is only validating user input for flow director filters.
(mask & field) == field pattern is used widely across iecm code. This function simply won't pass the review. If it reflects FD logics somehow, this should be explained in the kdoc block, so there'll be less questions why it's here at all. For now it looks like a generic function, not FD-specific one.
Anyway, I've just highlighted all references to this function and it's used only *once* throughout the code. So it's a pure overkill and should be just open-coded there.
Quoted 4 lines
Quoted 4 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 3644
Quoted 4 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +3
-0+ +/** +* iecm_parse_rx_flow_user_data - deconstruct user-defined data
--- 8< ---
Quoted 9 lines
Quoted 7 lines
drivers/net/ethernet/intel/include/iecm.h struct iecm_channel_config { · line 415
Quoted 3 lines
drivers/net/ethernet/intel/include/iecm.h +3
-0+enum iecm_fdir_flow_type { +/* NONE - used for undef/error */ +IECM_FDIR_FLOW_NONE =0 ,Enums always start with 0 unless other value specified, this is a bit excessive.
AFAIK this is the normal thing to do in Linux kernel. In cases where the value actually matters, as is here, it's better to be explicit even though yes you're right it should be getting the default value of zero.
Does it? It mostly only matters when it's being passed to HW anyhow, but I'm not sure it's the case here.
Anyways, I admit it's rather a personal preference, so I don't mind.
Quoted 11 lines
E.g. in
kernel/sched/sched.hyou can find:/* The regions in
numa_faultsarray fromtask_struct*/enum numa_faults_stats { NUMA_MEM = 0, NUMA_CPU, NUMA_MEMBUF, NUMA_CPUBUF };
Quoted 3 lines
and probably many more.
Quoted 1 line
drivers/net/ethernet/intel/include/iecm.h struct iecm_channel_config { · line 416
Quoted 1 line
drivers/net/ethernet/intel/include/iecm.h +1
-0+ IECM_FDIR_FLOW_IPV4_TCP,
--- 8< ---
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
--
2.33.0Thanks,
Al
Thanks,
Al
PATCH 17/19 iecm: implement cloud filters
In reply to Alan BradyThis gives iecm the ability to deal with cloud filters and other traffic classes.
--- drivers/net/ethernet/intel/iecm/iecm_lib.c | 900 +++++++++++++++++- .../net/ethernet/intel/iecm/iecm_virtchnl.c | 68 ++ drivers/net/ethernet/intel/include/iecm.h | 25 + 3 files changed, 992 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/iecm/iecm_lib.c +899 -1
@@ -43,9 +43,16 @@ static int iecm_get_vport_index(struct iecm_adapter *adapter,*/ bool iecm_is_feature_ena (struct iecm_vport *vport,netdev_features_t feature) { +struct iecm_channel_config *ch_config;bool ena;switch (feature) { +case NETIF_F_HW_TC : + ch_config = &vport->adapter->config_data.ch_config; + ena = (vport->netdev->features & feature) && + (ch_config->num_tc >IECM_START_CHNL_TC ) && + (ch_config->tc_running); +break ;default : ena = vport->netdev->features & feature;break ;
@@ -53,6 +60,23 @@ bool iecm_is_feature_ena(struct iecm_vport *vport, netdev_features_t feature)return ena; } +/** +* iecm_is_adq_v2_ena - Determine whether ADQ V2 is enabled +* @vport: virtual port struct +* +* This function returns true based on negotiated capability ADQ_V2 +* if set and ADQ enabled +*/ +static bool iecm_is_adq_v2_ena (struct iecm_vport *vport) +{ +/* iecm_is_feature_ena tells if the netdev flag is set and adq is +* enabled +*/ +return (iecm_is_feature_ena (vport,NETIF_F_HW_TC ) && +iecm_is_cap_ena (vport->adapter,IECM_OTHER_CAPS , +VIRTCHNL2_CAP_ADQ )); +} +/** * iecm_is_vlan_cap_ena - Check if VLAN capability is enabled * @adapter: pointer to adapter
@@ -946,6 +970,28 @@ static int iecm_get_free_slot(void *array, int size, int curr)return next; } +/** +* iecm_remove_cloud_filters - Remove all cloud filters +* @vport: vport structure +*/ +static void iecm_remove_cloud_filters (struct iecm_vport *vport) +{ +struct iecm_adapter *adapter = vport->adapter; +struct iecm_cloud_filter_config *cf_config; + + cf_config = &adapter->config_data.cf_config; +if (!list_empty (&cf_config->cloud_filter_list)) { +struct iecm_cloud_filter *cf; + +spin_lock_bh (&adapter->cloud_filter_list_lock); +list_for_each_entry (cf, &cf_config->cloud_filter_list, list) { + cf->remove = true; + } +spin_unlock_bh (&adapter->cloud_filter_list_lock); +iecm_send_add_del_cloud_filter_msg (vport, false); + } +} +/** * iecm_remove_vlan_filters - Remove all vlan filters * @vport: vport structure
@@ -1044,8 +1090,14 @@ static void iecm_vport_stop(struct iecm_vport *vport)if (test_and_clear_bit (__IECM_DEL_QUEUES, vport->adapter->flags))iecm_send_delete_queues_msg (vport); -if (!test_bit (__IECM_REL_RES_IN_PROG, adapter->flags)) +/* In function reset/rmmod path we call unregister_netdev which +* internally calls delete cloud filters. We remove cloud filters only +* when the interface goes down +*/ +if (!test_bit (__IECM_REL_RES_IN_PROG, adapter->flags)) { +iecm_remove_cloud_filters (vport);iecm_remove_vlan_filters (vport); + }iecm_remove_fdir_filters (vport);
@@ -1258,6 +1310,28 @@ static void iecm_restore_vlans(struct iecm_vport *vport)iecm_set_all_vlans (vport); } +/** +* iecm_restore_cloud_filters - Restore cloud filters +* @vport: vport structure +*/ +static void iecm_restore_cloud_filters (struct iecm_vport *vport) +{ +struct iecm_adapter *adapter = vport->adapter; +struct iecm_cloud_filter_config *cf_config; + + cf_config = &adapter->config_data.cf_config; +if (!list_empty (&cf_config->cloud_filter_list)) { +struct iecm_cloud_filter *cf; + +spin_lock_bh (&adapter->cloud_filter_list_lock); +list_for_each_entry (cf, &cf_config->cloud_filter_list, list) { + cf->add = true; + } +spin_unlock_bh (&adapter->cloud_filter_list_lock); +iecm_send_add_del_cloud_filter_msg (vport, true); + } +} +/** * iecm_restore_fdir_filters - Restore all Flow Director filters * @vport: vport structure
@@ -1302,6 +1376,10 @@ static void iecm_restore_features(struct iecm_vport *vport)dev_info (&adapter->pdev->dev,"Failed to restore promiscuous settings\n" ); } +/* Restore cloud filters if ADQ is enabled */ +if (iecm_is_feature_ena (vport,NETIF_F_HW_TC )) +iecm_restore_cloud_filters (vport); +if (iecm_is_cap_ena (adapter,IECM_OTHER_CAPS ,VIRTCHNL2_CAP_FDIR ))iecm_restore_fdir_filters (vport); }
@@ -2088,6 +2166,8 @@ int iecm_probe(struct pci_dev *pdev,spin_lock_init (&adapter->vlan_list_lock);spin_lock_init (&adapter->adv_rss_list_lock);spin_lock_init (&adapter->fdir_fltr_list_lock); +INIT_LIST_HEAD (&adapter->config_data.cf_config.cloud_filter_list); +INIT_LIST_HEAD (&adapter->config_data.cf_config.block_cb_list);INIT_LIST_HEAD (&adapter->config_data.mac_filter_list);INIT_LIST_HEAD (&adapter->config_data.vlan_filter_list);INIT_LIST_HEAD (&adapter->config_data.adv_rss_list);
@@ -2389,6 +2469,810 @@ static int iecm_offload_txtime(struct iecm_vport *vport,return -EOPNOTSUPP ; } +/** +* iecm_is_vlan_tc_filter_allowed - allowed to add tc-filter using VLAN +* @vport: vport structure +* @vlan: VLAN to verify +* +* Using specified "vlan" ID, there must be active VLAN filter in VF's +* MAC-VLAN filter list. +*/ +static bool +iecm_is_vlan_tc_filter_allowed (struct iecm_vport *vport, +struct iecm_vlan *vlan) +{ +struct iecm_vlan_filter *f; +bool allowed; + +spin_lock_bh (&vport->adapter->vlan_list_lock); + f =iecm_find_vlan (vport, vlan); + allowed = (f && !f->add && !f->remove); +spin_unlock_bh (&vport->adapter->vlan_list_lock); +return allowed; +} + +/** +* iecm_is_mac_tc_filter_allowed - allowed to add tc-filter using MAC addr +* @vport: vport structure +* @macaddr: MAC address +* +* Using specified MAC address, there must be active MAC filter in +* MAC filter list. +*/ +static bool +iecm_is_mac_tc_filter_allowed (struct iecm_vport *vport,const u8 *macaddr) +{ +struct iecm_adapter *adapter = vport->adapter; +struct iecm_mac_filter *f; +bool allowed; + +spin_lock_bh (&adapter->mac_filter_list_lock); + f =iecm_find_mac_filter (vport, macaddr); + allowed = (f && !f->add && !f->remove); +spin_unlock_bh (&adapter->mac_filter_list_lock); +return allowed; +} + +/** +* iecm_parse_keyid - Parse keyid +* @rule: Flow rule structure +* @field_flags: Cloud filter flags +*/ +static void iecm_parse_keyid (struct flow_rule *rule,u8 *field_flags) +{ +struct flow_match_enc_keyid match; + +flow_rule_match_enc_keyid (rule, &match); + +if (match.mask->keyid !=0 ) + *field_flags |=IECM_CLOUD_FIELD_TEN_ID ; +} + +/** +* iecm_parse_flow_type - Parse flow type based on L2 and L3 protocols +* @vport: vport structure +* @rule: rule from user +* @cf: Structure for the virtchnl filter +* @filter: Structure for the cloud filter +* +* Return 0 on success, negative on failure +*/ +static int +iecm_parse_flow_type (struct iecm_vport *vport, +struct flow_rule *rule,struct virtchnl_filter *cf, +struct iecm_cloud_filter *filter) +{ +struct iecm_adapter *adapter = vport->adapter; +enum virtchnl_flow_type flow_type; +struct flow_match_basic match; +u16 n_proto_mask =0 ; +u16 n_proto_key =0 ; +u16 n_proto =0 ; +u8 ip_proto =0 ; + +flow_rule_match_basic (rule, &match); + + n_proto_key =ntohs (match.key->n_proto); + n_proto_mask =ntohs (match.mask->n_proto); + +if (n_proto_key ==ETH_P_ALL ) { + n_proto_key =0 ; + n_proto_mask =0 ; + } + n_proto = n_proto_key & n_proto_mask; +if (n_proto !=ETH_P_IP && n_proto !=ETH_P_IPV6 ) +return -EINVAL ; + +if (iecm_is_cap_ena (adapter,IECM_OTHER_CAPS ,VIRTCHNL2_CAP_ADQ )) { +if (match.key->ip_proto !=IPPROTO_TCP && + match.key->ip_proto !=IPPROTO_UDP ) { +dev_err (&adapter->pdev->dev, +"Only TCP or UDP transport is supported\n" ); +return -EINVAL ; + } + }else if (match.key->ip_proto !=IPPROTO_TCP ) { +dev_err (&adapter->pdev->dev, +"Only TCP transport is supported\n" ); +return -EINVAL ; + } + ip_proto = match.key->ip_proto; + +/* determine VIRTCHNL flow_type based on L3 and L4 protocol */ +if (n_proto ==ETH_P_IP ) + flow_type = (ip_proto ==IPPROTO_TCP ) ? +VIRTCHNL_TCP_V4_FLOW : +VIRTCHNL_UDP_V4_FLOW ; +else + flow_type = (ip_proto ==IPPROTO_TCP ) ? +VIRTCHNL_TCP_V6_FLOW : +VIRTCHNL_UDP_V6_FLOW ; + cf->flow_type = flow_type; + filter->f.flow_type = flow_type; + +return 0 ; +} + +/** +* iecm_parse_ether_header - Parse ethernet header fields +* @vport: vport structure +* @field_flags: Cloud filter flags +* @d_spec: Virtchnl structure for L4 specs +* @m_spec: Virtchnl structure for L4 specs +* @rule: Flow rule structure +* +* Return 0 on success, negative on failure +*/ +static int +iecm_parse_ether_header (struct iecm_vport *vport,u8 *field_flags, +struct virtchnl_l4_spec *d_spec, +struct virtchnl_l4_spec *m_spec, +struct flow_rule *rule) +{ +struct iecm_adapter *adapter = vport->adapter; +struct flow_match_eth_addrs match; +bool adv_adq_ena; + + adv_adq_ena =iecm_is_cap_ena (adapter,IECM_OTHER_CAPS , +VIRTCHNL2_CAP_ADQ ); + +flow_rule_match_eth_addrs (rule, &match); + +/* use is_broadcast and is_zero to check for all 0xf or 0 */ +if (!is_zero_ether_addr (match.mask->dst)) { +if (adv_adq_ena ||is_broadcast_ether_addr (match.mask->dst)) { + *field_flags |=IECM_CLOUD_FIELD_OMAC ; + }else { +dev_err (&adapter->pdev->dev,"Bad ether dest mask %pM\n" , + match.mask->dst); +return -EINVAL ; + } + } + +if (!is_zero_ether_addr (match.mask->src)) { +if (adv_adq_ena ||is_broadcast_ether_addr (match.mask->src)) { + *field_flags |=IECM_CLOUD_FIELD_IMAC ; + }else { +dev_err (&adapter->pdev->dev,"Bad ether src mask %pM\n" , + match.mask->src); +return -EINVAL ; + } + } + +if (!is_zero_ether_addr (match.key->dst)) { +if (!iecm_is_mac_tc_filter_allowed (adapter->vports[0 ], + match.key->dst)) { +dev_err (&adapter->pdev->dev, +"Dest MAC %pM doesn't belong to this device\n" , + match.key->dst); +return -EINVAL ; + } + +if (is_valid_ether_addr (match.key->dst) || +is_multicast_ether_addr (match.key->dst)) { +/* set the mask if a valid dst_mac address */ +if (adv_adq_ena) +ether_addr_copy (m_spec->dst_mac, + match.mask->dst); +else +eth_broadcast_addr (m_spec->dst_mac); +ether_addr_copy (d_spec->dst_mac, + match.key->dst); + } + } + +if (!is_zero_ether_addr (match.key->src)) +if (is_valid_ether_addr (match.key->src) || +is_multicast_ether_addr (match.key->src)) { +/* set the mask if a valid src_mac address */ +if (adv_adq_ena) { +ether_addr_copy (m_spec->src_mac, + match.mask->src); + }else { +eth_broadcast_addr (m_spec->src_mac); + } +ether_addr_copy (d_spec->src_mac, + match.key->src); + } +return 0 ; +} + +/** +* iecm_parse_vlan_header - Parse vlan header fields +* @vport: vport structure +* @field_flags: Cloud filter flags +* @d_spec: Virtchnl structure for L4 specs +* @m_spec: Virtchnl structure for L4 specs +* @rule: Flow rule structure +* +* Return 0 on success, negative on failure +*/ +static int +iecm_parse_vlan_header (struct iecm_vport *vport,u8 *field_flags, +struct virtchnl_l4_spec *d_spec, +struct virtchnl_l4_spec *m_spec, +struct flow_rule *rule) +{ +struct iecm_adapter *adapter = vport->adapter; +struct flow_match_vlan match; + +flow_rule_match_vlan (rule, &match); +if (match.mask->vlan_id) { +u16 vid = match.key->vlan_id &VLAN_VID_MASK ; +struct iecm_vlan vlan; + + vlan =IECM_VLAN (vid,ETH_P_8021Q ); + +if (match.mask->vlan_id !=VLAN_VID_MASK ) { +dev_err (&adapter->pdev->dev,"Bad vlan mask %u\n" , + match.mask->vlan_id); +return -EINVAL ; + } +if (!iecm_is_vlan_tc_filter_allowed (vport, &vlan)) { +dev_err (&adapter->pdev->dev, +"VLAN %u doesn't belong to this VF\n" , + vid); +return -EINVAL ; + } + *field_flags |=IECM_CLOUD_FIELD_IVLAN ; + m_spec->vlan_id =cpu_to_be16 (match.mask->vlan_id); + d_spec->vlan_id =cpu_to_be16 (match.key->vlan_id); + } +return 0 ; +} + +/** +* iecm_parse_ipv4_header - Parse ipv4 header fields +* @vport: vport structure +* @field_flags: Cloud filter flags +* @d_spec: Virtchnl structure for L4 specs +* @m_spec: Virtchnl structure for L4 specs +* @rule: Flow rule structure +* +* Return 0 on success, negative on failure +*/ +static int +iecm_parse_ipv4_header (struct iecm_vport *vport,u8 *field_flags, +struct virtchnl_l4_spec *d_spec, +struct virtchnl_l4_spec *m_spec, +struct flow_rule *rule) +{ +struct iecm_adapter *adapter = vport->adapter; +struct flow_match_ipv4_addrs match; +bool adv_adq_ena; + + adv_adq_ena =iecm_is_cap_ena (adapter,IECM_OTHER_CAPS , +VIRTCHNL2_CAP_ADQ ); + +flow_rule_match_ipv4_addrs (rule, &match); + +if (*field_flags &IECM_CLOUD_FIELD_TEN_ID ) { +dev_info (&adapter->pdev->dev, +"Tenant id not allowed for ip filter\n" ); +return -EINVAL ; + } + +if (match.mask->dst) { +if (adv_adq_ena || match.mask->dst ==cpu_to_be32 (0xffffffff )) { + *field_flags |=IECM_CLOUD_FIELD_IIP ; + }else { +dev_err (&adapter->pdev->dev,"Bad ip dst mask 0x%08x\n" , +be32_to_cpu (match.mask->dst)); +return -EINVAL ; + } + } + +if (match.mask->src) { +if (adv_adq_ena || match.mask->src ==cpu_to_be32 (0xffffffff )) { + *field_flags |=IECM_CLOUD_FIELD_IIP ; + }else { +dev_err (&adapter->pdev->dev,"Bad ip src mask 0x%08x\n" , +be32_to_cpu (match.mask->dst)); +return -EINVAL ; + } + } + +if (match.key->dst) { +if (adv_adq_ena) + m_spec->dst_ip[0 ] = match.mask->dst; +else + m_spec->dst_ip[0 ] =cpu_to_be32 (0xffffffff ); + d_spec->dst_ip[0 ] = match.key->dst; + } + +if (match.key->src) { +if (adv_adq_ena) + m_spec->src_ip[0 ] = match.mask->src; +else + m_spec->src_ip[0 ] =cpu_to_be32 (0xffffffff ); + d_spec->src_ip[0 ] = match.key->src; + } +return 0 ; +} + +/** +* iecm_parse_ipv6_header - Parse ipv6 header fields +* @vport: vport structure +* @field_flags: Cloud filter flags +* @d_spec: Virtchnl structure for L4 specs +* @m_spec: Virtchnl structure for L4 specs +* @rule: Flow rule structure +* +* Return 0 on success, negative on failure +*/ +static int +iecm_parse_ipv6_header (struct iecm_vport *vport,u8 *field_flags, +struct virtchnl_l4_spec *d_spec, +struct virtchnl_l4_spec *m_spec, +struct flow_rule *rule) +{ +struct iecm_adapter *adapter = vport->adapter; +struct flow_match_ipv6_addrs match; +int i; + +flow_rule_match_ipv6_addrs (rule, &match); + +/* validate mask, make sure it is not IPV6_ADDR_ANY */ +if (ipv6_addr_any (&match.mask->dst)) { +dev_err (&adapter->pdev->dev,"Bad ipv6 dst mask 0x%02x\n" , +IPV6_ADDR_ANY ); +return -EINVAL ; + } + +/* src and dest IPv6 address should not be LOOPBACK +* (0:0:0:0:0:0:0:1) which can be represented as ::1 +*/ +if (ipv6_addr_loopback (&match.key->dst) || +ipv6_addr_loopback (&match.key->src)) { +dev_err (&adapter->pdev->dev, +"ipv6 addr should not be loopback\n" ); +return -EINVAL ; + } + +if (!ipv6_addr_any (&match.mask->dst) || + !ipv6_addr_any (&match.mask->src)) + *field_flags |=IECM_CLOUD_FIELD_IIP ; + +/* copy dest IPv6 mask and address */ +if (iecm_is_cap_ena (adapter,IECM_OTHER_CAPS ,VIRTCHNL2_CAP_ADQ )) { +memcpy (&m_spec->dst_ip, &match.mask->dst.s6_addr32, +sizeof (m_spec->dst_ip)); + }else { +for (i =0 ; i <4 ; i++) + m_spec->dst_ip[i] =cpu_to_be32 (0xffffffff ); + } +memcpy (&d_spec->dst_ip, &match.key->dst.s6_addr32, +sizeof (d_spec->dst_ip)); + +/* copy source IPv6 mask and address */ +if (iecm_is_cap_ena (adapter,IECM_OTHER_CAPS ,VIRTCHNL2_CAP_ADQ )) { +memcpy (&m_spec->src_ip, &match.mask->src.s6_addr32, +sizeof (m_spec->src_ip)); + }else { +for (i =0 ; i <4 ; i++) + m_spec->src_ip[i] =cpu_to_be32 (0xffffffff ); + } +memcpy (&d_spec->src_ip, &match.key->src.s6_addr32, +sizeof (d_spec->src_ip)); + +return 0 ; +} + +/** +* iecm_parse_l4_header - Parse l4 header fields +* @vport: vport structure +* @d_spec: Virtchnl structure for L4 specs +* @m_spec: Virtchnl structure for L4 specs +* @rule: Flow rule structure +* +* Return 0 on success, negative on failure +*/ +static int +iecm_parse_l4_header (struct iecm_vport *vport, +struct virtchnl_l4_spec *d_spec, +struct virtchnl_l4_spec *m_spec, +struct flow_rule *rule) +{ +struct iecm_adapter *adapter = vport->adapter; +struct flow_match_ports match; + +flow_rule_match_ports (rule, &match); + +if (match.key->dst) { +if (iecm_is_cap_ena (adapter,IECM_OTHER_CAPS , +VIRTCHNL2_CAP_ADQ ) || + match.mask->dst ==cpu_to_be16 (0xffff )) { + m_spec->dst_port = match.mask->dst; + d_spec->dst_port = match.key->dst; + }else { +dev_err (&adapter->pdev->dev,"Bad dst port mask %u\n" , +be16_to_cpu (match.mask->dst)); +return -EINVAL ; + } + } + +if (match.key->src) { +if (iecm_is_cap_ena (adapter,IECM_OTHER_CAPS , +VIRTCHNL2_CAP_ADQ ) || + match.mask->src ==cpu_to_be16 (0xffff )) { + m_spec->src_port = match.mask->src; + d_spec->src_port = match.key->src; + }else { +dev_err (&adapter->pdev->dev,"Bad src port mask %u\n" , +be16_to_cpu (match.mask->src)); +return -EINVAL ; + } + } +return 0 ; +} + +/** +* iecm_parse_cls_flower - Parse tc flower filters provided by kernel +* @vport: vport structure +* @f: pointer to struct flow_cls_offload +* @filter: pointer to cloud filter structure +*/ +static int iecm_parse_cls_flower (struct iecm_vport *vport, +struct flow_cls_offload *f, +struct iecm_cloud_filter *filter) +{ +struct flow_rule *rule =flow_cls_offload_flow_rule (f); +struct iecm_adapter *adapter = vport->adapter; +struct virtchnl_l4_spec *d_spec, *m_spec; +struct virtchnl_filter *cf = &filter->f; +struct flow_dissector *dissector; +u8 field_flags =0 ; +u16 addr_type =0 ; +int err; + + dissector = rule->match.dissector; +if (dissector->used_keys & + ~(BIT (FLOW_DISSECTOR_KEY_CONTROL ) | +BIT (FLOW_DISSECTOR_KEY_BASIC ) | +BIT (FLOW_DISSECTOR_KEY_ETH_ADDRS ) | +BIT (FLOW_DISSECTOR_KEY_VLAN ) | +BIT (FLOW_DISSECTOR_KEY_IPV4_ADDRS ) | +BIT (FLOW_DISSECTOR_KEY_IPV6_ADDRS ) | +BIT (FLOW_DISSECTOR_KEY_ENC_KEYID ) | +BIT (FLOW_DISSECTOR_KEY_PORTS ))) { +dev_err (&adapter->pdev->dev,"Unsupported key used: 0x%x\n" , + dissector->used_keys); +return -EOPNOTSUPP ; + } +if (flow_rule_match_key (rule,FLOW_DISSECTOR_KEY_ENC_KEYID )) +iecm_parse_keyid (rule, &field_flags); + +/* even though following code refers as "tcp_sec", it is not +* just for TCP but a generic struct representing +* L2, L3 + L4 fields if specified +*/ + m_spec = &cf->mask.tcp_spec; + d_spec = &cf->data.tcp_spec; + +/* determine flow type, TCP/UDP_V4[6]_FLOW based on +* L2 proto (aka ETH proto) and L3 proto (aka IP_PROTO) +*/ +if (flow_rule_match_key (rule,FLOW_DISSECTOR_KEY_BASIC )) { + err =iecm_parse_flow_type (vport, rule, cf, filter); +if (err) +return err; + } + +/* process Ethernet header fields */ +if (flow_rule_match_key (rule,FLOW_DISSECTOR_KEY_ETH_ADDRS )) { + err =iecm_parse_ether_header (vport, &field_flags, + d_spec, m_spec, rule); +if (err) +return err; + } + +/* process VLAN header for single VLAN (type could be S/C-tag) */ +if (flow_rule_match_key (rule,FLOW_DISSECTOR_KEY_VLAN )) { + err =iecm_parse_vlan_header (vport, &field_flags, + d_spec, m_spec, rule); +if (err) +return err; + } + +if (flow_rule_match_key (rule,FLOW_DISSECTOR_KEY_CONTROL )) { +struct flow_match_control match; + +flow_rule_match_control (rule, &match); + addr_type = match.key->addr_type; + } + +/* process IPv4 header */ +if (addr_type ==FLOW_DISSECTOR_KEY_IPV4_ADDRS ) { + err =iecm_parse_ipv4_header (vport, &field_flags, + d_spec, m_spec, rule); +if (err) +return err; + } + +/* process IPv6 header */ +if (addr_type ==FLOW_DISSECTOR_KEY_IPV6_ADDRS ) { + err =iecm_parse_ipv6_header (vport, &field_flags, + d_spec, m_spec, rule); +if (err) +return err; + } + +/* process L4 header, supported L4 protocols are TCP and UDP */ +if (flow_rule_match_key (rule,FLOW_DISSECTOR_KEY_PORTS )) { + err =iecm_parse_l4_header (vport, d_spec, m_spec, rule); +if (err) +return err; + } + cf->field_flags = field_flags; + +return 0 ; +} + +/** +* iecm_handle_tclass - Forward to a traffic class on the device +* @vport: vport structure +* @tc: traffic class index on the device +* @filter: pointer to cloud filter structure +* +* Return 0 on success, negative on failure +*/ +static int iecm_handle_tclass (struct iecm_vport *vport,int tc, +struct iecm_cloud_filter *filter) +{ +struct iecm_adapter *adapter = vport->adapter; + +if (tc ==0 ) +return 0 ; +if ((!iecm_is_adq_v2_ena (vport)) && + !filter->f.data.tcp_spec.dst_port) { +dev_err (&adapter->pdev->dev, +"Specify destination port to redirect to traffic class other than TC0\n" ); +return -EINVAL ; + } +/* redirect to a traffic class on the same device */ + filter->f.action =VIRTCHNL_ACTION_TC_REDIRECT ; + filter->f.action_meta = tc; +return 0 ; +} + +/* iecm_find_cf - Find the cloud filter in the list +* @vport: vport structure +* @cookie: filter specific cookie +* +* Returns pointer to the filter object or NULL. Must be called while holding +* cloud_filter_list_lock. +*/ +static struct iecm_cloud_filter *iecm_find_cf (struct iecm_vport *vport, +unsigned long *cookie) +{ +struct iecm_adapter *adapter = vport->adapter; +struct iecm_cloud_filter *filter =NULL ; + +if (!cookie) +return NULL ; + +list_for_each_entry (filter, + &adapter->config_data.cf_config.cloud_filter_list, + list) { +if (!memcmp (cookie, &filter->cookie,sizeof (filter->cookie))) +return filter; + } +return NULL ; +} + +/** +* iecm_configure_clsflower - Add tc flower filters +* @vport: vport structure +* @cls_flower: Pointer to struct flow_cls_offload +* +* Return 0 on success, negative on failure +*/ +static int iecm_configure_clsflower (struct iecm_vport *vport, +struct flow_cls_offload *cls_flower) +{ +struct iecm_adapter *adapter = vport->adapter; +struct iecm_user_config_data *config_data; +struct iecm_cloud_filter *filter =NULL ; +int err; +int tc; + + config_data = &adapter->config_data; + tc =tc_classid_to_hwtc (vport->netdev, cls_flower->classid); +if (tc <0 ) { +dev_err (&adapter->pdev->dev,"Invalid traffic class\n" ); +return -EINVAL ; + } + +#define IECM_MAX_CLOUD_ADQ_FILTERS 128 + +if (config_data->cf_config.num_cloud_filters >= +IECM_MAX_CLOUD_ADQ_FILTERS ) { +dev_err (&adapter->pdev->dev, +"Unable to add filter (action is forward to TC), reached max allowed filters (%u)\n" , +IECM_MAX_CLOUD_ADQ_FILTERS ); +return -ENOSPC ; + } + +/* bail out here if filter already exists */ +spin_lock_bh (&adapter->cloud_filter_list_lock); + filter =iecm_find_cf (vport, &cls_flower->cookie); +if (filter) { + filter->remove = false; +dev_err (&adapter->pdev->dev,"Failed to add TC Flower filter, it already exists\n" ); +spin_unlock_bh (&adapter->cloud_filter_list_lock); +return -EEXIST ; + } +spin_unlock_bh (&adapter->cloud_filter_list_lock); + + filter =kzalloc (sizeof (*filter),GFP_KERNEL ); +if (!filter) +return -ENOMEM ; + + filter->cookie = cls_flower->cookie; + +/* set the mask to all zeroes to begin with */ +memset (&filter->f.mask.tcp_spec,0 ,sizeof (struct virtchnl_l4_spec )); + +/* start out with flow type and eth type IPv4 to begin with */ + filter->f.flow_type =VIRTCHNL_TCP_V4_FLOW ; + err =iecm_parse_cls_flower (vport, cls_flower, filter); +if (err) + goto error; + + err =iecm_handle_tclass (vport, tc, filter); +if (err) + goto error; + +/* add filter to the list */ +spin_lock_bh (&adapter->cloud_filter_list_lock); +list_add_tail (&filter->list, &config_data->cf_config.cloud_filter_list); + filter->add = true; +spin_unlock_bh (&adapter->cloud_filter_list_lock); + err =iecm_send_add_del_cloud_filter_msg (vport, true); +spin_lock_bh (&adapter->cloud_filter_list_lock); +/* We have to find it again in case another thread has already +* deleted and kfreed it. +*/ + filter =iecm_find_cf (vport, &cls_flower->cookie); +if (filter && err) { +list_del (&filter->list); +spin_unlock_bh (&adapter->cloud_filter_list_lock); + goto error; + } +spin_unlock_bh (&adapter->cloud_filter_list_lock); + + config_data->cf_config.num_cloud_filters++; +error: +if (err) +kfree (filter); +return err; +} + +/** +* iecm_delete_clsflower - Remove tc flower filters +* @vport: vport structure +* @cls_flower: Pointer to struct flow_cls_offload +* +* Return 0 on success, negative on failure +*/ +static int iecm_delete_clsflower (struct iecm_vport *vport, +struct flow_cls_offload *cls_flower) +{ +struct iecm_adapter *adapter = vport->adapter; +struct iecm_cloud_filter *filter =NULL ; +int err =0 ; + +spin_lock_bh (&adapter->cloud_filter_list_lock); + filter =iecm_find_cf (vport, &cls_flower->cookie); +if (filter) { + filter->remove = true; + adapter->config_data.cf_config.num_cloud_filters--; + }else if (adapter->config_data.cf_config.num_cloud_filters) { +/* "num_cloud_filters" can become zero if egress qdisc is +* detached as per design, driver deletes related filters +* when qdisc is detached to avoid stale filters, hence +* num_cloud_filters can become zero. But since netdev +* layer doesn't know that filters are deleted by driver +* implictly when egress qdisc is deleted, it sees filters +* being present and "in_hw". User can request delete +* of specific filter of detach ingress qdisc - in either of +* those operation, filter(s) won't be found in driver cache, +* hence instead of returning, let this function return SUCCESS +* Returning of err as -EINVAL is only applicable when +* unable to find filter and num_cloud_filters is non-zero +*/ + err = -EINVAL ; + } +spin_unlock_bh (&adapter->cloud_filter_list_lock); + +if (filter) { + err =iecm_send_add_del_cloud_filter_msg (vport, false); +spin_lock_bh (&adapter->cloud_filter_list_lock); +/* It can happen that asynchronously the filter was already +* deleted from the list. Make sure it's still there and marked +* for remove under spinlock before actually trying to delete +* from list. +*/ + filter =iecm_find_cf (vport, &cls_flower->cookie); +if (filter) { +list_del (&filter->list); +kfree (filter); + } +spin_unlock_bh (&adapter->cloud_filter_list_lock); + } +return err; +} + +/** +* iecm_setup_tc_cls_flower - flower classifier offloads +* @vport: vport structure +* @cls_flower: pointer to struct flow_cls_offload +* +* Return 0 on success, negative on failure +*/ +static int iecm_setup_tc_cls_flower (struct iecm_vport *vport, +struct flow_cls_offload *cls_flower) +{ +if (cls_flower->common.chain_index) +return -EOPNOTSUPP ; + +switch (cls_flower->command) { +case FLOW_CLS_REPLACE : +return iecm_configure_clsflower (vport, cls_flower); +case FLOW_CLS_DESTROY : +return iecm_delete_clsflower (vport, cls_flower); +case FLOW_CLS_STATS : +return -EOPNOTSUPP ; +default : +return -EINVAL ; + } +} + +/** +* iecm_setup_tc_block_cb - block callback for tc +* @type: type of offload +* @type_data: offload data +* @cb_priv: Private adapter structure +* +* This function is the block callback for traffic classes +* Return 0 on success, negative on failure +**/ +static int iecm_setup_tc_block_cb (enum tc_setup_type type,void *type_data, +void *cb_priv) +{ +switch (type) { +case TC_SETUP_CLSFLOWER : +return iecm_setup_tc_cls_flower ((struct iecm_vport *)cb_priv, + (struct flow_cls_offload *) + type_data); +default : +return -EOPNOTSUPP ; + } +} + +/** +* iecm_del_all_cloud_filters - delete all cloud filters on the traffic classes +* @vport: vport structure +* +* This function will loop through the list of cloud filters and deletes them. +**/ +static void iecm_del_all_cloud_filters (struct iecm_vport *vport) +{ +struct iecm_adapter *adapter = vport->adapter; +struct iecm_cloud_filter_config *cf_config; +struct iecm_cloud_filter *cf, *cftmp; + + cf_config = &adapter->config_data.cf_config; +spin_lock_bh (&adapter->cloud_filter_list_lock); +list_for_each_entry_safe (cf, cftmp, + &cf_config->cloud_filter_list, + list) { +list_del (&cf->list); +kfree (cf); + cf_config->num_cloud_filters--; + } +spin_unlock_bh (&adapter->cloud_filter_list_lock); +} +/** * iecm_validate_tx_bandwidth - validate the max Tx bandwidth * @vport: vport structure
@@ -2596,6 +3480,7 @@ static int __iecm_setup_tc(struct iecm_vport *vport, void *type_data)netif_tx_stop_all_queues (netdev);netif_tx_disable (netdev); ret =iecm_send_disable_channels_msg (vport); +iecm_del_all_cloud_filters (vport);netif_tx_start_all_queues (netdev);if (!test_bit (__IECM_REL_RES_IN_PROG, adapter->flags) && !ret) {
@@ -2709,8 +3594,10 @@ static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, {struct iecm_vport *vport =iecm_netdev_to_vport (netdev);struct iecm_adapter *adapter = vport->adapter; +struct iecm_cloud_filter_config *cf_config;int err =0 ; + cf_config = &adapter->config_data.cf_config;switch (type) {case TC_SETUP_QDISC_ETF :if (iecm_is_queue_model_split (vport->txq_model))
@@ -2720,6 +3607,17 @@ static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, type_data);break ;case TC_SETUP_BLOCK : +if (iecm_is_cap_ena (adapter,IECM_BASE_CAPS , +VIRTCHNL2_CAP_ADQ ) || +iecm_is_cap_ena (adapter,IECM_OTHER_CAPS , +VIRTCHNL2_CAP_ADQ )) { + err = +flow_block_cb_setup_simple ((struct flow_block_offload *) + type_data, + &cf_config->block_cb_list, + iecm_setup_tc_block_cb, + vport, vport, true); + }break ;case TC_SETUP_QDISC_MQPRIO : if (iecm_is_cap_ena(adapter, IECM_BASE_CAPS,
drivers/net/ethernet/intel/iecm/iecm_virtchnl.c +68 -0
74 lines not on this page · raw message
drivers/net/ethernet/intel/include/iecm.h +25 -0
@@ -403,6 +403,28 @@ enum iecm_user_flags { __IECM_USER_FLAGS_NBITS, }; +#define IECM_CLOUD_FIELD_OMAC BIT(0) +#define IECM_CLOUD_FIELD_IMAC BIT(1) +#define IECM_CLOUD_FIELD_IVLAN BIT(2) +#define IECM_CLOUD_FIELD_TEN_ID BIT(3) +#define IECM_CLOUD_FIELD_IIP BIT(4) + +#define IECM_START_CHNL_TC 1 + +struct iecm_cloud_filter { +struct list_head list; +struct virtchnl_filter f; +unsigned long cookie; +bool remove;/* filter needs to be deleted */ +bool add;/* filter needs to be added */ +}; + +struct iecm_cloud_filter_config { +struct list_head block_cb_list;/* need to pass this to stack */ +struct list_head cloud_filter_list; +u16 num_cloud_filters; +}; +struct iecm_channel_config {struct virtchnl_channel_info ch_info[VIRTCHNL_MAX_ADQ_V2_CHANNELS ];bool tc_running;
@@ -536,6 +558,7 @@ struct iecm_ptype_state {bool outer_frag;u8 tunnel_state; }; +/* User defined configuration values */ struct iecm_user_config_data {u32 num_req_tx_qs;/* user requested TX queues through ethtool */
@@ -550,6 +573,7 @@ struct iecm_user_config_data {struct list_head vlan_filter_list;struct list_head adv_rss_list;struct iecm_fdir_fltr_config fdir_config; +struct iecm_cloud_filter_config cf_config;struct iecm_channel_config ch_config; };
@@ -853,6 +877,7 @@ void iecm_set_ethtool_ops(struct net_device *netdev);void iecm_vport_set_hsplit (struct iecm_vport *vport,bool ena);void iecm_add_del_ether_addrs (struct iecm_vport *vport,bool add,bool async);int iecm_set_promiscuous (struct iecm_adapter *adapter); +int iecm_send_add_del_cloud_filter_msg (struct iecm_vport *vport,bool add);int iecm_send_add_fdir_filter_msg (struct iecm_vport *vport);int iecm_send_del_fdir_filter_msg (struct iecm_vport *vport); int iecm_get_fdir_fltr_entry(struct iecm_vport *vport,
Signature · 1 line
2.33.0
PATCH 17/19 iecm: implement cloud filters
From: Alan Brady <[email protected]>
Date: Thu, 27 Jan 2022 16:10:07 -0800
Quoted 44 lines
This gives iecm the ability to deal with cloud filters and other traffic classes.
Signed-off-by Phani Burra <[email protected]>Signed-off-by Joshua Hay <[email protected]>Signed-off-by Madhu Chittim <[email protected]>Signed-off-by Pavan Kumar Linga <[email protected]>Signed-off-by Alan Brady <[email protected]>--- drivers/net/ethernet/intel/iecm/iecm_lib.c | 900 +++++++++++++++++- .../net/ethernet/intel/iecm/iecm_virtchnl.c | 68 ++ drivers/net/ethernet/intel/include/iecm.h | 25 + 3 files changed, 992 insertions(+), 1 deletion(-)drivers/net/ethernet/intel/iecm/iecm_lib.c +12
-0@@ -43,9 +43,16 @@ static int iecm_get_vport_index(struct iecm_adapter *adapter,*/ bool iecm_is_feature_ena (struct iecm_vport *vport,netdev_features_t feature) { +struct iecm_channel_config *ch_config;bool ena;switch (feature) { +case NETIF_F_HW_TC : + ch_config = &vport->adapter->config_data.ch_config; + ena = (vport->netdev->features & feature) && + (ch_config->num_tc >IECM_START_CHNL_TC ) && + (ch_config->tc_running); +break ;default : ena = vport->netdev->features & feature;break ;@@ -53,6 +60,23 @@ bool iecm_is_feature_ena(struct iecm_vport *vport, netdev_features_t feature)return ena; } +/** +* iecm_is_adq_v2_ena - Determine whether ADQ V2 is enabled +* @vport: virtual port struct +* +* This function returns true based on negotiated capability ADQ_V2
drivers/net/ethernet/intel/iecm/iecm_lib.c bool iecm_is_feature_ena(struct iecm_vport *vport, netdev_features_t feature) · line 77
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+* if set and ADQ enabled +*/ +static bool iecm_is_adq_v2_ena (struct iecm_vport *vport) +{ +/* iecm_is_feature_ena tells if the netdev flag is set and adq is +* enabled +*/ +return (iecm_is_feature_ena (vport,NETIF_F_HW_TC ) && +iecm_is_cap_ena (vport->adapter,IECM_OTHER_CAPS , +VIRTCHNL2_CAP_ADQ ));
The outermost braces are redundant.
Quoted 16 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +9
-0+} +/** * iecm_is_vlan_cap_ena - Check if VLAN capability is enabled * @adapter: pointer to adapter @@ -946,6 +970,28 @@ static int iecm_get_free_slot(void *array, int size, int curr)return next; } +/** +* iecm_remove_cloud_filters - Remove all cloud filters +* @vport: vport structure +*/ +static void iecm_remove_cloud_filters (struct iecm_vport *vport) +{ +struct iecm_adapter *adapter = vport->adapter;
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_get_free_slot(void *array, int size, int curr) · line 989
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+struct iecm_cloud_filter_config *cf_config; + + cf_config = &adapter->config_data.cf_config; +if (!list_empty (&cf_config->cloud_filter_list)) { +struct iecm_cloud_filter *cf; + +spin_lock_bh (&adapter->cloud_filter_list_lock); +list_for_each_entry (cf, &cf_config->cloud_filter_list, list) { + cf->remove = true; + }
One-liner, braces are redundant.
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_get_free_slot(void *array, int size, int curr) · line 992
Quoted 3 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +3
-0+spin_unlock_bh (&adapter->cloud_filter_list_lock); +iecm_send_add_del_cloud_filter_msg (vport, false); + }
if (list_empty()) return;
-1 level.
Quoted 32 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +16
-1+} +/** * iecm_remove_vlan_filters - Remove all vlan filters * @vport: vport structure @@ -1044,8 +1090,14 @@ static void iecm_vport_stop(struct iecm_vport *vport)if (test_and_clear_bit (__IECM_DEL_QUEUES, vport->adapter->flags))iecm_send_delete_queues_msg (vport); -if (!test_bit (__IECM_REL_RES_IN_PROG, adapter->flags)) +/* In function reset/rmmod path we call unregister_netdev which +* internally calls delete cloud filters. We remove cloud filters only +* when the interface goes down +*/ +if (!test_bit (__IECM_REL_RES_IN_PROG, adapter->flags)) { +iecm_remove_cloud_filters (vport);iecm_remove_vlan_filters (vport); + }iecm_remove_fdir_filters (vport);@@ -1258,6 +1310,28 @@ static void iecm_restore_vlans(struct iecm_vport *vport)iecm_set_all_vlans (vport); } +/** +* iecm_restore_cloud_filters - Restore cloud filters +* @vport: vport structure +*/ +static void iecm_restore_cloud_filters (struct iecm_vport *vport) +{ +struct iecm_adapter *adapter = vport->adapter;
drivers/net/ethernet/intel/iecm/iecm_lib.c static void iecm_restore_vlans(struct iecm_vport *vport) · line 1329
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+struct iecm_cloud_filter_config *cf_config; + + cf_config = &adapter->config_data.cf_config; +if (!list_empty (&cf_config->cloud_filter_list)) { +struct iecm_cloud_filter *cf; + +spin_lock_bh (&adapter->cloud_filter_list_lock); +list_for_each_entry (cf, &cf_config->cloud_filter_list, list) { + cf->add = true; + }
Same here for braces.
drivers/net/ethernet/intel/iecm/iecm_lib.c static void iecm_restore_vlans(struct iecm_vport *vport) · line 1332
Quoted 3 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +3
-0+spin_unlock_bh (&adapter->cloud_filter_list_lock); +iecm_send_add_del_cloud_filter_msg (vport, true); + }
Same here for reducing indent level.
Quoted 37 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +16
-0+} +/** * iecm_restore_fdir_filters - Restore all Flow Director filters * @vport: vport structure @@ -1302,6 +1376,10 @@ static void iecm_restore_features(struct iecm_vport *vport)dev_info (&adapter->pdev->dev,"Failed to restore promiscuous settings\n" ); } +/* Restore cloud filters if ADQ is enabled */ +if (iecm_is_feature_ena (vport,NETIF_F_HW_TC )) +iecm_restore_cloud_filters (vport); +if (iecm_is_cap_ena (adapter,IECM_OTHER_CAPS ,VIRTCHNL2_CAP_FDIR ))iecm_restore_fdir_filters (vport); }@@ -2088,6 +2166,8 @@ int iecm_probe(struct pci_dev *pdev,spin_lock_init (&adapter->vlan_list_lock);spin_lock_init (&adapter->adv_rss_list_lock);spin_lock_init (&adapter->fdir_fltr_list_lock); +INIT_LIST_HEAD (&adapter->config_data.cf_config.cloud_filter_list); +INIT_LIST_HEAD (&adapter->config_data.cf_config.block_cb_list);INIT_LIST_HEAD (&adapter->config_data.mac_filter_list);INIT_LIST_HEAD (&adapter->config_data.vlan_filter_list);INIT_LIST_HEAD (&adapter->config_data.adv_rss_list);@@ -2389,6 +2469,810 @@ static int iecm_offload_txtime(struct iecm_vport *vport,return -EOPNOTSUPP ; } +/** +* iecm_is_vlan_tc_filter_allowed - allowed to add tc-filter using VLAN +* @vport: vport structure +* @vlan: VLAN to verify +* +* Using specified "vlan" ID, there must be active VLAN filter in VF's +* MAC-VLAN filter list. +*/
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_offload_txtime(struct iecm_vport *vport, · line 2489
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+static bool +iecm_is_vlan_tc_filter_allowed (struct iecm_vport *vport, +struct iecm_vlan *vlan) +{ +struct iecm_vlan_filter *f; +bool allowed; + +spin_lock_bh (&vport->adapter->vlan_list_lock); + f =iecm_find_vlan (vport, vlan); + allowed = (f && !f->add && !f->remove);
Redundant braces here.
Quoted 12 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +12
-0+spin_unlock_bh (&vport->adapter->vlan_list_lock); +return allowed; +} + +/** +* iecm_is_mac_tc_filter_allowed - allowed to add tc-filter using MAC addr +* @vport: vport structure +* @macaddr: MAC address +* +* Using specified MAC address, there must be active MAC filter in +* MAC filter list. +*/
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_offload_txtime(struct iecm_vport *vport, · line 2511
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+static bool +iecm_is_mac_tc_filter_allowed (struct iecm_vport *vport,const u8 *macaddr) +{ +struct iecm_adapter *adapter = vport->adapter; +struct iecm_mac_filter *f; +bool allowed; + +spin_lock_bh (&adapter->mac_filter_list_lock); + f =iecm_find_mac_filter (vport, macaddr); + allowed = (f && !f->add && !f->remove);
Same here.
Quoted 40 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +40
-0+spin_unlock_bh (&adapter->mac_filter_list_lock); +return allowed; +} + +/** +* iecm_parse_keyid - Parse keyid +* @rule: Flow rule structure +* @field_flags: Cloud filter flags +*/ +static void iecm_parse_keyid (struct flow_rule *rule,u8 *field_flags) +{ +struct flow_match_enc_keyid match; + +flow_rule_match_enc_keyid (rule, &match); + +if (match.mask->keyid !=0 ) + *field_flags |=IECM_CLOUD_FIELD_TEN_ID ; +} + +/** +* iecm_parse_flow_type - Parse flow type based on L2 and L3 protocols +* @vport: vport structure +* @rule: rule from user +* @cf: Structure for the virtchnl filter +* @filter: Structure for the cloud filter +* +* Return 0 on success, negative on failure +*/ +static int +iecm_parse_flow_type (struct iecm_vport *vport, +struct flow_rule *rule,struct virtchnl_filter *cf, +struct iecm_cloud_filter *filter) +{ +struct iecm_adapter *adapter = vport->adapter; +enum virtchnl_flow_type flow_type; +struct flow_match_basic match; +u16 n_proto_mask =0 ; +u16 n_proto_key =0 ; +u16 n_proto =0 ; +u8 ip_proto =0 ;
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_offload_txtime(struct iecm_vport *vport, · line 2561
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+ +flow_rule_match_basic (rule, &match); + + n_proto_key =ntohs (match.key->n_proto); + n_proto_mask =ntohs (match.mask->n_proto); + +if (n_proto_key ==ETH_P_ALL ) { + n_proto_key =0 ; + n_proto_mask =0 ; + }
n_proto_key = ntohs(); if (n_proto_key != ETH_P_ALL) n_proto_mask = ntohs();
Quoted 104 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +104
-0+ n_proto = n_proto_key & n_proto_mask; +if (n_proto !=ETH_P_IP && n_proto !=ETH_P_IPV6 ) +return -EINVAL ; + +if (iecm_is_cap_ena (adapter,IECM_OTHER_CAPS ,VIRTCHNL2_CAP_ADQ )) { +if (match.key->ip_proto !=IPPROTO_TCP && + match.key->ip_proto !=IPPROTO_UDP ) { +dev_err (&adapter->pdev->dev, +"Only TCP or UDP transport is supported\n" ); +return -EINVAL ; + } + }else if (match.key->ip_proto !=IPPROTO_TCP ) { +dev_err (&adapter->pdev->dev, +"Only TCP transport is supported\n" ); +return -EINVAL ; + } + ip_proto = match.key->ip_proto; + +/* determine VIRTCHNL flow_type based on L3 and L4 protocol */ +if (n_proto ==ETH_P_IP ) + flow_type = (ip_proto ==IPPROTO_TCP ) ? +VIRTCHNL_TCP_V4_FLOW : +VIRTCHNL_UDP_V4_FLOW ; +else + flow_type = (ip_proto ==IPPROTO_TCP ) ? +VIRTCHNL_TCP_V6_FLOW : +VIRTCHNL_UDP_V6_FLOW ; + cf->flow_type = flow_type; + filter->f.flow_type = flow_type; + +return 0 ; +} + +/** +* iecm_parse_ether_header - Parse ethernet header fields +* @vport: vport structure +* @field_flags: Cloud filter flags +* @d_spec: Virtchnl structure for L4 specs +* @m_spec: Virtchnl structure for L4 specs +* @rule: Flow rule structure +* +* Return 0 on success, negative on failure +*/ +static int +iecm_parse_ether_header (struct iecm_vport *vport,u8 *field_flags, +struct virtchnl_l4_spec *d_spec, +struct virtchnl_l4_spec *m_spec, +struct flow_rule *rule) +{ +struct iecm_adapter *adapter = vport->adapter; +struct flow_match_eth_addrs match; +bool adv_adq_ena; + + adv_adq_ena =iecm_is_cap_ena (adapter,IECM_OTHER_CAPS , +VIRTCHNL2_CAP_ADQ ); + +flow_rule_match_eth_addrs (rule, &match); + +/* use is_broadcast and is_zero to check for all 0xf or 0 */ +if (!is_zero_ether_addr (match.mask->dst)) { +if (adv_adq_ena ||is_broadcast_ether_addr (match.mask->dst)) { + *field_flags |=IECM_CLOUD_FIELD_OMAC ; + }else { +dev_err (&adapter->pdev->dev,"Bad ether dest mask %pM\n" , + match.mask->dst); +return -EINVAL ; + } + } + +if (!is_zero_ether_addr (match.mask->src)) { +if (adv_adq_ena ||is_broadcast_ether_addr (match.mask->src)) { + *field_flags |=IECM_CLOUD_FIELD_IMAC ; + }else { +dev_err (&adapter->pdev->dev,"Bad ether src mask %pM\n" , + match.mask->src); +return -EINVAL ; + } + } + +if (!is_zero_ether_addr (match.key->dst)) { +if (!iecm_is_mac_tc_filter_allowed (adapter->vports[0 ], + match.key->dst)) { +dev_err (&adapter->pdev->dev, +"Dest MAC %pM doesn't belong to this device\n" , + match.key->dst); +return -EINVAL ; + } + +if (is_valid_ether_addr (match.key->dst) || +is_multicast_ether_addr (match.key->dst)) { +/* set the mask if a valid dst_mac address */ +if (adv_adq_ena) +ether_addr_copy (m_spec->dst_mac, + match.mask->dst); +else +eth_broadcast_addr (m_spec->dst_mac); +ether_addr_copy (d_spec->dst_mac, + match.key->dst); + } + } + +if (!is_zero_ether_addr (match.key->src)) +if (is_valid_ether_addr (match.key->src) || +is_multicast_ether_addr (match.key->src)) {
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_offload_txtime(struct iecm_vport *vport, · line 2675
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+/* set the mask if a valid src_mac address */ +if (adv_adq_ena) { +ether_addr_copy (m_spec->src_mac, + match.mask->src); + }else { +eth_broadcast_addr (m_spec->src_mac); + } +ether_addr_copy (d_spec->src_mac, + match.key->src); + }
All previous ifs had braces, and it way okay since we have multiple nested if-elses, but here we don't have them.
Please either add them here or remove all the way above to keep the code style consistent.
Quoted 34 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +34
-0+return 0 ; +} + +/** +* iecm_parse_vlan_header - Parse vlan header fields +* @vport: vport structure +* @field_flags: Cloud filter flags +* @d_spec: Virtchnl structure for L4 specs +* @m_spec: Virtchnl structure for L4 specs +* @rule: Flow rule structure +* +* Return 0 on success, negative on failure +*/ +static int +iecm_parse_vlan_header (struct iecm_vport *vport,u8 *field_flags, +struct virtchnl_l4_spec *d_spec, +struct virtchnl_l4_spec *m_spec, +struct flow_rule *rule) +{ +struct iecm_adapter *adapter = vport->adapter; +struct flow_match_vlan match; + +flow_rule_match_vlan (rule, &match); +if (match.mask->vlan_id) { +u16 vid = match.key->vlan_id &VLAN_VID_MASK ; +struct iecm_vlan vlan; + + vlan =IECM_VLAN (vid,ETH_P_8021Q ); + +if (match.mask->vlan_id !=VLAN_VID_MASK ) { +dev_err (&adapter->pdev->dev,"Bad vlan mask %u\n" , + match.mask->vlan_id); +return -EINVAL ; + }
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_offload_txtime(struct iecm_vport *vport, · line 2719
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+if (!iecm_is_vlan_tc_filter_allowed (vport, &vlan)) { +dev_err (&adapter->pdev->dev, +"VLAN %u doesn't belong to this VF\n" , + vid); +return -EINVAL ; + } + *field_flags |=IECM_CLOUD_FIELD_IVLAN ; + m_spec->vlan_id =cpu_to_be16 (match.mask->vlan_id); + d_spec->vlan_id =cpu_to_be16 (match.key->vlan_id); + }
if (!vlan_id) return 0;
-1 level.
Quoted 113 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +113
-0+return 0 ; +} + +/** +* iecm_parse_ipv4_header - Parse ipv4 header fields +* @vport: vport structure +* @field_flags: Cloud filter flags +* @d_spec: Virtchnl structure for L4 specs +* @m_spec: Virtchnl structure for L4 specs +* @rule: Flow rule structure +* +* Return 0 on success, negative on failure +*/ +static int +iecm_parse_ipv4_header (struct iecm_vport *vport,u8 *field_flags, +struct virtchnl_l4_spec *d_spec, +struct virtchnl_l4_spec *m_spec, +struct flow_rule *rule) +{ +struct iecm_adapter *adapter = vport->adapter; +struct flow_match_ipv4_addrs match; +bool adv_adq_ena; + + adv_adq_ena =iecm_is_cap_ena (adapter,IECM_OTHER_CAPS , +VIRTCHNL2_CAP_ADQ ); + +flow_rule_match_ipv4_addrs (rule, &match); + +if (*field_flags &IECM_CLOUD_FIELD_TEN_ID ) { +dev_info (&adapter->pdev->dev, +"Tenant id not allowed for ip filter\n" ); +return -EINVAL ; + } + +if (match.mask->dst) { +if (adv_adq_ena || match.mask->dst ==cpu_to_be32 (0xffffffff )) { + *field_flags |=IECM_CLOUD_FIELD_IIP ; + }else { +dev_err (&adapter->pdev->dev,"Bad ip dst mask 0x%08x\n" , +be32_to_cpu (match.mask->dst)); +return -EINVAL ; + } + } + +if (match.mask->src) { +if (adv_adq_ena || match.mask->src ==cpu_to_be32 (0xffffffff )) { + *field_flags |=IECM_CLOUD_FIELD_IIP ; + }else { +dev_err (&adapter->pdev->dev,"Bad ip src mask 0x%08x\n" , +be32_to_cpu (match.mask->dst)); +return -EINVAL ; + } + } + +if (match.key->dst) { +if (adv_adq_ena) + m_spec->dst_ip[0 ] = match.mask->dst; +else + m_spec->dst_ip[0 ] =cpu_to_be32 (0xffffffff ); + d_spec->dst_ip[0 ] = match.key->dst; + } + +if (match.key->src) { +if (adv_adq_ena) + m_spec->src_ip[0 ] = match.mask->src; +else + m_spec->src_ip[0 ] =cpu_to_be32 (0xffffffff ); + d_spec->src_ip[0 ] = match.key->src; + } +return 0 ; +} + +/** +* iecm_parse_ipv6_header - Parse ipv6 header fields +* @vport: vport structure +* @field_flags: Cloud filter flags +* @d_spec: Virtchnl structure for L4 specs +* @m_spec: Virtchnl structure for L4 specs +* @rule: Flow rule structure +* +* Return 0 on success, negative on failure +*/ +static int +iecm_parse_ipv6_header (struct iecm_vport *vport,u8 *field_flags, +struct virtchnl_l4_spec *d_spec, +struct virtchnl_l4_spec *m_spec, +struct flow_rule *rule) +{ +struct iecm_adapter *adapter = vport->adapter; +struct flow_match_ipv6_addrs match; +int i; + +flow_rule_match_ipv6_addrs (rule, &match); + +/* validate mask, make sure it is not IPV6_ADDR_ANY */ +if (ipv6_addr_any (&match.mask->dst)) { +dev_err (&adapter->pdev->dev,"Bad ipv6 dst mask 0x%02x\n" , +IPV6_ADDR_ANY ); +return -EINVAL ; + } + +/* src and dest IPv6 address should not be LOOPBACK +* (0:0:0:0:0:0:0:1) which can be represented as ::1 +*/ +if (ipv6_addr_loopback (&match.key->dst) || +ipv6_addr_loopback (&match.key->src)) { +dev_err (&adapter->pdev->dev, +"ipv6 addr should not be loopback\n" ); +return -EINVAL ; + } + +if (!ipv6_addr_any (&match.mask->dst) || + !ipv6_addr_any (&match.mask->src))
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_offload_txtime(struct iecm_vport *vport, · line 2842
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+ *field_flags |=IECM_CLOUD_FIELD_IIP ; + +/* copy dest IPv6 mask and address */ +if (iecm_is_cap_ena (adapter,IECM_OTHER_CAPS ,VIRTCHNL2_CAP_ADQ )) { +memcpy (&m_spec->dst_ip, &match.mask->dst.s6_addr32, +sizeof (m_spec->dst_ip)); + }else { +for (i =0 ; i <4 ; i++) + m_spec->dst_ip[i] =cpu_to_be32 (0xffffffff ); + }
One-liners, no braces needed for both if and else.
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_offload_txtime(struct iecm_vport *vport, · line 2853
Quoted 11 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +11
-0+memcpy (&d_spec->dst_ip, &match.key->dst.s6_addr32, +sizeof (d_spec->dst_ip)); + +/* copy source IPv6 mask and address */ +if (iecm_is_cap_ena (adapter,IECM_OTHER_CAPS ,VIRTCHNL2_CAP_ADQ )) { +memcpy (&m_spec->src_ip, &match.mask->src.s6_addr32, +sizeof (m_spec->src_ip)); + }else { +for (i =0 ; i <4 ; i++) + m_spec->src_ip[i] =cpu_to_be32 (0xffffffff ); + }
Same here.
Quoted 195 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +195
-0+memcpy (&d_spec->src_ip, &match.key->src.s6_addr32, +sizeof (d_spec->src_ip)); + +return 0 ; +} + +/** +* iecm_parse_l4_header - Parse l4 header fields +* @vport: vport structure +* @d_spec: Virtchnl structure for L4 specs +* @m_spec: Virtchnl structure for L4 specs +* @rule: Flow rule structure +* +* Return 0 on success, negative on failure +*/ +static int +iecm_parse_l4_header (struct iecm_vport *vport, +struct virtchnl_l4_spec *d_spec, +struct virtchnl_l4_spec *m_spec, +struct flow_rule *rule) +{ +struct iecm_adapter *adapter = vport->adapter; +struct flow_match_ports match; + +flow_rule_match_ports (rule, &match); + +if (match.key->dst) { +if (iecm_is_cap_ena (adapter,IECM_OTHER_CAPS , +VIRTCHNL2_CAP_ADQ ) || + match.mask->dst ==cpu_to_be16 (0xffff )) { + m_spec->dst_port = match.mask->dst; + d_spec->dst_port = match.key->dst; + }else { +dev_err (&adapter->pdev->dev,"Bad dst port mask %u\n" , +be16_to_cpu (match.mask->dst)); +return -EINVAL ; + } + } + +if (match.key->src) { +if (iecm_is_cap_ena (adapter,IECM_OTHER_CAPS , +VIRTCHNL2_CAP_ADQ ) || + match.mask->src ==cpu_to_be16 (0xffff )) { + m_spec->src_port = match.mask->src; + d_spec->src_port = match.key->src; + }else { +dev_err (&adapter->pdev->dev,"Bad src port mask %u\n" , +be16_to_cpu (match.mask->src)); +return -EINVAL ; + } + } +return 0 ; +} + +/** +* iecm_parse_cls_flower - Parse tc flower filters provided by kernel +* @vport: vport structure +* @f: pointer to struct flow_cls_offload +* @filter: pointer to cloud filter structure +*/ +static int iecm_parse_cls_flower (struct iecm_vport *vport, +struct flow_cls_offload *f, +struct iecm_cloud_filter *filter) +{ +struct flow_rule *rule =flow_cls_offload_flow_rule (f); +struct iecm_adapter *adapter = vport->adapter; +struct virtchnl_l4_spec *d_spec, *m_spec; +struct virtchnl_filter *cf = &filter->f; +struct flow_dissector *dissector; +u8 field_flags =0 ; +u16 addr_type =0 ; +int err; + + dissector = rule->match.dissector; +if (dissector->used_keys & + ~(BIT (FLOW_DISSECTOR_KEY_CONTROL ) | +BIT (FLOW_DISSECTOR_KEY_BASIC ) | +BIT (FLOW_DISSECTOR_KEY_ETH_ADDRS ) | +BIT (FLOW_DISSECTOR_KEY_VLAN ) | +BIT (FLOW_DISSECTOR_KEY_IPV4_ADDRS ) | +BIT (FLOW_DISSECTOR_KEY_IPV6_ADDRS ) | +BIT (FLOW_DISSECTOR_KEY_ENC_KEYID ) | +BIT (FLOW_DISSECTOR_KEY_PORTS ))) { +dev_err (&adapter->pdev->dev,"Unsupported key used: 0x%x\n" , + dissector->used_keys); +return -EOPNOTSUPP ; + } +if (flow_rule_match_key (rule,FLOW_DISSECTOR_KEY_ENC_KEYID )) +iecm_parse_keyid (rule, &field_flags); + +/* even though following code refers as "tcp_sec", it is not +* just for TCP but a generic struct representing +* L2, L3 + L4 fields if specified +*/ + m_spec = &cf->mask.tcp_spec; + d_spec = &cf->data.tcp_spec; + +/* determine flow type, TCP/UDP_V4[6]_FLOW based on +* L2 proto (aka ETH proto) and L3 proto (aka IP_PROTO) +*/ +if (flow_rule_match_key (rule,FLOW_DISSECTOR_KEY_BASIC )) { + err =iecm_parse_flow_type (vport, rule, cf, filter); +if (err) +return err; + } + +/* process Ethernet header fields */ +if (flow_rule_match_key (rule,FLOW_DISSECTOR_KEY_ETH_ADDRS )) { + err =iecm_parse_ether_header (vport, &field_flags, + d_spec, m_spec, rule); +if (err) +return err; + } + +/* process VLAN header for single VLAN (type could be S/C-tag) */ +if (flow_rule_match_key (rule,FLOW_DISSECTOR_KEY_VLAN )) { + err =iecm_parse_vlan_header (vport, &field_flags, + d_spec, m_spec, rule); +if (err) +return err; + } + +if (flow_rule_match_key (rule,FLOW_DISSECTOR_KEY_CONTROL )) { +struct flow_match_control match; + +flow_rule_match_control (rule, &match); + addr_type = match.key->addr_type; + } + +/* process IPv4 header */ +if (addr_type ==FLOW_DISSECTOR_KEY_IPV4_ADDRS ) { + err =iecm_parse_ipv4_header (vport, &field_flags, + d_spec, m_spec, rule); +if (err) +return err; + } + +/* process IPv6 header */ +if (addr_type ==FLOW_DISSECTOR_KEY_IPV6_ADDRS ) { + err =iecm_parse_ipv6_header (vport, &field_flags, + d_spec, m_spec, rule); +if (err) +return err; + } + +/* process L4 header, supported L4 protocols are TCP and UDP */ +if (flow_rule_match_key (rule,FLOW_DISSECTOR_KEY_PORTS )) { + err =iecm_parse_l4_header (vport, d_spec, m_spec, rule); +if (err) +return err; + } + cf->field_flags = field_flags; + +return 0 ; +} + +/** +* iecm_handle_tclass - Forward to a traffic class on the device +* @vport: vport structure +* @tc: traffic class index on the device +* @filter: pointer to cloud filter structure +* +* Return 0 on success, negative on failure +*/ +static int iecm_handle_tclass (struct iecm_vport *vport,int tc, +struct iecm_cloud_filter *filter) +{ +struct iecm_adapter *adapter = vport->adapter; + +if (tc ==0 ) +return 0 ; +if ((!iecm_is_adq_v2_ena (vport)) && + !filter->f.data.tcp_spec.dst_port) { +dev_err (&adapter->pdev->dev, +"Specify destination port to redirect to traffic class other than TC0\n" ); +return -EINVAL ; + } +/* redirect to a traffic class on the same device */ + filter->f.action =VIRTCHNL_ACTION_TC_REDIRECT ; + filter->f.action_meta = tc; +return 0 ; +} + +/* iecm_find_cf - Find the cloud filter in the list +* @vport: vport structure +* @cookie: filter specific cookie +* +* Returns pointer to the filter object or NULL. Must be called while holding +* cloud_filter_list_lock. +*/ +static struct iecm_cloud_filter *iecm_find_cf (struct iecm_vport *vport, +unsigned long *cookie) +{ +struct iecm_adapter *adapter = vport->adapter; +struct iecm_cloud_filter *filter =NULL ;
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_offload_txtime(struct iecm_vport *vport, · line 3058
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+ +if (!cookie) +return NULL ; + +list_for_each_entry (filter, + &adapter->config_data.cf_config.cloud_filter_list, + list) { +if (!memcmp (cookie, &filter->cookie,sizeof (filter->cookie))) +return filter; + }
Redundant braces round single statement.
Quoted 133 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +133
-0+return NULL ; +} + +/** +* iecm_configure_clsflower - Add tc flower filters +* @vport: vport structure +* @cls_flower: Pointer to struct flow_cls_offload +* +* Return 0 on success, negative on failure +*/ +static int iecm_configure_clsflower (struct iecm_vport *vport, +struct flow_cls_offload *cls_flower) +{ +struct iecm_adapter *adapter = vport->adapter; +struct iecm_user_config_data *config_data; +struct iecm_cloud_filter *filter =NULL ; +int err; +int tc; + + config_data = &adapter->config_data; + tc =tc_classid_to_hwtc (vport->netdev, cls_flower->classid); +if (tc <0 ) { +dev_err (&adapter->pdev->dev,"Invalid traffic class\n" ); +return -EINVAL ; + } + +#define IECM_MAX_CLOUD_ADQ_FILTERS 128 + +if (config_data->cf_config.num_cloud_filters >= +IECM_MAX_CLOUD_ADQ_FILTERS ) { +dev_err (&adapter->pdev->dev, +"Unable to add filter (action is forward to TC), reached max allowed filters (%u)\n" , +IECM_MAX_CLOUD_ADQ_FILTERS ); +return -ENOSPC ; + } + +/* bail out here if filter already exists */ +spin_lock_bh (&adapter->cloud_filter_list_lock); + filter =iecm_find_cf (vport, &cls_flower->cookie); +if (filter) { + filter->remove = false; +dev_err (&adapter->pdev->dev,"Failed to add TC Flower filter, it already exists\n" ); +spin_unlock_bh (&adapter->cloud_filter_list_lock); +return -EEXIST ; + } +spin_unlock_bh (&adapter->cloud_filter_list_lock); + + filter =kzalloc (sizeof (*filter),GFP_KERNEL ); +if (!filter) +return -ENOMEM ; + + filter->cookie = cls_flower->cookie; + +/* set the mask to all zeroes to begin with */ +memset (&filter->f.mask.tcp_spec,0 ,sizeof (struct virtchnl_l4_spec )); + +/* start out with flow type and eth type IPv4 to begin with */ + filter->f.flow_type =VIRTCHNL_TCP_V4_FLOW ; + err =iecm_parse_cls_flower (vport, cls_flower, filter); +if (err) + goto error; + + err =iecm_handle_tclass (vport, tc, filter); +if (err) + goto error; + +/* add filter to the list */ +spin_lock_bh (&adapter->cloud_filter_list_lock); +list_add_tail (&filter->list, &config_data->cf_config.cloud_filter_list); + filter->add = true; +spin_unlock_bh (&adapter->cloud_filter_list_lock); + err =iecm_send_add_del_cloud_filter_msg (vport, true); +spin_lock_bh (&adapter->cloud_filter_list_lock); +/* We have to find it again in case another thread has already +* deleted and kfreed it. +*/ + filter =iecm_find_cf (vport, &cls_flower->cookie); +if (filter && err) { +list_del (&filter->list); +spin_unlock_bh (&adapter->cloud_filter_list_lock); + goto error; + } +spin_unlock_bh (&adapter->cloud_filter_list_lock); + + config_data->cf_config.num_cloud_filters++; +error: +if (err) +kfree (filter); +return err; +} + +/** +* iecm_delete_clsflower - Remove tc flower filters +* @vport: vport structure +* @cls_flower: Pointer to struct flow_cls_offload +* +* Return 0 on success, negative on failure +*/ +static int iecm_delete_clsflower (struct iecm_vport *vport, +struct flow_cls_offload *cls_flower) +{ +struct iecm_adapter *adapter = vport->adapter; +struct iecm_cloud_filter *filter =NULL ; +int err =0 ; + +spin_lock_bh (&adapter->cloud_filter_list_lock); + filter =iecm_find_cf (vport, &cls_flower->cookie); +if (filter) { + filter->remove = true; + adapter->config_data.cf_config.num_cloud_filters--; + }else if (adapter->config_data.cf_config.num_cloud_filters) { +/* "num_cloud_filters" can become zero if egress qdisc is +* detached as per design, driver deletes related filters +* when qdisc is detached to avoid stale filters, hence +* num_cloud_filters can become zero. But since netdev +* layer doesn't know that filters are deleted by driver +* implictly when egress qdisc is deleted, it sees filters +* being present and "in_hw". User can request delete +* of specific filter of detach ingress qdisc - in either of +* those operation, filter(s) won't be found in driver cache, +* hence instead of returning, let this function return SUCCESS +* Returning of err as -EINVAL is only applicable when +* unable to find filter and num_cloud_filters is non-zero +*/ + err = -EINVAL ; + } +spin_unlock_bh (&adapter->cloud_filter_list_lock); + +if (filter) { + err =iecm_send_add_del_cloud_filter_msg (vport, false); +spin_lock_bh (&adapter->cloud_filter_list_lock); +/* It can happen that asynchronously the filter was already +* deleted from the list. Make sure it's still there and marked
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_offload_txtime(struct iecm_vport *vport, · line 3201
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+* for remove under spinlock before actually trying to delete +* from list. +*/ + filter =iecm_find_cf (vport, &cls_flower->cookie); +if (filter) { +list_del (&filter->list); +kfree (filter); + } +spin_unlock_bh (&adapter->cloud_filter_list_lock); + }
if (!filter) return err; err = ...
-1 level.
Quoted 35 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +35
-0+return err; +} + +/** +* iecm_setup_tc_cls_flower - flower classifier offloads +* @vport: vport structure +* @cls_flower: pointer to struct flow_cls_offload +* +* Return 0 on success, negative on failure +*/ +static int iecm_setup_tc_cls_flower (struct iecm_vport *vport, +struct flow_cls_offload *cls_flower) +{ +if (cls_flower->common.chain_index) +return -EOPNOTSUPP ; + +switch (cls_flower->command) { +case FLOW_CLS_REPLACE : +return iecm_configure_clsflower (vport, cls_flower); +case FLOW_CLS_DESTROY : +return iecm_delete_clsflower (vport, cls_flower); +case FLOW_CLS_STATS : +return -EOPNOTSUPP ; +default : +return -EINVAL ; + } +} + +/** +* iecm_setup_tc_block_cb - block callback for tc +* @type: type of offload +* @type_data: offload data +* @cb_priv: Private adapter structure +* +* This function is the block callback for traffic classes
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_offload_txtime(struct iecm_vport *vport, · line 3246
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+* Return 0 on success, negative on failure +**/ +static int iecm_setup_tc_block_cb (enum tc_setup_type type,void *type_data, +void *cb_priv) +{ +switch (type) { +case TC_SETUP_CLSFLOWER : +return iecm_setup_tc_cls_flower ((struct iecm_vport *)cb_priv, + (struct flow_cls_offload *) + type_data);
Just dereference them in separate variables and they will fit into one line. There shouldn't be any spaces or line breaks after a cast.
Quoted 56 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +33
-0+default : +return -EOPNOTSUPP ; + } +} + +/** +* iecm_del_all_cloud_filters - delete all cloud filters on the traffic classes +* @vport: vport structure +* +* This function will loop through the list of cloud filters and deletes them. +**/ +static void iecm_del_all_cloud_filters (struct iecm_vport *vport) +{ +struct iecm_adapter *adapter = vport->adapter; +struct iecm_cloud_filter_config *cf_config; +struct iecm_cloud_filter *cf, *cftmp; + + cf_config = &adapter->config_data.cf_config; +spin_lock_bh (&adapter->cloud_filter_list_lock); +list_for_each_entry_safe (cf, cftmp, + &cf_config->cloud_filter_list, + list) { +list_del (&cf->list); +kfree (cf); + cf_config->num_cloud_filters--; + } +spin_unlock_bh (&adapter->cloud_filter_list_lock); +} +/** * iecm_validate_tx_bandwidth - validate the max Tx bandwidth * @vport: vport structure @@ -2596,6 +3480,7 @@ static int __iecm_setup_tc(struct iecm_vport *vport, void *type_data)netif_tx_stop_all_queues (netdev);netif_tx_disable (netdev); ret =iecm_send_disable_channels_msg (vport); +iecm_del_all_cloud_filters (vport);netif_tx_start_all_queues (netdev);if (!test_bit (__IECM_REL_RES_IN_PROG, adapter->flags) && !ret) {@@ -2709,8 +3594,10 @@ static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, {struct iecm_vport *vport =iecm_netdev_to_vport (netdev);struct iecm_adapter *adapter = vport->adapter; +struct iecm_cloud_filter_config *cf_config;int err =0 ; + cf_config = &adapter->config_data.cf_config;switch (type) {case TC_SETUP_QDISC_ETF :if (iecm_is_queue_model_split (vport->txq_model))@@ -2720,6 +3607,17 @@ static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, type_data);break ;case TC_SETUP_BLOCK : + if (iecm_is_cap_ena(adapter, IECM_BASE_CAPS,
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 3620
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+ VIRTCHNL2_CAP_ADQ) || + iecm_is_cap_ena(adapter, IECM_OTHER_CAPS, + VIRTCHNL2_CAP_ADQ)) { + err = +flow_block_cb_setup_simple ((struct flow_block_offload *) + type_data, + &cf_config->block_cb_list, + iecm_setup_tc_block_cb, + vport, vport, true); + }
Invert the condition, and there'll be no line wraps (esp. if you assign casted @type_data into a separate var).
Quoted 38 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +0
-0break ;case TC_SETUP_QDISC_MQPRIO : if (iecm_is_cap_ena(adapter, IECM_BASE_CAPS,drivers/net/ethernet/intel/iecm/iecm_virtchnl.c +27
-0@@ -2731,6 +2731,74 @@ static int iecm_send_insert_vlan_msg(struct iecm_vport *vport, bool ena)return err; } +/** +* iecm_send_add_del_cloud_filter_msg: Send add/del cloud filter message +* @vport: vport structure +* @add: True to add, false to delete cloud filter +* +* Request the CP/PF to add/del cloud filters as specified by the user via +* tc tool +* +* Return 0 on success, negative on failure +**/ +int iecm_send_add_del_cloud_filter_msg (struct iecm_vport *vport,bool add) +{ +struct iecm_adapter *adapter = vport->adapter; +struct iecm_cloud_filter_config *cf_config; +struct iecm_cloud_filter *cf; +struct virtchnl_filter f; +int len =0 , err =0 ; + + cf_config = &adapter->config_data.cf_config; + +while (true) { +bool process_fltr = false; + +spin_lock_bh (&adapter->cloud_filter_list_lock); +list_for_each_entry (cf, &cf_config->cloud_filter_list, list) { +if (add && cf->add) { + process_fltr = true;
drivers/net/ethernet/intel/iecm/iecm_virtchnl.c static int iecm_send_insert_vlan_msg(struct iecm_vport *vport, bool ena) · line 2770
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_virtchnl.c +10
-0+ cf->add = false; + f = cf->f; +break ; + }else if (!add && cf->remove) { + process_fltr = true; + cf->remove = false; + f = cf->f; +break ; + } + }
Redundant braces.
Quoted 13 lines
drivers/net/ethernet/intel/iecm/iecm_virtchnl.c +13
-0+spin_unlock_bh (&adapter->cloud_filter_list_lock); + +/* Don't send mailbox message when there are no filters to add/del */ +if (!process_fltr) + goto error; + +if (add) { + err =iecm_send_mb_msg (adapter,VIRTCHNL_OP_ADD_CLOUD_FILTER , + len, (u8 *)&f); +if (err) + goto error; + + err = iecm_wait_for_event(adapter, IECM_VC_ADD_CLOUD_FILTER,
drivers/net/ethernet/intel/iecm/iecm_virtchnl.c static int iecm_send_insert_vlan_msg(struct iecm_vport *vport, bool ena) · line 2793
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_virtchnl.c +10
-0+ IECM_VC_ADD_CLOUD_FILTER_ERR); + }else { + err =iecm_send_mb_msg (adapter,VIRTCHNL_OP_DEL_CLOUD_FILTER , + len, (u8 *)&f); +if (err) + goto error; + + err = +iecm_min_wait_for_event (adapter,IECM_VC_DEL_CLOUD_FILTER , +IECM_VC_DEL_CLOUD_FILTER_ERR );
Too long lines here.
Quoted 45 lines
drivers/net/ethernet/intel/iecm/iecm_virtchnl.c +8
-0+ } +if (err) +break ; + } +error: +return err; +} +/** * iecm_send_add_fdir_filter_msg: Send add Flow Director filter message * @vport: vport structure drivers/net/ethernet/intel/include/iecm.h +22
-0@@ -403,6 +403,28 @@ enum iecm_user_flags { __IECM_USER_FLAGS_NBITS, }; +#define IECM_CLOUD_FIELD_OMAC BIT(0) +#define IECM_CLOUD_FIELD_IMAC BIT(1) +#define IECM_CLOUD_FIELD_IVLAN BIT(2) +#define IECM_CLOUD_FIELD_TEN_ID BIT(3) +#define IECM_CLOUD_FIELD_IIP BIT(4) + +#define IECM_START_CHNL_TC 1 + +struct iecm_cloud_filter { +struct list_head list; +struct virtchnl_filter f; +unsigned long cookie; +bool remove;/* filter needs to be deleted */ +bool add;/* filter needs to be added */ +}; + +struct iecm_cloud_filter_config { +struct list_head block_cb_list;/* need to pass this to stack */ +struct list_head cloud_filter_list; +u16 num_cloud_filters; +}; +struct iecm_channel_config {struct virtchnl_channel_info ch_info[VIRTCHNL_MAX_ADQ_V2_CHANNELS ];bool tc_running;
drivers/net/ethernet/intel/include/iecm.h struct iecm_ptype_state { · line 561
Quoted 4 lines
drivers/net/ethernet/intel/include/iecm.h +1
-0@@ -536,6 +558,7 @@ struct iecm_ptype_state {bool outer_frag;u8 tunnel_state; }; +
Please move this newline into the patch where iecm_ptype_state was introduced, it doesn't belong here.
Quoted 21 lines
drivers/net/ethernet/intel/include/iecm.h +2
-0/* User defined configuration values */ struct iecm_user_config_data {u32 num_req_tx_qs;/* user requested TX queues through ethtool */ @@ -550,6 +573,7 @@ struct iecm_user_config_data {struct list_head vlan_filter_list;struct list_head adv_rss_list;struct iecm_fdir_fltr_config fdir_config; +struct iecm_cloud_filter_config cf_config;struct iecm_channel_config ch_config; };@@ -853,6 +877,7 @@ void iecm_set_ethtool_ops(struct net_device *netdev);void iecm_vport_set_hsplit (struct iecm_vport *vport,bool ena);void iecm_add_del_ether_addrs (struct iecm_vport *vport,bool add,bool async);int iecm_set_promiscuous (struct iecm_adapter *adapter); +int iecm_send_add_del_cloud_filter_msg (struct iecm_vport *vport,bool add);int iecm_send_add_fdir_filter_msg (struct iecm_vport *vport);int iecm_send_del_fdir_filter_msg (struct iecm_vport *vport); int iecm_get_fdir_fltr_entry(struct iecm_vport *vport,Signature · 1 line
2.33.0
Thanks,
Al
Brady
PATCH 17/19 iecm: implement cloud filters
Quoted 57 lines
-----Original Message-----
From: Lobakin, Alexandr <[email protected]>
Sent: Friday, January 28, 2022 11:38 AM
To: Brady, Alan <[email protected]>
Cc: Lobakin, Alexandr <[email protected]>; intel-wired- lan at lists.osuosl.org; Burra, Phani R <[email protected]>; Chittim, Madhu <[email protected]>; Linga, Pavan Kumar <[email protected]>
Subject: Re: [Intel-wired-lan] [PATCH net-next 17/19] iecm: implement cloud filtersFrom: Alan Brady <[email protected]>
Date: Thu, 27 Jan 2022 16:10:07 -0800Quoted 10 lines
This gives iecm the ability to deal with cloud filters and other traffic classes.
Signed-off-by Phani Burra <[email protected]>Signed-off-by Joshua Hay <[email protected]>Signed-off-by Madhu Chittim <[email protected]>Signed-off-by Pavan Kumar Linga <[email protected]>Signed-off-by Alan Brady <[email protected]>--- drivers/net/ethernet/intel/iecm/iecm_lib.c | 900+++++++++++++++++-
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_get_vport_index(struct
Quoted 10 lines
.../net/ethernet/intel/iecm/iecm_virtchnl.c | 68 ++ drivers/net/ethernet/intel/include/iecm.h | 25 + 3 files changed, 992 insertions(+), 1 deletion(-)drivers/net/ethernet/intel/iecm/iecm_lib.c +0
-0@@ -43,9 +43,16 @@ static int iecm_get_vport_index(struct
iecm_adapter*adapter,drivers/net/ethernet/intel/iecm/iecm_lib.c bool iecm_is_feature_ena(struct iecm_vport
Quoted 17 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +7
-0*/ bool iecm_is_feature_ena (struct iecm_vport *vport,netdev_features_t feature) { +struct iecm_channel_config *ch_config;bool ena;switch (feature) { +case NETIF_F_HW_TC : + ch_config = &vport->adapter->config_data.ch_config; + ena = (vport->netdev->features & feature) && + (ch_config->num_tc >IECM_START_CHNL_TC ) && + (ch_config->tc_running); +break ;default : ena = vport->netdev->features & feature;break ;@@ -53,6 +60,23 @@ bool iecm_is_feature_ena(struct iecm_vport*vport,
netdev_features_tfeature)Quoted 3 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +0
-0return ena; }
Quoted 17 lines
Quoted 4 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +4
-0+/** +* iecm_is_adq_v2_ena - Determine whether ADQ V2 is enabled +* @vport: virtual port struct +* drivers/net/ethernet/intel/iecm/iecm_lib.c bool iecm_is_feature_ena(struct iecm_vport *vport, netdev_features_t feature) · line 77
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+* This function returns true based on negotiated capability ADQ_V2 +* if set and ADQ enabled +*/ +static bool iecm_is_adq_v2_ena (struct iecm_vport *vport) { +/* iecm_is_feature_ena tells if the netdev flag is set and adq is +* enabled +*/ +return (iecm_is_feature_ena (vport,NETIF_F_HW_TC ) && +iecm_is_cap_ena (vport->adapter,IECM_OTHER_CAPS , +VIRTCHNL2_CAP_ADQ ));The outermost braces are redundant.
Will fix.
Quoted 75 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_get_free_slot(void *array, int
Quoted 6 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +2
-0+} +/** * iecm_is_vlan_cap_ena - Check if VLAN capability is enabled * @adapter: pointer to adapter @@ -946,6 +970,28 @@ static int iecm_get_free_slot(void *array, intsize, int curr)
Quoted 9 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +6
-0return next; } +/** +* iecm_remove_cloud_filters - Remove all cloud filters +* @vport: vport structure +*/ +static void iecm_remove_cloud_filters (struct iecm_vport *vport) { +struct iecm_adapter *adapter = vport->adapter;drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_get_free_slot(void *array, int size, int curr) · line 989
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+struct iecm_cloud_filter_config *cf_config; + + cf_config = &adapter->config_data.cf_config; +if (!list_empty (&cf_config->cloud_filter_list)) { +struct iecm_cloud_filter *cf; + +spin_lock_bh (&adapter->cloud_filter_list_lock); +list_for_each_entry (cf, &cf_config->cloud_filter_list, list) { + cf->remove = true; + }One-liner, braces are redundant.
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_get_free_slot(void *array, int size, int curr) · line 992
Quoted 3 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +3
-0+spin_unlock_bh (&adapter->cloud_filter_list_lock); +iecm_send_add_del_cloud_filter_msg (vport, false); + }if (list_empty()) return;-1 level.
drivers/net/ethernet/intel/iecm/iecm_lib.c static void iecm_vport_stop(struct
Quoted 6 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +2
-0+} +/** * iecm_remove_vlan_filters - Remove all vlan filters * @vport: vport structure @@ -1044,8 +1090,14 @@ static void iecm_vport_stop(struct
iecm_vport*vport)drivers/net/ethernet/intel/iecm/iecm_lib.c static void iecm_restore_vlans(struct
Quoted 16 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +7
-1if (test_and_clear_bit (__IECM_DEL_QUEUES, vport->adapter->flags))iecm_send_delete_queues_msg (vport); -if (!test_bit (__IECM_REL_RES_IN_PROG, adapter->flags)) +/* In function reset/rmmod path we call unregister_netdev which +* internally calls delete cloud filters. We remove cloud filters only +* when the interface goes down +*/ +if (!test_bit (__IECM_REL_RES_IN_PROG, adapter->flags)) { +iecm_remove_cloud_filters (vport);iecm_remove_vlan_filters (vport); + }iecm_remove_fdir_filters (vport);@@ -1258,6 +1310,28 @@ static void iecm_restore_vlans(struct
iecm_vport*vport)Quoted 13 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0iecm_set_all_vlans (vport); } +/** +* iecm_restore_cloud_filters - Restore cloud filters +* @vport: vport structure +*/ +static void iecm_restore_cloud_filters (struct iecm_vport *vport) { +struct iecm_adapter *adapter = vport->adapter; +struct iecm_cloud_filter_config *cf_config; + + cf_config = &adapter->config_data.cf_config; +if (!list_empty (&cf_config->cloud_filter_list)) {
Quoted 9 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c static void iecm_restore_vlans(struct iecm_vport *vport) · line 1329
Quoted 6 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +6
-0+struct iecm_cloud_filter *cf; + +spin_lock_bh (&adapter->cloud_filter_list_lock); +list_for_each_entry (cf, &cf_config->cloud_filter_list, list) { + cf->add = true; + }Same here for braces.
Will fix.
Quoted 53 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c static void iecm_restore_vlans(struct iecm_vport *vport) · line 1332
Quoted 3 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +3
-0+spin_unlock_bh (&adapter->cloud_filter_list_lock); +iecm_send_add_del_cloud_filter_msg (vport, true); + }Same here for reducing indent level.
drivers/net/ethernet/intel/iecm/iecm_lib.c static void iecm_restore_features(struct
Quoted 6 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +2
-0+} +/** * iecm_restore_fdir_filters - Restore all Flow Director filters * @vport: vport structure @@ -1302,6 +1376,10 @@ static void iecm_restore_features(struct
iecm_vport*vport)drivers/net/ethernet/intel/iecm/iecm_lib.c static void iecm_restore_features(struct · line 1376
Quoted 1 line
drivers/net/ethernet/intel/iecm/iecm_lib.c +0
-0dev_info(&adapter->pdev->dev, "Failed to restorepromiscuous settings\n");
drivers/net/ethernet/intel/iecm/iecm_lib.c static void iecm_restore_features(struct iecm_vport *vport)
Quoted 7 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +4
-0} +/* Restore cloud filters if ADQ is enabled */ +if (iecm_is_feature_ena (vport,NETIF_F_HW_TC )) +iecm_restore_cloud_filters (vport); + if (iecm_is_cap_ena(adapter, IECM_OTHER_CAPS,
VIRTCHNL2_CAP_FDIR))drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_offload_txtime(struct
Quoted 12 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +2
-0iecm_restore_fdir_filters (vport); }@@ -2088,6 +2166,8 @@ int iecm_probe(struct pci_dev *pdev,spin_lock_init (&adapter->vlan_list_lock);spin_lock_init (&adapter->adv_rss_list_lock);spin_lock_init (&adapter->fdir_fltr_list_lock); +INIT_LIST_HEAD (&adapter->config_data.cf_config.cloud_filter_list); +INIT_LIST_HEAD (&adapter->config_data.cf_config.block_cb_list);INIT_LIST_HEAD (&adapter->config_data.mac_filter_list);INIT_LIST_HEAD (&adapter->config_data.vlan_filter_list);INIT_LIST_HEAD (&adapter->config_data.adv_rss_list);@@ -2389,6 +2469,810 @@ static int iecm_offload_txtime(struct
iecm_vport*vport,Quoted 17 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +14
-0return -EOPNOTSUPP ; } +/** +* iecm_is_vlan_tc_filter_allowed - allowed to add tc-filter using +VLAN +* @vport: vport structure +* @vlan: VLAN to verify +* +* Using specified "vlan" ID, there must be active VLAN filter in +VF's +* MAC-VLAN filter list. +*/ +static bool +iecm_is_vlan_tc_filter_allowed (struct iecm_vport *vport, +struct iecm_vlan *vlan) +{
Quoted 9 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_offload_txtime(struct iecm_vport *vport, · line 2489
Quoted 6 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +6
-0+struct iecm_vlan_filter *f; +bool allowed; + +spin_lock_bh (&vport->adapter->vlan_list_lock); + f =iecm_find_vlan (vport, vlan); + allowed = (f && !f->add && !f->remove);Redundant braces here.
Will fix.
Quoted 69 lines
Quoted 13 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +13
-0+spin_unlock_bh (&vport->adapter->vlan_list_lock); +return allowed; +} + +/** +* iecm_is_mac_tc_filter_allowed - allowed to add tc-filter using MAC +addr +* @vport: vport structure +* @macaddr: MAC address +* +* Using specified MAC address, there must be active MAC filter in +* MAC filter list. +*/ drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_offload_txtime(struct iecm_vport *vport, · line 2511
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+static bool +iecm_is_mac_tc_filter_allowed (struct iecm_vport *vport,const u8 +*macaddr) { +struct iecm_adapter *adapter = vport->adapter; +struct iecm_mac_filter *f; +bool allowed; + +spin_lock_bh (&adapter->mac_filter_list_lock); + f =iecm_find_mac_filter (vport, macaddr); + allowed = (f && !f->add && !f->remove);Same here.
Quoted 43 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +43
-0+spin_unlock_bh (&adapter->mac_filter_list_lock); +return allowed; +} + +/** +* iecm_parse_keyid - Parse keyid +* @rule: Flow rule structure +* @field_flags: Cloud filter flags +*/ +static void iecm_parse_keyid (struct flow_rule *rule,u8 +*field_flags) { +struct flow_match_enc_keyid match; + +flow_rule_match_enc_keyid (rule, &match); + +if (match.mask->keyid !=0 ) + *field_flags |=IECM_CLOUD_FIELD_TEN_ID ; } + +/** +* iecm_parse_flow_type - Parse flow type based on L2 and L3 +protocols +* @vport: vport structure +* @rule: rule from user +* @cf: Structure for the virtchnl filter +* @filter: Structure for the cloud filter +* +* Return 0 on success, negative on failure */ static int +iecm_parse_flow_type (struct iecm_vport *vport, +struct flow_rule *rule,struct virtchnl_filter *cf, +struct iecm_cloud_filter *filter) { +struct iecm_adapter *adapter = vport->adapter; +enum virtchnl_flow_type flow_type; +struct flow_match_basic match; +u16 n_proto_mask =0 ; +u16 n_proto_key =0 ; +u16 n_proto =0 ; +u8 ip_proto =0 ; + +flow_rule_match_basic (rule, &match); + + n_proto_key =ntohs (match.key->n_proto); + n_proto_mask =ntohs (match.mask->n_proto); +
Quoted 9 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_offload_txtime(struct iecm_vport *vport, · line 2561
Quoted 4 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +4
-0+if (n_proto_key ==ETH_P_ALL ) { + n_proto_key =0 ; + n_proto_mask =0 ; + }n_proto_key = ntohs(); if (n_proto_key != ETH_P_ALL) n_proto_mask = ntohs();
Will fix
Quoted 116 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_offload_txtime(struct iecm_vport *vport,
Quoted 5 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +5
-0+ n_proto = n_proto_key & n_proto_mask; +if (n_proto !=ETH_P_IP && n_proto !=ETH_P_IPV6 ) +return -EINVAL ; + + if (iecm_is_cap_ena(adapter, IECM_OTHER_CAPS,
VIRTCHNL2_CAP_ADQ)) {drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_offload_txtime(struct iecm_vport *vport,
Quoted 4 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +4
-0+if (match.key->ip_proto !=IPPROTO_TCP && + match.key->ip_proto !=IPPROTO_UDP ) { + dev_err(&adapter->pdev->dev, + "Only TCP or UDP transport issupported\n");
Quoted 44 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +44
-0+return -EINVAL ; + } + }else if (match.key->ip_proto !=IPPROTO_TCP ) { +dev_err (&adapter->pdev->dev, +"Only TCP transport is supported\n" ); +return -EINVAL ; + } + ip_proto = match.key->ip_proto; + +/* determine VIRTCHNL flow_type based on L3 and L4 protocol */ +if (n_proto ==ETH_P_IP ) + flow_type = (ip_proto ==IPPROTO_TCP ) ? +VIRTCHNL_TCP_V4_FLOW : +VIRTCHNL_UDP_V4_FLOW ; +else + flow_type = (ip_proto ==IPPROTO_TCP ) ? +VIRTCHNL_TCP_V6_FLOW : +VIRTCHNL_UDP_V6_FLOW ; + cf->flow_type = flow_type; + filter->f.flow_type = flow_type; + +return 0 ; +} + +/** +* iecm_parse_ether_header - Parse ethernet header fields +* @vport: vport structure +* @field_flags: Cloud filter flags +* @d_spec: Virtchnl structure for L4 specs +* @m_spec: Virtchnl structure for L4 specs +* @rule: Flow rule structure +* +* Return 0 on success, negative on failure */ static int +iecm_parse_ether_header (struct iecm_vport *vport,u8 *field_flags, +struct virtchnl_l4_spec *d_spec, +struct virtchnl_l4_spec *m_spec, +struct flow_rule *rule) +{ +struct iecm_adapter *adapter = vport->adapter; +struct flow_match_eth_addrs match; +bool adv_adq_ena; + + adv_adq_ena =iecm_is_cap_ena (adapter,IECM_OTHER_CAPS , +VIRTCHNL2_CAP_ADQ );drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_offload_txtime(struct iecm_vport *vport,
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +9
-0+ +flow_rule_match_eth_addrs (rule, &match); + +/* use is_broadcast and is_zero to check for all 0xf or 0 */ +if (!is_zero_ether_addr (match.mask->dst)) { +if (adv_adq_ena ||is_broadcast_ether_addr (match.mask- dst)) { + *field_flags |=IECM_CLOUD_FIELD_OMAC ; + }else { + dev_err(&adapter->pdev->dev, "Bad ether destmask %pM\n",
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_offload_txtime(struct iecm_vport *vport,
Quoted 11 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+ match.mask->dst); +return -EINVAL ; + } + } + +if (!is_zero_ether_addr (match.mask->src)) { +if (adv_adq_ena ||is_broadcast_ether_addr (match.mask- src)) { + *field_flags |=IECM_CLOUD_FIELD_IMAC ; + }else { + dev_err(&adapter->pdev->dev, "Bad ether src mask%pM\n",
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_offload_txtime(struct iecm_vport *vport,
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+ match.mask->src); +return -EINVAL ; + } + } + +if (!is_zero_ether_addr (match.key->dst)) { +if (!iecm_is_mac_tc_filter_allowed (adapter->vports[0 ], + match.key->dst)) { + dev_err(&adapter->pdev->dev, + "Dest MAC %pM doesn't belong to thisdevice\n",
Quoted 27 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +27
-0+ match.key->dst); +return -EINVAL ; + } + +if (is_valid_ether_addr (match.key->dst) || +is_multicast_ether_addr (match.key->dst)) { +/* set the mask if a valid dst_mac address */ +if (adv_adq_ena) +ether_addr_copy (m_spec->dst_mac, + match.mask->dst); +else +eth_broadcast_addr (m_spec->dst_mac); +ether_addr_copy (d_spec->dst_mac, + match.key->dst); + } + } + +if (!is_zero_ether_addr (match.key->src)) +if (is_valid_ether_addr (match.key->src) || +is_multicast_ether_addr (match.key->src)) { +/* set the mask if a valid src_mac address */ +if (adv_adq_ena) { +ether_addr_copy (m_spec->src_mac, + match.mask->src); + }else { +eth_broadcast_addr (m_spec->src_mac); + }
Quoted 9 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_offload_txtime(struct iecm_vport *vport, · line 2675
Quoted 3 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +3
-0+ether_addr_copy (d_spec->src_mac, + match.key->src); + }All previous ifs had braces, and it way okay since we have multiple nested if- elses, but here we don't have them.
Please either add them here or remove all the way above to keep the code style consistent.
Yes this needs braces will fix.
Quoted 47 lines
Quoted 19 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +19
-0+return 0 ; +} + +/** +* iecm_parse_vlan_header - Parse vlan header fields +* @vport: vport structure +* @field_flags: Cloud filter flags +* @d_spec: Virtchnl structure for L4 specs +* @m_spec: Virtchnl structure for L4 specs +* @rule: Flow rule structure +* +* Return 0 on success, negative on failure */ static int +iecm_parse_vlan_header (struct iecm_vport *vport,u8 *field_flags, +struct virtchnl_l4_spec *d_spec, +struct virtchnl_l4_spec *m_spec, +struct flow_rule *rule) +{ +struct iecm_adapter *adapter = vport->adapter; +struct flow_match_vlan match;drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_offload_txtime(struct iecm_vport *vport,
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+ +flow_rule_match_vlan (rule, &match); +if (match.mask->vlan_id) { +u16 vid = match.key->vlan_id &VLAN_VID_MASK ; +struct iecm_vlan vlan; + + vlan =IECM_VLAN (vid,ETH_P_8021Q ); + +if (match.mask->vlan_id !=VLAN_VID_MASK ) { + dev_err(&adapter->pdev->dev, "Bad vlan mask%u\n",
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_offload_txtime(struct iecm_vport *vport, · line 2719
Quoted 13 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +13
-0+ match.mask->vlan_id); +return -EINVAL ; + } +if (!iecm_is_vlan_tc_filter_allowed (vport, &vlan)) { +dev_err (&adapter->pdev->dev, +"VLAN %u doesn't belong to this VF\n" , + vid); +return -EINVAL ; + } + *field_flags |=IECM_CLOUD_FIELD_IVLAN ; + m_spec->vlan_id =cpu_to_be16 (match.mask->vlan_id); + d_spec->vlan_id =cpu_to_be16 (match.key->vlan_id); + }if (!vlan_id) return 0;
Quoted 2 lines
-1 level.
Will fix.
Quoted 119 lines
Quoted 24 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +24
-0+return 0 ; +} + +/** +* iecm_parse_ipv4_header - Parse ipv4 header fields +* @vport: vport structure +* @field_flags: Cloud filter flags +* @d_spec: Virtchnl structure for L4 specs +* @m_spec: Virtchnl structure for L4 specs +* @rule: Flow rule structure +* +* Return 0 on success, negative on failure */ static int +iecm_parse_ipv4_header (struct iecm_vport *vport,u8 *field_flags, +struct virtchnl_l4_spec *d_spec, +struct virtchnl_l4_spec *m_spec, +struct flow_rule *rule) +{ +struct iecm_adapter *adapter = vport->adapter; +struct flow_match_ipv4_addrs match; +bool adv_adq_ena; + + adv_adq_ena =iecm_is_cap_ena (adapter,IECM_OTHER_CAPS , +VIRTCHNL2_CAP_ADQ ); +drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_offload_txtime(struct iecm_vport *vport,
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+flow_rule_match_ipv4_addrs (rule, &match); + +if (*field_flags &IECM_CLOUD_FIELD_TEN_ID ) { +dev_info (&adapter->pdev->dev, +"Tenant id not allowed for ip filter\n" ); +return -EINVAL ; + } + + if (match.mask->dst) { + if (adv_adq_ena || match.mask->dst ==
cpu_to_be32(0xffffffff)) {drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_offload_txtime(struct iecm_vport *vport,
Quoted 3 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +3
-0+ *field_flags |=IECM_CLOUD_FIELD_IIP ; + }else { + dev_err(&adapter->pdev->dev, "Bad ip dst mask0x%08x\n",
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_offload_txtime(struct iecm_vport *vport,
Quoted 7 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +7
-0+ be32_to_cpu(match.mask->dst)); +return -EINVAL ; + } + } + + if (match.mask->src) { + if (adv_adq_ena || match.mask->src ==
cpu_to_be32(0xffffffff)) {drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_offload_txtime(struct iecm_vport *vport,
Quoted 3 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +3
-0+ *field_flags |=IECM_CLOUD_FIELD_IIP ; + }else { + dev_err(&adapter->pdev->dev, "Bad ip src mask0x%08x\n",
Quoted 36 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +36
-0+ be32_to_cpu(match.mask->dst)); +return -EINVAL ; + } + } + +if (match.key->dst) { +if (adv_adq_ena) + m_spec->dst_ip[0 ] = match.mask->dst; +else + m_spec->dst_ip[0 ] =cpu_to_be32 (0xffffffff ); + d_spec->dst_ip[0 ] = match.key->dst; + } + +if (match.key->src) { +if (adv_adq_ena) + m_spec->src_ip[0 ] = match.mask->src; +else + m_spec->src_ip[0 ] =cpu_to_be32 (0xffffffff ); + d_spec->src_ip[0 ] = match.key->src; + } +return 0 ; +} + +/** +* iecm_parse_ipv6_header - Parse ipv6 header fields +* @vport: vport structure +* @field_flags: Cloud filter flags +* @d_spec: Virtchnl structure for L4 specs +* @m_spec: Virtchnl structure for L4 specs +* @rule: Flow rule structure +* +* Return 0 on success, negative on failure */ static int +iecm_parse_ipv6_header (struct iecm_vport *vport,u8 *field_flags, +struct virtchnl_l4_spec *d_spec, +struct virtchnl_l4_spec *m_spec, +struct flow_rule *rule)drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_offload_txtime(struct iecm_vport *vport,
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+{ +struct iecm_adapter *adapter = vport->adapter; +struct flow_match_ipv6_addrs match; +int i; + +flow_rule_match_ipv6_addrs (rule, &match); + +/* validate mask, make sure it is not IPV6_ADDR_ANY */ +if (ipv6_addr_any (&match.mask->dst)) { + dev_err(&adapter->pdev->dev, "Bad ipv6 dst mask0x%02x\n",
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+ IPV6_ADDR_ANY); +return -EINVAL ; + } + +/* src and dest IPv6 address should not be LOOPBACK +* (0:0:0:0:0:0:0:1) which can be represented as ::1 +*/ +if (ipv6_addr_loopback (&match.key->dst) || +ipv6_addr_loopback (&match.key->src)) { + dev_err(&adapter->pdev->dev,drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_offload_txtime(struct iecm_vport *vport, · line 2881
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+ "ipv6 addr should not be loopback\n"); +return -EINVAL ; + } + +if (!ipv6_addr_any (&match.mask->dst) || + !ipv6_addr_any (&match.mask->src)) + *field_flags |=IECM_CLOUD_FIELD_IIP ; + +/* copy dest IPv6 mask and address */ + if (iecm_is_cap_ena(adapter, IECM_OTHER_CAPS,
VIRTCHNL2_CAP_ADQ)) {
Quoted 9 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_offload_txtime(struct iecm_vport *vport, · line 2842
Quoted 6 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +6
-0+memcpy (&m_spec->dst_ip, &match.mask->dst.s6_addr32, +sizeof (m_spec->dst_ip)); + }else { +for (i =0 ; i <4 ; i++) + m_spec->dst_ip[i] =cpu_to_be32 (0xffffffff ); + }One-liners, no braces needed for both
ifandelse.
Will not fix
Quoted 6 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_offload_txtime(struct iecm_vport *vport, · line 2881
Quoted 5 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +5
-0+memcpy (&d_spec->dst_ip, &match.key->dst.s6_addr32, +sizeof (d_spec->dst_ip)); + +/* copy source IPv6 mask and address */ + if (iecm_is_cap_ena(adapter, IECM_OTHER_CAPS,
VIRTCHNL2_CAP_ADQ)) {
Quoted 9 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_offload_txtime(struct iecm_vport *vport, · line 2853
Quoted 6 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +6
-0+memcpy (&m_spec->src_ip, &match.mask->src.s6_addr32, +sizeof (m_spec->src_ip)); + }else { +for (i =0 ; i <4 ; i++) + m_spec->src_ip[i] =cpu_to_be32 (0xffffffff ); + }Same here.
Will not fix.
Quoted 199 lines
Quoted 22 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +22
-0+memcpy (&d_spec->src_ip, &match.key->src.s6_addr32, +sizeof (d_spec->src_ip)); + +return 0 ; +} + +/** +* iecm_parse_l4_header - Parse l4 header fields +* @vport: vport structure +* @d_spec: Virtchnl structure for L4 specs +* @m_spec: Virtchnl structure for L4 specs +* @rule: Flow rule structure +* +* Return 0 on success, negative on failure */ static int +iecm_parse_l4_header (struct iecm_vport *vport, +struct virtchnl_l4_spec *d_spec, +struct virtchnl_l4_spec *m_spec, +struct flow_rule *rule) +{ +struct iecm_adapter *adapter = vport->adapter; +struct flow_match_ports match; +drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_offload_txtime(struct iecm_vport *vport,
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+flow_rule_match_ports (rule, &match); + +if (match.key->dst) { +if (iecm_is_cap_ena (adapter,IECM_OTHER_CAPS , +VIRTCHNL2_CAP_ADQ ) || + match.mask->dst ==cpu_to_be16 (0xffff )) { + m_spec->dst_port = match.mask->dst; + d_spec->dst_port = match.key->dst; + }else { + dev_err(&adapter->pdev->dev, "Bad dst port mask%u\n",
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_offload_txtime(struct iecm_vport *vport,
Quoted 13 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +13
-0+ be16_to_cpu(match.mask->dst)); +return -EINVAL ; + } + } + +if (match.key->src) { +if (iecm_is_cap_ena (adapter,IECM_OTHER_CAPS , +VIRTCHNL2_CAP_ADQ ) || + match.mask->src ==cpu_to_be16 (0xffff )) { + m_spec->src_port = match.mask->src; + d_spec->src_port = match.key->src; + }else { + dev_err(&adapter->pdev->dev, "Bad src port mask%u\n",
Quoted 25 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +25
-0+ be16_to_cpu(match.mask->src)); +return -EINVAL ; + } + } +return 0 ; +} + +/** +* iecm_parse_cls_flower - Parse tc flower filters provided by kernel +* @vport: vport structure +* @f: pointer to struct flow_cls_offload +* @filter: pointer to cloud filter structure */ static int +iecm_parse_cls_flower (struct iecm_vport *vport, +struct flow_cls_offload *f, +struct iecm_cloud_filter *filter) { +struct flow_rule *rule =flow_cls_offload_flow_rule (f); +struct iecm_adapter *adapter = vport->adapter; +struct virtchnl_l4_spec *d_spec, *m_spec; +struct virtchnl_filter *cf = &filter->f; +struct flow_dissector *dissector; +u8 field_flags =0 ; +u16 addr_type =0 ; +int err; + + dissector = rule->match.dissector;drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_offload_txtime(struct iecm_vport *vport,
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+if (dissector->used_keys & + ~(BIT (FLOW_DISSECTOR_KEY_CONTROL ) | +BIT (FLOW_DISSECTOR_KEY_BASIC ) | +BIT (FLOW_DISSECTOR_KEY_ETH_ADDRS ) | +BIT (FLOW_DISSECTOR_KEY_VLAN ) | +BIT (FLOW_DISSECTOR_KEY_IPV4_ADDRS ) | +BIT (FLOW_DISSECTOR_KEY_IPV6_ADDRS ) | +BIT (FLOW_DISSECTOR_KEY_ENC_KEYID ) | +BIT (FLOW_DISSECTOR_KEY_PORTS ))) { + dev_err(&adapter->pdev->dev, "Unsupported key used:0x%x\n",
Quoted 14 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +14
-0+ dissector->used_keys); +return -EOPNOTSUPP ; + } +if (flow_rule_match_key (rule,FLOW_DISSECTOR_KEY_ENC_KEYID )) +iecm_parse_keyid (rule, &field_flags); + +/* even though following code refers as "tcp_sec", it is not +* just for TCP but a generic struct representing +* L2, L3 + L4 fields if specified +*/ + m_spec = &cf->mask.tcp_spec; + d_spec = &cf->data.tcp_spec; + +/* determine flow type, TCP/UDP_V4[6]_FLOW based on drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_offload_txtime(struct iecm_vport *vport,
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+* L2 proto (aka ETH proto) and L3 proto (aka IP_PROTO) +*/ +if (flow_rule_match_key (rule,FLOW_DISSECTOR_KEY_BASIC )) { + err =iecm_parse_flow_type (vport, rule, cf, filter); +if (err) +return err; + } + +/* process Ethernet header fields */ +if (flow_rule_match_key (rule,FLOW_DISSECTOR_KEY_ETH_ADDRS )){
Quoted 55 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +55
-0+ err =iecm_parse_ether_header (vport, &field_flags, + d_spec, m_spec, rule); +if (err) +return err; + } + +/* process VLAN header for single VLAN (type could be S/C-tag) */ +if (flow_rule_match_key (rule,FLOW_DISSECTOR_KEY_VLAN )) { + err =iecm_parse_vlan_header (vport, &field_flags, + d_spec, m_spec, rule); +if (err) +return err; + } + +if (flow_rule_match_key (rule,FLOW_DISSECTOR_KEY_CONTROL )) { +struct flow_match_control match; + +flow_rule_match_control (rule, &match); + addr_type = match.key->addr_type; + } + +/* process IPv4 header */ +if (addr_type ==FLOW_DISSECTOR_KEY_IPV4_ADDRS ) { + err =iecm_parse_ipv4_header (vport, &field_flags, + d_spec, m_spec, rule); +if (err) +return err; + } + +/* process IPv6 header */ +if (addr_type ==FLOW_DISSECTOR_KEY_IPV6_ADDRS ) { + err =iecm_parse_ipv6_header (vport, &field_flags, + d_spec, m_spec, rule); +if (err) +return err; + } + +/* process L4 header, supported L4 protocols are TCP and UDP */ +if (flow_rule_match_key (rule,FLOW_DISSECTOR_KEY_PORTS )) { + err =iecm_parse_l4_header (vport, d_spec, m_spec, rule); +if (err) +return err; + } + cf->field_flags = field_flags; + +return 0 ; +} + +/** +* iecm_handle_tclass - Forward to a traffic class on the device +* @vport: vport structure +* @tc: traffic class index on the device +* @filter: pointer to cloud filter structure +* + * Return 0 on success, negative on failure */ static intdrivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_offload_txtime(struct iecm_vport *vport,
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+iecm_handle_tclass(struct iecm_vport *vport, int tc, + struct iecm_cloud_filter *filter) { + struct iecm_adapter *adapter = vport->adapter; + +if (tc ==0 ) +return 0 ; +if ((!iecm_is_adq_v2_ena (vport)) && + !filter->f.data.tcp_spec.dst_port) { + dev_err(&adapter->pdev->dev, + "Specify destination port to redirect to traffic classother than TC0\n");
Quoted 25 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +25
-0+return -EINVAL ; + } +/* redirect to a traffic class on the same device */ + filter->f.action =VIRTCHNL_ACTION_TC_REDIRECT ; + filter->f.action_meta = tc; +return 0 ; +} + +/* iecm_find_cf - Find the cloud filter in the list +* @vport: vport structure +* @cookie: filter specific cookie +* +* Returns pointer to the filter object or NULL. Must be called while +holding +* cloud_filter_list_lock. +*/ +static struct iecm_cloud_filter *iecm_find_cf (struct iecm_vport *vport, +unsigned long *cookie) +{ +struct iecm_adapter *adapter = vport->adapter; +struct iecm_cloud_filter *filter =NULL ; + +if (!cookie) +return NULL ; +
Quoted 9 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_offload_txtime(struct iecm_vport *vport, · line 3058
Quoted 6 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +6
-0+list_for_each_entry (filter, + &adapter->config_data.cf_config.cloud_filter_list, + list) { +if (!memcmp (cookie, &filter->cookie,sizeof (filter->cookie))) +return filter; + }Redundant braces round single statement.
Will not fix.
Quoted 151 lines
Quoted 18 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +18
-0+return NULL ; +} + +/** +* iecm_configure_clsflower - Add tc flower filters +* @vport: vport structure +* @cls_flower: Pointer to struct flow_cls_offload +* +* Return 0 on success, negative on failure */ static int +iecm_configure_clsflower (struct iecm_vport *vport, +struct flow_cls_offload *cls_flower) { +struct iecm_adapter *adapter = vport->adapter; +struct iecm_user_config_data *config_data; +struct iecm_cloud_filter *filter =NULL ; +int err; +int tc; + + config_data = &adapter->config_data;drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_offload_txtime(struct iecm_vport *vport, · line 3094
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+ tc =tc_classid_to_hwtc (vport->netdev, cls_flower->classid); +if (tc <0 ) { +dev_err (&adapter->pdev->dev,"Invalid traffic class\n" ); +return -EINVAL ; + } + +#define IECM_MAX_CLOUD_ADQ_FILTERS 128 + + if (config_data->cf_config.num_cloud_filters >= +IECM_MAX_CLOUD_ADQ_FILTERS) {drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_offload_txtime(struct · line 3077
Quoted 2 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +2
-0+ dev_err(&adapter->pdev->dev, + "Unable to add filter (action is forward to TC),reached max allowed filters (%u)\n",
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_offload_txtime(struct iecm_vport *vport,
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+ IECM_MAX_CLOUD_ADQ_FILTERS); +return -ENOSPC ; + } + +/* bail out here if filter already exists */ +spin_lock_bh (&adapter->cloud_filter_list_lock); + filter =iecm_find_cf (vport, &cls_flower->cookie); +if (filter) { + filter->remove = false; + dev_err(&adapter->pdev->dev, "Failed to add TC Flowerfilter, it already exists\n");
Quoted 68 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +68
-0+spin_unlock_bh (&adapter->cloud_filter_list_lock); +return -EEXIST ; + } +spin_unlock_bh (&adapter->cloud_filter_list_lock); + + filter =kzalloc (sizeof (*filter),GFP_KERNEL ); +if (!filter) +return -ENOMEM ; + + filter->cookie = cls_flower->cookie; + +/* set the mask to all zeroes to begin with */ +memset (&filter->f.mask.tcp_spec,0 ,sizeof (struct +virtchnl_l4_spec )); + +/* start out with flow type and eth type IPv4 to begin with */ + filter->f.flow_type =VIRTCHNL_TCP_V4_FLOW ; + err =iecm_parse_cls_flower (vport, cls_flower, filter); +if (err) + goto error; + + err =iecm_handle_tclass (vport, tc, filter); +if (err) + goto error; + +/* add filter to the list */ +spin_lock_bh (&adapter->cloud_filter_list_lock); +list_add_tail (&filter->list, &config_data->cf_config.cloud_filter_list); + filter->add = true; +spin_unlock_bh (&adapter->cloud_filter_list_lock); + err =iecm_send_add_del_cloud_filter_msg (vport, true); +spin_lock_bh (&adapter->cloud_filter_list_lock); +/* We have to find it again in case another thread has already +* deleted and kfreed it. +*/ + filter =iecm_find_cf (vport, &cls_flower->cookie); +if (filter && err) { +list_del (&filter->list); +spin_unlock_bh (&adapter->cloud_filter_list_lock); + goto error; + } +spin_unlock_bh (&adapter->cloud_filter_list_lock); + + config_data->cf_config.num_cloud_filters++; +error: +if (err) +kfree (filter); +return err; +} + +/** +* iecm_delete_clsflower - Remove tc flower filters +* @vport: vport structure +* @cls_flower: Pointer to struct flow_cls_offload +* +* Return 0 on success, negative on failure */ static int +iecm_delete_clsflower (struct iecm_vport *vport, +struct flow_cls_offload *cls_flower) { +struct iecm_adapter *adapter = vport->adapter; +struct iecm_cloud_filter *filter =NULL ; +int err =0 ; + +spin_lock_bh (&adapter->cloud_filter_list_lock); + filter =iecm_find_cf (vport, &cls_flower->cookie); +if (filter) { + filter->remove = true; + adapter->config_data.cf_config.num_cloud_filters--; + }else if (adapter->config_data.cf_config.num_cloud_filters) {drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_offload_txtime(struct iecm_vport *vport,
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+/* "num_cloud_filters" can become zero if egress qdisc is +* detached as per design, driver deletes related filters +* when qdisc is detached to avoid stale filters, hence +* num_cloud_filters can become zero. But since netdev +* layer doesn't know that filters are deleted by driver +* implictly when egress qdisc is deleted, it sees filters +* being present and "in_hw". User can request delete +* of specific filter of detach ingress qdisc - in either of +* those operation, filter(s) won't be found in driver cache, +* hence instead of returning, let this function return SUCCESS
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_offload_txtime(struct iecm_vport *vport,
Quoted 12 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +12
-0+* Returning of err as -EINVAL is only applicable when +* unable to find filter and num_cloud_filters is non-zero +*/ + err = -EINVAL ; + } +spin_unlock_bh (&adapter->cloud_filter_list_lock); + +if (filter) { + err =iecm_send_add_del_cloud_filter_msg (vport, false); +spin_lock_bh (&adapter->cloud_filter_list_lock); +/* It can happen that asynchronously the filter was already +* deleted from the list. Make sure it's still there and marked
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_offload_txtime(struct iecm_vport *vport, · line 3201
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+* for remove under spinlock before actually trying to delete +* from list. +*/ + filter =iecm_find_cf (vport, &cls_flower->cookie); +if (filter) { +list_del (&filter->list); +kfree (filter); + } +spin_unlock_bh (&adapter->cloud_filter_list_lock); + }if (!filter) return err; err = ...
Quoted 2 lines
-1 level.
Will fix.
Quoted 41 lines
Quoted 30 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +30
-0+return err; +} + +/** +* iecm_setup_tc_cls_flower - flower classifier offloads +* @vport: vport structure +* @cls_flower: pointer to struct flow_cls_offload +* +* Return 0 on success, negative on failure */ static int +iecm_setup_tc_cls_flower (struct iecm_vport *vport, +struct flow_cls_offload *cls_flower) { +if (cls_flower->common.chain_index) +return -EOPNOTSUPP ; + +switch (cls_flower->command) { +case FLOW_CLS_REPLACE : +return iecm_configure_clsflower (vport, cls_flower); +case FLOW_CLS_DESTROY : +return iecm_delete_clsflower (vport, cls_flower); +case FLOW_CLS_STATS : +return -EOPNOTSUPP ; +default : +return -EINVAL ; + } +} + +/** +* iecm_setup_tc_block_cb - block callback for tc +* @type: type of offload +* @type_data: offload data drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_offload_txtime(struct iecm_vport *vport,
Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10
-0+* @cb_priv: Private adapter structure +* +* This function is the block callback for traffic classes +* Return 0 on success, negative on failure **/ static int +iecm_setup_tc_block_cb (enum tc_setup_type type,void *type_data, +void *cb_priv) +{ +switch (type) { +case TC_SETUP_CLSFLOWER : + return iecm_setup_tc_cls_flower((struct iecm_vport*)cb_priv,
Quoted 6 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_offload_txtime(struct iecm_vport *vport, · line 3246
Quoted 2 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +2
-0+ (struct flow_cls_offload *) + type_data);Just dereference them in separate variables and they will fit into one line. There shouldn't be any spaces or line breaks after a cast.
Will take a look.
Quoted 66 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_offload_txtime(struct iecm_vport *vport,
Quoted 11 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +11
-0+default : +return -EOPNOTSUPP ; + } +} + +/** +* iecm_del_all_cloud_filters - delete all cloud filters on the +traffic classes +* @vport: vport structure +* +* This function will loop through the list of cloud filters and deletes them.
drivers/net/ethernet/intel/iecm/iecm_lib.c static int __iecm_setup_tc(struct iecm_vport
Quoted 22 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +18
-0+**/ +static void iecm_del_all_cloud_filters (struct iecm_vport *vport) { +struct iecm_adapter *adapter = vport->adapter; +struct iecm_cloud_filter_config *cf_config; +struct iecm_cloud_filter *cf, *cftmp; + + cf_config = &adapter->config_data.cf_config; +spin_lock_bh (&adapter->cloud_filter_list_lock); +list_for_each_entry_safe (cf, cftmp, + &cf_config->cloud_filter_list, + list) { +list_del (&cf->list); +kfree (cf); + cf_config->num_cloud_filters--; + } +spin_unlock_bh (&adapter->cloud_filter_list_lock); +} +/** * iecm_validate_tx_bandwidth - validate the max Tx bandwidth * @vport: vport structure @@ -2596,6 +3480,7 @@ static int __iecm_setup_tc(struct iecm_vport*vport, void
*type_data)drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device
Quoted 20 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +1
-0netif_tx_stop_all_queues (netdev);netif_tx_disable (netdev); ret =iecm_send_disable_channels_msg (vport); +iecm_del_all_cloud_filters (vport);netif_tx_start_all_queues (netdev); if (!test_bit(__IECM_REL_RES_IN_PROG, adapter-flags) &&
drivers/net/ethernet/intel/iecm/iecm_lib.c +2
-0!ret) {@@ -2709,8 +3594,10 @@ static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, {struct iecm_vport *vport =iecm_netdev_to_vport (netdev);struct iecm_adapter *adapter = vport->adapter; +struct iecm_cloud_filter_config *cf_config;int err =0 ; + cf_config = &adapter->config_data.cf_config;switch (type) {case TC_SETUP_QDISC_ETF :if (iecm_is_queue_model_split (vport->txq_model))@@ -2720,6 +3607,17 @@ static int iecm_setup_tc(struct net_device*netdev, enum
tc_setup_typetype,drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type,
Quoted 9 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +6
-0type_data);break ;case TC_SETUP_BLOCK : +if (iecm_is_cap_ena (adapter,IECM_BASE_CAPS , +VIRTCHNL2_CAP_ADQ ) || +iecm_is_cap_ena (adapter,IECM_OTHER_CAPS , +VIRTCHNL2_CAP_ADQ )) { + err = + flow_block_cb_setup_simple((struct
flow_block_offload*)
Quoted 9 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 3620
Quoted 5 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +5
-0+ type_data, + &cf_config->block_cb_list, + iecm_setup_tc_block_cb, + vport, vport, true); + }Invert the condition, and there'll be no line wraps (esp. if you assign casted @type_data into a separate var).
Will fix
Quoted 45 lines
drivers/net/ethernet/intel/iecm/iecm_virtchnl.c static int iecm_send_insert_vlan_msg(struct
Quoted 9 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +0
-0break ;case TC_SETUP_QDISC_MQPRIO : if (iecm_is_cap_ena(adapter, IECM_BASE_CAPS, diff --git
a/drivers/net/ethernet/intel/iecm/iecm_virtchnl.cb/drivers/net/ethernet/intel/iecm/iecm_virtchnl.c
index5601846b4674..94af45c36866100644drivers/net/ethernet/intel/iecm/iecm_virtchnl.c +0
-0@@ -2731,6 +2731,74 @@ static int iecm_send_insert_vlan_msg(struct
iecm_vport*vport, bool ena)Quoted 35 lines
drivers/net/ethernet/intel/iecm/iecm_virtchnl.c +32
-0return err; } +/** +* iecm_send_add_del_cloud_filter_msg: Send add/del cloud filter +message +* @vport: vport structure +* @add: True to add, false to delete cloud filter +* +* Request the CP/PF to add/del cloud filters as specified by the +user via +* tc tool +* +* Return 0 on success, negative on failure **/ int +iecm_send_add_del_cloud_filter_msg (struct iecm_vport *vport,bool +add) { +struct iecm_adapter *adapter = vport->adapter; +struct iecm_cloud_filter_config *cf_config; +struct iecm_cloud_filter *cf; +struct virtchnl_filter f; +int len =0 , err =0 ; + + cf_config = &adapter->config_data.cf_config; + +while (true) { +bool process_fltr = false; + +spin_lock_bh (&adapter->cloud_filter_list_lock); +list_for_each_entry (cf, &cf_config->cloud_filter_list, list) { +if (add && cf->add) { + process_fltr = true; + cf->add = false; + f = cf->f; +break ; + }else if (!add && cf->remove) {
Quoted 8 lines
drivers/net/ethernet/intel/iecm/iecm_virtchnl.c static int iecm_send_insert_vlan_msg(struct iecm_vport *vport, bool ena) · line 2770
Quoted 6 lines
drivers/net/ethernet/intel/iecm/iecm_virtchnl.c +6
-0+ process_fltr = true; + cf->remove = false; + f = cf->f; +break ; + } + }Redundant braces.
Will not fix.
Quoted 80 lines
drivers/net/ethernet/intel/iecm/iecm_virtchnl.c static int iecm_send_insert_vlan_msg(struct · line 2774
Quoted 4 lines
drivers/net/ethernet/intel/iecm/iecm_virtchnl.c +3
-0+spin_unlock_bh (&adapter->cloud_filter_list_lock); + +/* Don't send mailbox message when there are no filters to add/del */
drivers/net/ethernet/intel/iecm/iecm_virtchnl.c static int iecm_send_insert_vlan_msg(struct iecm_vport *vport, bool ena)
Quoted 5 lines
drivers/net/ethernet/intel/iecm/iecm_virtchnl.c +5
-0+if (!process_fltr) + goto error; + +if (add) { + err = iecm_send_mb_msg(adapter,
VIRTCHNL_OP_ADD_CLOUD_FILTER,drivers/net/ethernet/intel/iecm/iecm_virtchnl.c static int iecm_send_insert_vlan_msg(struct iecm_vport *vport, bool ena)
Quoted 5 lines
drivers/net/ethernet/intel/iecm/iecm_virtchnl.c +5
-0+ len, (u8 *)&f); +if (err) + goto error; + + err = iecm_wait_for_event(adapter,
IECM_VC_ADD_CLOUD_FILTER,drivers/net/ethernet/intel/iecm/iecm_virtchnl.c static int iecm_send_insert_vlan_msg(struct · line 2785
Quoted 1 line
drivers/net/ethernet/intel/iecm/iecm_virtchnl.c +1
-0+
IECM_VC_ADD_CLOUD_FILTER_ERR);drivers/net/ethernet/intel/iecm/iecm_virtchnl.c static int iecm_send_insert_vlan_msg(struct · line 2787
Quoted 2 lines
drivers/net/ethernet/intel/iecm/iecm_virtchnl.c +2
-0+ }else { + err = iecm_send_mb_msg(adapter,
VIRTCHNL_OP_DEL_CLOUD_FILTER,drivers/net/ethernet/intel/iecm/iecm_virtchnl.c static int iecm_send_insert_vlan_msg(struct iecm_vport *vport, bool ena)
Quoted 6 lines
drivers/net/ethernet/intel/iecm/iecm_virtchnl.c +6
-0+ len, (u8 *)&f); +if (err) + goto error; + + err = + iecm_min_wait_for_event(adapter,
IECM_VC_DEL_CLOUD_FILTER,drivers/net/ethernet/intel/iecm/iecm_virtchnl.c static int iecm_send_insert_vlan_msg(struct · line 2794
Quoted 1 line
drivers/net/ethernet/intel/iecm/iecm_virtchnl.c +1
-0+IECM_VC_DEL_CLOUD_FILTER_ERR);Too long lines here.
Quoted 28 lines
drivers/net/ethernet/intel/iecm/iecm_virtchnl.c +8
-0+ } +if (err) +break ; + } +error: +return err; +} +/** * iecm_send_add_fdir_filter_msg: Send add Flow Director filter message * @vport: vport structure drivers/net/ethernet/intel/include/iecm.h +8
-0@@ -403,6 +403,28 @@ enum iecm_user_flags { __IECM_USER_FLAGS_NBITS, }; +#define IECM_CLOUD_FIELD_OMAC BIT(0) +#define IECM_CLOUD_FIELD_IMAC BIT(1) +#define IECM_CLOUD_FIELD_IVLAN BIT(2) +#define IECM_CLOUD_FIELD_TEN_ID BIT(3) +#define IECM_CLOUD_FIELD_IIP BIT(4) + +#define IECM_START_CHNL_TC 1 +drivers/net/ethernet/intel/include/iecm.h enum iecm_user_flags { · line 423
Quoted 10 lines
drivers/net/ethernet/intel/include/iecm.h +10
-0+struct iecm_cloud_filter { +struct list_head list; +struct virtchnl_filter f; +unsigned long cookie; +bool remove;/* filter needs to be deleted */ +bool add;/* filter needs to be added */ +}; + +struct iecm_cloud_filter_config { +struct list_head block_cb_list;/* need to pass this to stack */
drivers/net/ethernet/intel/include/iecm.h enum iecm_user_flags {
Quoted 6 lines
drivers/net/ethernet/intel/include/iecm.h +4
-0+struct list_head cloud_filter_list; +u16 num_cloud_filters; +}; +struct iecm_channel_config {struct virtchnl_channel_info ch_info[VIRTCHNL_MAX_ADQ_V2_CHANNELS];
Quoted 10 lines
drivers/net/ethernet/intel/include/iecm.h struct iecm_ptype_state { · line 561
Quoted 6 lines
drivers/net/ethernet/intel/include/iecm.h +1
-0bool tc_running;@@ -536,6 +558,7 @@ struct iecm_ptype_state {bool outer_frag;u8 tunnel_state; }; +Please move this newline into the patch where
iecm_ptype_statewas introduced, it doesn't belong here.
Will fix
Quoted 27 lines
drivers/net/ethernet/intel/include/iecm.h struct iecm_ptype_state { · line 564
Quoted 3 lines
drivers/net/ethernet/intel/include/iecm.h +0
-0/* User defined configuration values */ struct iecm_user_config_data {u32 num_req_tx_qs;/* user requested TX queues through ethtool */ @@
Quoted 9 lines
-550,6 +573,7 @@ struct
iecm_user_config_data{drivers/net/ethernet/intel/include/iecm.h +1
-0struct list_head vlan_filter_list;struct list_head adv_rss_list;struct iecm_fdir_fltr_config fdir_config; +struct iecm_cloud_filter_config cf_config;struct iecm_channel_config ch_config; };@@ -853,6 +877,7 @@ void iecm_set_ethtool_ops(struct net_device *netdev); void iecm_vport_set_hsplit(struct iecm_vport *vport, boolQuoted 4 lines
ena); void
iecm_add_del_ether_addrs(struct iecm_vport *vport, bool add, bool async); intiecm_set_promiscuous(struct iecm_adapter *adapter);
+int iecm_send_add_del_cloud_filter_msg(structiecm_vport*vport,bool
Quoted 6 lines
+add);
intiecm_send_add_fdir_filter_msg(struct iecm_vport *vport); intiecm_send_del_fdir_filter_msg(struct iecm_vport *vport); int iecm_get_fdir_fltr_entry(structiecm_vport*vport,
--
2.33.0Thanks,
Al
PATCH 18/19 iecm: add advanced rss
In reply to Alan BradyFrom: Haiyue Wang <[email protected]>
Continuing with advanced features this implements what's needed to do advanced rss.
--- drivers/net/ethernet/intel/iecm/iecm_lib.c | 547 ++++++++++++++++++ .../net/ethernet/intel/iecm/iecm_virtchnl.c | 71 +++ drivers/net/ethernet/intel/include/iecm.h | 73 +++ 3 files changed, 691 insertions(+)
drivers/net/ethernet/intel/iecm/iecm_lib.c +547 -0
@@ -1013,6 +1013,52 @@ static void iecm_remove_vlan_filters(struct iecm_vport *vport) } } +/** +* iecm_remove_adv_rss_cfgs - Remove all RSS configuration +* @vport: vport structure +*/ +static void iecm_remove_adv_rss_cfgs (struct iecm_vport *vport) +{ +struct iecm_adapter *adapter = vport->adapter; + +if (!iecm_is_cap_ena (adapter,IECM_OTHER_CAPS ,VIRTCHNL2_CAP_ADV_RSS )) +return ; + +if (!list_empty (&adapter->config_data.adv_rss_list)) { +struct iecm_adv_rss *rss; + +spin_lock_bh (&adapter->adv_rss_list_lock); +list_for_each_entry (rss, &adapter->config_data.adv_rss_list, + list) { + rss->remove = true; + } +spin_unlock_bh (&adapter->adv_rss_list_lock); +iecm_send_add_del_adv_rss_cfg_msg (vport, false); + } +} + +/** +* iecm_del_all_adv_rss_cfgs - delete all RSS configuration +* @vport: vport structure +* +* This function will loop through the list of RSS configuration and deletes +* them. +**/ +static void iecm_del_all_adv_rss_cfgs (struct iecm_vport *vport) +{ +struct iecm_adapter *adapter = vport->adapter; +struct iecm_adv_rss *rss, *rss_tmp; + +spin_lock_bh (&adapter->adv_rss_list_lock); +list_for_each_entry_safe (rss, rss_tmp, + &adapter->config_data.adv_rss_list, + list) { +list_del (&rss->list); +kfree (rss); + } +spin_unlock_bh (&adapter->adv_rss_list_lock); +} +/** * iecm_remove_fdir_filters - Remove all Flow Director filters * @vport: vport structure
@@ -1099,6 +1145,7 @@ static void iecm_vport_stop(struct iecm_vport *vport)iecm_remove_vlan_filters (vport); } +iecm_remove_adv_rss_cfgs (vport);iecm_remove_fdir_filters (vport); adapter->link_up = false;
@@ -1332,6 +1379,27 @@ static void iecm_restore_cloud_filters(struct iecm_vport *vport) } } +/** +* iecm_restore_adv_rss_cfgs - Restore all RSS configuration +* @vport: vport structure +*/ +static void iecm_restore_adv_rss_cfgs (struct iecm_vport *vport) +{ +struct iecm_adapter *adapter = vport->adapter; + +if (!list_empty (&adapter->config_data.adv_rss_list)) { +struct iecm_adv_rss *rss; + +spin_lock_bh (&adapter->adv_rss_list_lock); +list_for_each_entry (rss, &adapter->config_data.adv_rss_list, + list) { + rss->add = true; + } +spin_unlock_bh (&adapter->adv_rss_list_lock); +iecm_send_add_del_adv_rss_cfg_msg (vport, true); + } +} +/** * iecm_restore_fdir_filters - Restore all Flow Director filters * @vport: vport structure
@@ -1380,6 +1448,9 @@ static void iecm_restore_features(struct iecm_vport *vport)if (iecm_is_feature_ena (vport,NETIF_F_HW_TC ))iecm_restore_cloud_filters (vport); +if (iecm_is_cap_ena (adapter,IECM_OTHER_CAPS ,VIRTCHNL2_CAP_ADV_RSS )) +iecm_restore_adv_rss_cfgs (vport); +if (iecm_is_cap_ena (adapter,IECM_OTHER_CAPS ,VIRTCHNL2_CAP_FDIR ))iecm_restore_fdir_filters (vport); }
@@ -2219,6 +2290,7 @@ static void iecm_del_user_cfg_data(struct iecm_adapter *adapter)if (!adapter->vports[i])continue ; +iecm_del_all_adv_rss_cfgs (adapter->vports[i]);iecm_del_all_fdir_filters (adapter->vports[i]); } }
@@ -3633,6 +3705,481 @@ static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type,return err; } +/** +* iecm_fill_adv_rss_ip4_hdr - fill the IPv4 RSS protocol header +* @hdr: the virtchnl message protocol header data structure +* @hash_flds: the RSS configuration protocol hash fields +*/ +static void +iecm_fill_adv_rss_ip4_hdr (struct virtchnl_proto_hdr *hdr,u64 hash_flds) +{ +VIRTCHNL_SET_PROTO_HDR_TYPE (hdr,IPV4 ); + +if (hash_flds &IECM_ADV_RSS_HASH_FLD_IPV4_SA ) +VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (hdr,IPV4 ,SRC ); + +if (hash_flds &IECM_ADV_RSS_HASH_FLD_IPV4_DA ) +VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (hdr,IPV4 ,DST ); +} + +/** +* iecm_fill_adv_rss_ip6_hdr - fill the IPv6 RSS protocol header +* @hdr: the virtchnl message protocol header data structure +* @hash_flds: the RSS configuration protocol hash fields +*/ +static void +iecm_fill_adv_rss_ip6_hdr (struct virtchnl_proto_hdr *hdr,u64 hash_flds) +{ +VIRTCHNL_SET_PROTO_HDR_TYPE (hdr,IPV6 ); + +if (hash_flds &IECM_ADV_RSS_HASH_FLD_IPV6_SA ) +VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (hdr,IPV6 ,SRC ); + +if (hash_flds &IECM_ADV_RSS_HASH_FLD_IPV6_DA ) +VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (hdr,IPV6 ,DST ); +} + +/** +* iecm_fill_adv_rss_tcp_hdr - fill the TCP RSS protocol header +* @hdr: the virtchnl message protocol header data structure +* @hash_flds: the RSS configuration protocol hash fields +*/ +static void +iecm_fill_adv_rss_tcp_hdr (struct virtchnl_proto_hdr *hdr,u64 hash_flds) +{ +VIRTCHNL_SET_PROTO_HDR_TYPE (hdr,TCP ); + +if (hash_flds &IECM_ADV_RSS_HASH_FLD_TCP_SRC_PORT ) +VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (hdr,TCP ,SRC_PORT ); + +if (hash_flds &IECM_ADV_RSS_HASH_FLD_TCP_DST_PORT ) +VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (hdr,TCP ,DST_PORT ); +} + +/** +* iecm_fill_adv_rss_udp_hdr - fill the UDP RSS protocol header +* @hdr: the virtchnl message protocol header data structure +* @hash_flds: the RSS configuration protocol hash fields +*/ +static void +iecm_fill_adv_rss_udp_hdr (struct virtchnl_proto_hdr *hdr,u64 hash_flds) +{ +VIRTCHNL_SET_PROTO_HDR_TYPE (hdr,UDP ); + +if (hash_flds &IECM_ADV_RSS_HASH_FLD_UDP_SRC_PORT ) +VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (hdr,UDP ,SRC_PORT ); + +if (hash_flds &IECM_ADV_RSS_HASH_FLD_UDP_DST_PORT ) +VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (hdr,UDP ,DST_PORT ); +} + +/** +* iecm_fill_adv_rss_sctp_hdr - fill the SCTP RSS protocol header +* @hdr: the virtchnl message protocol header data structure +* @hash_flds: the RSS configuration protocol hash fields +*/ +static void +iecm_fill_adv_rss_sctp_hdr (struct virtchnl_proto_hdr *hdr,s64 hash_flds) +{ +VIRTCHNL_SET_PROTO_HDR_TYPE (hdr,SCTP ); + +if (hash_flds &IECM_ADV_RSS_HASH_FLD_SCTP_SRC_PORT ) +VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (hdr,SCTP ,SRC_PORT ); + +if (hash_flds &IECM_ADV_RSS_HASH_FLD_SCTP_DST_PORT ) +VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (hdr,SCTP ,DST_PORT ); +} + +/** +* iecm_fill_adv_rss_cfg_msg - fill the RSS configuration into virtchnl message +* @rss_cfg: the virtchnl message to be filled with RSS configuration setting +* @packet_hdrs: the RSS configuration protocol header types +* @hash_flds: the RSS configuration protocol hash fields +* +* Returns 0 if the RSS configuration virtchnl message is filled successfully +*/ +static int +iecm_fill_adv_rss_cfg_msg (struct virtchnl_rss_cfg *rss_cfg, +u32 packet_hdrs,u64 hash_flds) +{ +struct virtchnl_proto_hdrs *proto_hdrs = &rss_cfg->proto_hdrs; +struct virtchnl_proto_hdr *hdr; + + rss_cfg->rss_algorithm =VIRTCHNL_RSS_ALG_TOEPLITZ_ASYMMETRIC ; + + proto_hdrs->tunnel_level =0 ;/* always outer layer */ + + hdr = &proto_hdrs->proto_hdr[proto_hdrs->count++]; +switch (packet_hdrs &IECM_ADV_RSS_FLOW_SEG_HDR_L3 ) { +case IECM_ADV_RSS_FLOW_SEG_HDR_IPV4 : +iecm_fill_adv_rss_ip4_hdr (hdr, hash_flds); +break ; +case IECM_ADV_RSS_FLOW_SEG_HDR_IPV6 : +iecm_fill_adv_rss_ip6_hdr (hdr, hash_flds); +break ; +default : +return -EINVAL ; + } + + hdr = &proto_hdrs->proto_hdr[proto_hdrs->count++]; +switch (packet_hdrs &IECM_ADV_RSS_FLOW_SEG_HDR_L4 ) { +case IECM_ADV_RSS_FLOW_SEG_HDR_TCP : +iecm_fill_adv_rss_tcp_hdr (hdr, hash_flds); +break ; +case IECM_ADV_RSS_FLOW_SEG_HDR_UDP : +iecm_fill_adv_rss_udp_hdr (hdr, hash_flds); +break ; +case IECM_ADV_RSS_FLOW_SEG_HDR_SCTP : +iecm_fill_adv_rss_sctp_hdr (hdr, hash_flds); +break ; +default : +return -EINVAL ; + } + +return 0 ; +} + +/** +* iecm_find_adv_rss_cfg_by_hdrs - find RSS configuration with header type +* @vport: vport structure +* @packet_hdrs: protocol header type to find. +* +* Returns pointer to advance RSS configuration if found or null +*/ +static struct iecm_adv_rss * +iecm_find_adv_rss_cfg_by_hdrs (struct iecm_vport *vport,u32 packet_hdrs) +{ +struct iecm_adapter *adapter = vport->adapter; +struct iecm_adv_rss *rss; + +list_for_each_entry (rss, &adapter->config_data.adv_rss_list, list) +if (rss->packet_hdrs == packet_hdrs) +return rss; + +return NULL ; +} + +/** +* iecm_dump_adv_rss_cfg_info +* @vport: vport structure +* @packet_hdrs: The protocol headers for RSS configuration +* @hash_flds: The protocol hash fields for RSS configuration +* @prefix: the prefix string description to dump the RSS +* @postfix: the postfix string description to dump the RSS +* +* Dump the advance RSS configuration +**/ +static void +iecm_dump_adv_rss_cfg_info (struct iecm_vport *vport, +u32 packet_hdrs,u64 hash_flds, +const char *prefix,const char *postfix) +{ +static char hash_opt[300 ]; +const char *proto; + +if (packet_hdrs &IECM_ADV_RSS_FLOW_SEG_HDR_TCP ) + proto ="TCP" ; +else if (packet_hdrs &IECM_ADV_RSS_FLOW_SEG_HDR_UDP ) + proto ="UDP" ; +else if (packet_hdrs &IECM_ADV_RSS_FLOW_SEG_HDR_SCTP ) + proto ="SCTP" ; +else +return ; + +memset (hash_opt,0 ,sizeof (hash_opt)); + +strcat (hash_opt, proto); +if (packet_hdrs &IECM_ADV_RSS_FLOW_SEG_HDR_IPV4 ) +strcat (hash_opt,"v4 " ); +else +strcat (hash_opt,"v6 " ); + +if (hash_flds & (IECM_ADV_RSS_HASH_FLD_IPV4_SA | +IECM_ADV_RSS_HASH_FLD_IPV6_SA )) +strcat (hash_opt,"[IP SA] " ); +if (hash_flds & (IECM_ADV_RSS_HASH_FLD_IPV4_DA | +IECM_ADV_RSS_HASH_FLD_IPV6_DA )) +strcat (hash_opt,"[IP DA] " ); +if (hash_flds & (IECM_ADV_RSS_HASH_FLD_TCP_SRC_PORT | +IECM_ADV_RSS_HASH_FLD_UDP_SRC_PORT | +IECM_ADV_RSS_HASH_FLD_SCTP_SRC_PORT )) +strcat (hash_opt,"[src port] " ); +if (hash_flds & (IECM_ADV_RSS_HASH_FLD_TCP_DST_PORT | +IECM_ADV_RSS_HASH_FLD_UDP_DST_PORT | +IECM_ADV_RSS_HASH_FLD_SCTP_DST_PORT )) +strcat (hash_opt,"[dst port] " ); + +if (!prefix) + prefix ="" ; + +if (!postfix) + postfix ="" ; + +dev_info (&vport->adapter->pdev->dev,"%s %s %s\n" , + prefix, hash_opt, postfix); +} + +/** +* iecm_adv_rss_parse_hdrs - parses headers from RSS hash input +* @cmd: ethtool rxnfc command +* +* This function parses the rxnfc command and returns intended +* header types for RSS configuration +*/ +static u32 iecm_adv_rss_parse_hdrs (struct ethtool_rxnfc *cmd) +{ +u32 hdrs =IECM_ADV_RSS_FLOW_SEG_HDR_NONE ; + +switch (cmd->flow_type) { +case TCP_V4_FLOW : + hdrs |=IECM_ADV_RSS_FLOW_SEG_HDR_TCP | +IECM_ADV_RSS_FLOW_SEG_HDR_IPV4 ; +break ; +case UDP_V4_FLOW : + hdrs |=IECM_ADV_RSS_FLOW_SEG_HDR_UDP | +IECM_ADV_RSS_FLOW_SEG_HDR_IPV4 ; +break ; +case SCTP_V4_FLOW : + hdrs |=IECM_ADV_RSS_FLOW_SEG_HDR_SCTP | +IECM_ADV_RSS_FLOW_SEG_HDR_IPV4 ; +break ; +case TCP_V6_FLOW : + hdrs |=IECM_ADV_RSS_FLOW_SEG_HDR_TCP | +IECM_ADV_RSS_FLOW_SEG_HDR_IPV6 ; +break ; +case UDP_V6_FLOW : + hdrs |=IECM_ADV_RSS_FLOW_SEG_HDR_UDP | +IECM_ADV_RSS_FLOW_SEG_HDR_IPV6 ; +break ; +case SCTP_V6_FLOW : + hdrs |=IECM_ADV_RSS_FLOW_SEG_HDR_SCTP | +IECM_ADV_RSS_FLOW_SEG_HDR_IPV6 ; +break ; +default : +break ; + } + +return hdrs; +} + +/** +* iecm_adv_rss_parse_hash_flds - parses hash fields from RSS hash input +* @cmd: ethtool rxnfc command +* +* This function parses the rxnfc command and returns intended hash fields for +* RSS configuration +*/ +static u64 iecm_adv_rss_parse_hash_flds (struct ethtool_rxnfc *cmd) +{ +u64 hfld =IECM_ADV_RSS_HASH_INVALID ; + +if (cmd->data &RXH_IP_SRC || cmd->data &RXH_IP_DST ) { +switch (cmd->flow_type) { +case TCP_V4_FLOW : +case UDP_V4_FLOW : +case SCTP_V4_FLOW : +if (cmd->data &RXH_IP_SRC ) + hfld |=IECM_ADV_RSS_HASH_FLD_IPV4_SA ; +if (cmd->data &RXH_IP_DST ) + hfld |=IECM_ADV_RSS_HASH_FLD_IPV4_DA ; +break ; +case TCP_V6_FLOW : +case UDP_V6_FLOW : +case SCTP_V6_FLOW : +if (cmd->data &RXH_IP_SRC ) + hfld |=IECM_ADV_RSS_HASH_FLD_IPV6_SA ; +if (cmd->data &RXH_IP_DST ) + hfld |=IECM_ADV_RSS_HASH_FLD_IPV6_DA ; +break ; +default : +break ; + } + } + +if (cmd->data &RXH_L4_B_0_1 || cmd->data &RXH_L4_B_2_3 ) { +switch (cmd->flow_type) { +case TCP_V4_FLOW : +case TCP_V6_FLOW : +if (cmd->data &RXH_L4_B_0_1 ) + hfld |=IECM_ADV_RSS_HASH_FLD_TCP_SRC_PORT ; +if (cmd->data &RXH_L4_B_2_3 ) + hfld |=IECM_ADV_RSS_HASH_FLD_TCP_DST_PORT ; +break ; +case UDP_V4_FLOW : +case UDP_V6_FLOW : +if (cmd->data &RXH_L4_B_0_1 ) + hfld |=IECM_ADV_RSS_HASH_FLD_UDP_SRC_PORT ; +if (cmd->data &RXH_L4_B_2_3 ) + hfld |=IECM_ADV_RSS_HASH_FLD_UDP_DST_PORT ; +break ; +case SCTP_V4_FLOW : +case SCTP_V6_FLOW : +if (cmd->data &RXH_L4_B_0_1 ) + hfld |=IECM_ADV_RSS_HASH_FLD_SCTP_SRC_PORT ; +if (cmd->data &RXH_L4_B_2_3 ) + hfld |=IECM_ADV_RSS_HASH_FLD_SCTP_DST_PORT ; +break ; +default : +break ; + } + } + +return hfld; +} + +/** +* iecm_set_adv_rss_hash_opt - Enable/Disable flow types for RSS hash +* @vport: vport structure +* @cmd: ethtool rxnfc command +* +* Returns Success if the flow input set is supported. +*/ +int +iecm_set_adv_rss_hash_opt (struct iecm_vport *vport,struct ethtool_rxnfc *cmd) +{ +struct iecm_adapter *adapter = vport->adapter; +struct iecm_adv_rss *rss, *rss_new; +u64 hash_flds; +u32 hdrs; +int err; + +if (adapter->state != __IECM_UP) +return -EIO ; + +if (!iecm_is_cap_ena (adapter,IECM_OTHER_CAPS ,VIRTCHNL2_CAP_ADV_RSS )) +return -EOPNOTSUPP ; + + hdrs =iecm_adv_rss_parse_hdrs (cmd); +if (hdrs ==IECM_ADV_RSS_FLOW_SEG_HDR_NONE ) +return -EINVAL ; + + hash_flds =iecm_adv_rss_parse_hash_flds (cmd); +if (hash_flds ==IECM_ADV_RSS_HASH_INVALID ) +return -EINVAL ; + + rss_new =kzalloc (sizeof (*rss_new),GFP_KERNEL ); +if (!rss_new) +return -ENOMEM ; + +/* Since this can fail, do it now to avoid dirtying the list, we'll +* copy it from rss_new if it turns out we're updating an existing +* filter instead of adding a new one. +*/ +if (iecm_fill_adv_rss_cfg_msg (&rss_new->cfg_msg, hdrs, hash_flds)) { +kfree (rss_new); +return -EINVAL ; + } + +iecm_dump_adv_rss_cfg_info (vport, hdrs, hash_flds, +"Input set change for" ,"is pending" ); + +spin_lock_bh (&adapter->adv_rss_list_lock); + rss =iecm_find_adv_rss_cfg_by_hdrs (vport, hdrs); +if (rss) { +if (rss->hash_flds != hash_flds) { + rss->remove = false; +memcpy (&rss->cfg_msg, &rss_new->cfg_msg, +sizeof (rss_new->cfg_msg)); +kfree (rss_new); + }else { +kfree (rss_new); +spin_unlock_bh (&adapter->adv_rss_list_lock); +return -EEXIST ; + } + }else { + rss = rss_new; + rss->packet_hdrs = hdrs; +list_add_tail (&rss->list, &adapter->config_data.adv_rss_list); + } + rss->add = true; + rss->hash_flds = hash_flds; +spin_unlock_bh (&adapter->adv_rss_list_lock); + + err =iecm_send_add_del_adv_rss_cfg_msg (vport, true); +if (err) { +spin_lock_bh (&adapter->adv_rss_list_lock); +/* We have to find it again to make sure another thread hasn't +* already deleted and kfreed it. +*/ + rss =iecm_find_adv_rss_cfg_by_hdrs (vport, hdrs); +if (rss) { +list_del (&rss->list); +kfree (rss); + } +spin_unlock_bh (&adapter->adv_rss_list_lock); + } + +if (!err) +iecm_dump_adv_rss_cfg_info (vport, hdrs, hash_flds, +"Input set change for" , +"successful" ); +else +iecm_dump_adv_rss_cfg_info (vport, hdrs, hash_flds, +"Failed to change the input set for" , +NULL ); + +return err; +} + +/** +* iecm_get_adv_rss_hash_opt - Retrieve hash fields for a given flow-type +* @vport: vport structure +* @cmd: ethtool rxnfc command +* +* Returns Success if the flow input set is supported. +*/ +int +iecm_get_adv_rss_hash_opt (struct iecm_vport *vport,struct ethtool_rxnfc *cmd) +{ +struct iecm_adapter *adapter = vport->adapter; +struct iecm_adv_rss *rss; +u64 hash_flds; +u32 hdrs; + +if (adapter->state != __IECM_UP) +return -EIO ; + +if (!iecm_is_cap_ena (adapter,IECM_OTHER_CAPS ,VIRTCHNL2_CAP_ADV_RSS )) +return -EOPNOTSUPP ; + + cmd->data =0 ; + + hdrs =iecm_adv_rss_parse_hdrs (cmd); +if (hdrs ==IECM_ADV_RSS_FLOW_SEG_HDR_NONE ) +return -EINVAL ; + +spin_lock_bh (&adapter->adv_rss_list_lock); + rss =iecm_find_adv_rss_cfg_by_hdrs (vport, hdrs); +if (rss) + hash_flds = rss->hash_flds; +else + hash_flds =IECM_ADV_RSS_HASH_INVALID ; +spin_unlock_bh (&adapter->adv_rss_list_lock); + +if (hash_flds ==IECM_ADV_RSS_HASH_INVALID ) +return -EINVAL ; + +if (hash_flds & (IECM_ADV_RSS_HASH_FLD_IPV4_SA | +IECM_ADV_RSS_HASH_FLD_IPV6_SA )) + cmd->data |= (u64 )RXH_IP_SRC ; + +if (hash_flds & (IECM_ADV_RSS_HASH_FLD_IPV4_DA | +IECM_ADV_RSS_HASH_FLD_IPV6_DA )) + cmd->data |= (u64 )RXH_IP_DST ; + +if (hash_flds & (IECM_ADV_RSS_HASH_FLD_TCP_SRC_PORT | +IECM_ADV_RSS_HASH_FLD_UDP_SRC_PORT | +IECM_ADV_RSS_HASH_FLD_SCTP_SRC_PORT )) + cmd->data |= (u64 )RXH_L4_B_0_1 ; + +if (hash_flds & (IECM_ADV_RSS_HASH_FLD_TCP_DST_PORT | +IECM_ADV_RSS_HASH_FLD_UDP_DST_PORT | +IECM_ADV_RSS_HASH_FLD_SCTP_DST_PORT )) + cmd->data |= (u64 )RXH_L4_B_2_3 ; + +return 0 ; +} +/** * iecm_pkt_udp_no_pay_len - the length of UDP packet without payload * @fltr: Flow Director filter data structure
drivers/net/ethernet/intel/iecm/iecm_virtchnl.c +71 -0
77 lines not on this page · raw message
drivers/net/ethernet/intel/include/iecm.h +73 -0
85 lines not on this page · raw message
Signature · 1 line
2.33.0