LCOV - code coverage report
Current view: top level - app/test-pmd - macswap_sse.h (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 25 0.0 %
Date: 2025-03-01 20:23:48 Functions: 0 1 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(c) 2018 Intel Corporation
       3                 :            :  */
       4                 :            : 
       5                 :            : #ifndef _MACSWAP_SSE_H_
       6                 :            : #define _MACSWAP_SSE_H_
       7                 :            : 
       8                 :            : #include "macswap_common.h"
       9                 :            : 
      10                 :            : static inline void
      11                 :          0 : do_macswap(struct rte_mbuf *pkts[], uint16_t nb,
      12                 :            :                 struct rte_port *txp)
      13                 :            : {
      14                 :            :         struct rte_ether_hdr *eth_hdr[4];
      15                 :            :         struct rte_mbuf *mb[4];
      16                 :            :         uint64_t ol_flags;
      17                 :            :         int i;
      18                 :            :         int r;
      19                 :            :         register __m128i addr0, addr1, addr2, addr3;
      20                 :            :         /**
      21                 :            :          * shuffle mask be used to shuffle the 16 bytes.
      22                 :            :          * byte 0-5 wills be swapped with byte 6-11.
      23                 :            :          * byte 12-15 will keep unchanged.
      24                 :            :          */
      25                 :            :         register const __m128i shfl_msk = _mm_set_epi8(15, 14, 13, 12,
      26                 :            :                                         5, 4, 3, 2,
      27                 :            :                                         1, 0, 11, 10,
      28                 :            :                                         9, 8, 7, 6);
      29                 :            : 
      30                 :          0 :         ol_flags = ol_flags_init(txp->dev_conf.txmode.offloads);
      31                 :          0 :         vlan_qinq_set(pkts, nb, ol_flags,
      32                 :          0 :                         txp->tx_vlan_id, txp->tx_vlan_id_outer);
      33                 :            : 
      34                 :            :         i = 0;
      35                 :            :         r = nb;
      36                 :            : 
      37                 :          0 :         while (r >= 4) {
      38                 :          0 :                 if (r >= 8) {
      39                 :          0 :                         rte_prefetch0(rte_pktmbuf_mtod(pkts[i + 4], void *));
      40                 :          0 :                         rte_prefetch0(rte_pktmbuf_mtod(pkts[i + 5], void *));
      41                 :          0 :                         rte_prefetch0(rte_pktmbuf_mtod(pkts[i + 6], void *));
      42                 :          0 :                         rte_prefetch0(rte_pktmbuf_mtod(pkts[i + 7], void *));
      43                 :            :                 }
      44                 :            : 
      45                 :          0 :                 mb[0] = pkts[i++];
      46                 :          0 :                 eth_hdr[0] = rte_pktmbuf_mtod(mb[0], struct rte_ether_hdr *);
      47                 :            :                 addr0 = _mm_loadu_si128((__m128i *)eth_hdr[0]);
      48                 :            :                 mbuf_field_set(mb[0], ol_flags);
      49                 :            : 
      50                 :          0 :                 mb[1] = pkts[i++];
      51                 :          0 :                 eth_hdr[1] = rte_pktmbuf_mtod(mb[1], struct rte_ether_hdr *);
      52                 :            :                 addr1 = _mm_loadu_si128((__m128i *)eth_hdr[1]);
      53                 :            :                 mbuf_field_set(mb[1], ol_flags);
      54                 :            : 
      55                 :            :                 addr0 = _mm_shuffle_epi8(addr0, shfl_msk);
      56                 :            : 
      57                 :          0 :                 mb[2] = pkts[i++];
      58                 :          0 :                 eth_hdr[2] = rte_pktmbuf_mtod(mb[2], struct rte_ether_hdr *);
      59                 :            :                 addr2 = _mm_loadu_si128((__m128i *)eth_hdr[2]);
      60                 :            :                 mbuf_field_set(mb[2], ol_flags);
      61                 :            : 
      62                 :            :                 addr1 = _mm_shuffle_epi8(addr1, shfl_msk);
      63                 :            :                 _mm_storeu_si128((__m128i *)eth_hdr[0], addr0);
      64                 :            : 
      65                 :          0 :                 mb[3] = pkts[i++];
      66                 :          0 :                 eth_hdr[3] = rte_pktmbuf_mtod(mb[3], struct rte_ether_hdr *);
      67                 :            :                 addr3 = _mm_loadu_si128((__m128i *)eth_hdr[3]);
      68                 :            :                 mbuf_field_set(mb[3], ol_flags);
      69                 :            : 
      70                 :            :                 addr2 = _mm_shuffle_epi8(addr2, shfl_msk);
      71                 :            :                 _mm_storeu_si128((__m128i *)eth_hdr[1], addr1);
      72                 :            : 
      73                 :            :                 addr3 = _mm_shuffle_epi8(addr3, shfl_msk);
      74                 :            :                 _mm_storeu_si128((__m128i *)eth_hdr[2], addr2);
      75                 :            :                 _mm_storeu_si128((__m128i *)eth_hdr[3], addr3);
      76                 :            : 
      77                 :          0 :                 r -= 4;
      78                 :            :         }
      79                 :            : 
      80                 :          0 :         for ( ; i < nb; i++) {
      81                 :          0 :                 if (i < nb - 1)
      82                 :          0 :                         rte_prefetch0(rte_pktmbuf_mtod(pkts[i+1], void *));
      83                 :          0 :                 mb[0] = pkts[i];
      84                 :          0 :                 eth_hdr[0] = rte_pktmbuf_mtod(mb[0], struct rte_ether_hdr *);
      85                 :            : 
      86                 :            :                 /* Swap dest and src mac addresses. */
      87                 :            :                 addr0 = _mm_loadu_si128((__m128i *)eth_hdr[0]);
      88                 :            :                 mbuf_field_set(mb[0], ol_flags);
      89                 :            : 
      90                 :            :                 addr0 = _mm_shuffle_epi8(addr0, shfl_msk);
      91                 :            :                 _mm_storeu_si128((__m128i *)eth_hdr[0], addr0);
      92                 :            :         }
      93                 :          0 : }
      94                 :            : 
      95                 :            : #endif /* _MACSWAP_SSE_H_ */

Generated by: LCOV version 1.14