Skip to content

Commit

Permalink
reverted ipv4 csum offload flags raising, does not work + fixed endle…
Browse files Browse the repository at this point in the history
…ss loop while udp transmission
  • Loading branch information
vadimsu committed Jan 30, 2015
1 parent 21e969d commit b8fc456
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 38 deletions.
32 changes: 8 additions & 24 deletions dpdk-1.6.0r2/lib/librte_pmd_ixgbe/ixgbe_rxtx.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ ixgbe_xmit_pkts_simple(void *tx_queue, struct rte_mbuf **tx_pkts,
static inline void
ixgbe_set_xmit_ctx(struct igb_tx_queue* txq,
volatile struct ixgbe_adv_tx_context_desc *ctx_txd,
uint16_t ol_flags, uint32_t vlan_macip_lens,uint32_t mss_l4len)
uint16_t ol_flags, uint32_t vlan_macip_lens)
{
uint32_t type_tucmd_mlhl;
uint32_t mss_l4len_idx;
Expand All @@ -372,7 +372,6 @@ ixgbe_set_xmit_ctx(struct igb_tx_queue* txq,

/* Specify which HW CTX to upload. */
mss_l4len_idx = (ctx_idx << IXGBE_ADVTXD_IDX_SHIFT);
// mss_l4len_idx = 0;
switch (ol_flags & PKT_TX_L4_MASK) {
case PKT_TX_UDP_CKSUM:
type_tucmd_mlhl |= IXGBE_ADVTXD_TUCMD_L4T_UDP |
Expand All @@ -383,8 +382,7 @@ ixgbe_set_xmit_ctx(struct igb_tx_queue* txq,
case PKT_TX_TCP_CKSUM:
type_tucmd_mlhl |= IXGBE_ADVTXD_TUCMD_L4T_TCP |
IXGBE_ADVTXD_DTYP_CTXT | IXGBE_ADVTXD_DCMD_DEXT;
mss_l4len_idx |= mss_l4len << IXGBE_ADVTXD_L4LEN_SHIFT;
mss_l4len_idx |= 1448 << IXGBE_ADVTXD_MSS_SHIFT;
mss_l4len_idx |= sizeof(struct tcp_hdr) << IXGBE_ADVTXD_L4LEN_SHIFT;
cmp_mask |= TX_MACIP_LEN_CMP_MASK;
break;
case PKT_TX_SCTP_CKSUM:
Expand All @@ -403,7 +401,6 @@ ixgbe_set_xmit_ctx(struct igb_tx_queue* txq,
txq->ctx_cache[ctx_idx].cmp_mask = cmp_mask;
txq->ctx_cache[ctx_idx].vlan_macip_lens.data =
vlan_macip_lens & cmp_mask;
txq->ctx_cache[ctx_idx].mss_l4_len = mss_l4len;

ctx_txd->type_tucmd_mlhl = rte_cpu_to_le_32(type_tucmd_mlhl);
ctx_txd->vlan_macip_lens = rte_cpu_to_le_32(vlan_macip_lens);
Expand All @@ -417,22 +414,20 @@ ixgbe_set_xmit_ctx(struct igb_tx_queue* txq,
*/
static inline uint32_t
what_advctx_update(struct igb_tx_queue *txq, uint16_t flags,
uint32_t vlan_macip_lens,uint32_t mss_l4_len)
uint32_t vlan_macip_lens)
{
/* If match with the current used context */
if (likely((txq->ctx_cache[txq->ctx_curr].flags == flags) &&
(txq->ctx_cache[txq->ctx_curr].vlan_macip_lens.data ==
(txq->ctx_cache[txq->ctx_curr].cmp_mask & vlan_macip_lens))&&
(txq->ctx_cache[txq->ctx_curr].mss_l4_len == mss_l4_len))) {
(txq->ctx_cache[txq->ctx_curr].cmp_mask & vlan_macip_lens)))) {
return txq->ctx_curr;
}

/* What if match with the next context */
txq->ctx_curr ^= 1;
if (likely((txq->ctx_cache[txq->ctx_curr].flags == flags) &&
(txq->ctx_cache[txq->ctx_curr].vlan_macip_lens.data ==
(txq->ctx_cache[txq->ctx_curr].cmp_mask & vlan_macip_lens))&&
(txq->ctx_cache[txq->ctx_curr].mss_l4_len == mss_l4_len))) {
(txq->ctx_cache[txq->ctx_curr].cmp_mask & vlan_macip_lens)))) {
return txq->ctx_curr;
}

Expand Down Expand Up @@ -583,7 +578,7 @@ ixgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
if (tx_ol_req) {
/* If new context need be built or reuse the exist ctx. */
ctx = what_advctx_update(txq, tx_ol_req,
vlan_macip_lens,tx_pkt->pkt.hash.fdir.hash);
vlan_macip_lens);
/* Only allocate context descriptor if required*/
new_ctx = (ctx == IXGBE_CTX_NUM);
ctx = txq->ctx_curr;
Expand Down Expand Up @@ -698,15 +693,7 @@ ixgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
*/
cmd_type_len = IXGBE_ADVTXD_DTYP_DATA |
IXGBE_ADVTXD_DCMD_IFCS | IXGBE_ADVTXD_DCMD_DEXT;
#define IXGBE_TX_FLAGS_TSO 0x2
if(tx_ol_req) {
olinfo_status = (pkt_len - (tx_pkt->pkt.hash.fdir.hash + tx_pkt->pkt.hash.fdir.id)) << IXGBE_ADVTXD_PAYLEN_SHIFT;
cmd_type_len |= ((IXGBE_TX_FLAGS_TSO <= IXGBE_ADVTXD_DCMD_TSE) ? (IXGBE_TX_FLAGS_TSO * (IXGBE_ADVTXD_DCMD_TSE / IXGBE_TX_FLAGS_TSO)) : \
(IXGBE_TX_FLAGS_TSO / (IXGBE_TX_FLAGS_TSO / IXGBE_ADVTXD_DCMD_TSE)));
}
else {
olinfo_status = (pkt_len << IXGBE_ADVTXD_PAYLEN_SHIFT);
}
olinfo_status = (pkt_len << IXGBE_ADVTXD_PAYLEN_SHIFT);
#ifdef RTE_LIBRTE_IEEE1588
if (ol_flags & PKT_TX_IEEE1588_TMST)
cmd_type_len |= IXGBE_ADVTXD_MAC_1588;
Expand All @@ -733,7 +720,7 @@ ixgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
}

ixgbe_set_xmit_ctx(txq, ctx_txd, tx_ol_req,
vlan_macip_lens,tx_pkt->pkt.hash.fdir.hash);
vlan_macip_lens);

txe->last_id = tx_last;
tx_id = txe->next_id;
Expand Down Expand Up @@ -770,9 +757,6 @@ ixgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
rte_cpu_to_le_32(cmd_type_len | slen);
txd->read.olinfo_status =
rte_cpu_to_le_32(olinfo_status);
if (tx_ol_req) {
olinfo_status = 0;
}
txe->last_id = tx_last;
tx_id = txe->next_id;
txe = txn;
Expand Down
1 change: 0 additions & 1 deletion dpdk-1.6.0r2/lib/librte_pmd_ixgbe/ixgbe_rxtx.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ struct ixgbe_advctx_info {
uint16_t flags; /**< ol_flags for context build. */
uint32_t cmp_mask; /**< compare mask for vlan_macip_lens */
union rte_vlan_macip vlan_macip_lens; /**< vlan, mac ip length. */
uint32_t mss_l4_len;
};

/**
Expand Down
14 changes: 11 additions & 3 deletions drivers/net/dpdk/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,16 @@ static netdev_tx_t dpdk_xmit_frame(struct sk_buff *skb,
IPPROTO_TCP,
0);
}
#else
head->ol_flags = PKT_TX_IP_CKSUM;
#else
// if (skb->protocol == htons(ETH_P_IP)) {
// head->ol_flags = PKT_TX_IP_CKSUM;
// struct iphdr *iph = ip_hdr(skb);
// iph->check = 0;
// if (ip_hdr(skb)->protocol == IPPROTO_TCP)
// head->ol_flags = PKT_TX_TCP_CKSUM;
// else if(ip_hdr(skb)->protocol == IPPROTO_UDP)
// head->ol_flags = PKT_TX_UDP_CKSUM;
// }
#endif
/* this will pass the mbuf to DPDK PMD driver */
dpdk_dev_enqueue_for_tx(priv->port_number,head);
Expand Down Expand Up @@ -403,7 +411,7 @@ void *create_netdev(int port_num)
#ifdef GSO
netdev->features = NETIF_F_SG | NETIF_F_GSO | NETIF_F_FRAGLIST;
#else
netdev->features = NETIF_F_SG | NETIF_F_FRAGLIST|NETIF_F_V4_CSUM;
netdev->features = NETIF_F_SG | NETIF_F_FRAGLIST/*|NETIF_F_V4_CSUM*/;
#endif
netdev->hw_features = 0;

Expand Down
2 changes: 1 addition & 1 deletion porting/libinit.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ static const struct rte_eth_conf port_conf = {
.rxmode = {
.split_hdr_size = 0,
.header_split = 0, /**< Header Split disabled */
.hw_ip_checksum = 1, /**< IP checksum offload disabled */
.hw_ip_checksum = 0, /**< IP checksum offload disabled */
.hw_vlan_filter = 0, /**< VLAN filtering disabled */
.jumbo_frame = 1, /**< Jumbo Frame Support disabled */
.max_rx_pkt_len = 0x2000,
Expand Down
14 changes: 5 additions & 9 deletions user_callbacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ static inline __attribute__ ((always_inline)) int user_on_transmission_opportuni
struct iovec iov;
struct rte_mbuf *mbuf[MAX_PKT_BURST];
struct sock *sk = sock->sk;
int dequeued,rc = 0,loop = 1;
int dequeued,rc = 0,loop = 0;

msghdr.msg_namelen = sizeof(struct sockaddr_in);
msghdr.msg_iov = &iov;
Expand All @@ -95,20 +95,16 @@ static inline __attribute__ ((always_inline)) int user_on_transmission_opportuni
p_addr -= sizeof(struct sockaddr_in);
msghdr.msg_name = p_addr;

iov.head = mbuf[i];
sent += rc;

iov.head = mbuf[i];
sent = 1;
rc = udp_sendmsg(NULL, sk, &msghdr, mbuf[i]->pkt.data_len);
sent = (rc > 0);
}
user_on_tx_opportunity_api_failed += dequeued - i;
for(;i < dequeued;i++) {
rte_pktmbuf_free(mbuf[i]);
loop = 0;
}
}while(loop);
}
if(!sent) {
user_on_tx_opportunity_cannot_send++;
}while((dequeued > 0) && (sent > 0));
}
user_on_tx_opportunity_cycles += rte_rdtsc() - ts;
return sent;
Expand Down

0 comments on commit b8fc456

Please sign in to comment.