X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=VNFs%2FDPPD-PROX%2Fhandle_l2fwd.c;h=35d331b657c81068f5d344f7717971e91598f30d;hb=1f50af6cc73dd820b7a2a9bc12d1d365bfe8dfd9;hp=79a5f02e33aada9878b289addcf0d81d39047341;hpb=a0eb3c45ca8a89220caaefa43665a7a1eb6c1933;p=samplevnf.git diff --git a/VNFs/DPPD-PROX/handle_l2fwd.c b/VNFs/DPPD-PROX/handle_l2fwd.c index 79a5f02e..35d331b6 100644 --- a/VNFs/DPPD-PROX/handle_l2fwd.c +++ b/VNFs/DPPD-PROX/handle_l2fwd.c @@ -31,32 +31,32 @@ struct task_l2fwd { static int handle_l2fwd_bulk(struct task_base *tbase, struct rte_mbuf **mbufs, uint16_t n_pkts) { struct task_l2fwd *task = (struct task_l2fwd *)tbase; - struct ether_hdr *hdr; - struct ether_addr mac; + prox_rte_ether_hdr *hdr; + prox_rte_ether_addr mac; if ((task->runtime_flags & (TASK_ARG_DST_MAC_SET|TASK_ARG_SRC_MAC_SET)) == (TASK_ARG_DST_MAC_SET|TASK_ARG_SRC_MAC_SET)) { /* Source and Destination mac hardcoded */ for (uint16_t j = 0; j < n_pkts; ++j) { - hdr = rte_pktmbuf_mtod(mbufs[j], struct ether_hdr *); + hdr = rte_pktmbuf_mtod(mbufs[j], prox_rte_ether_hdr *); rte_memcpy(hdr, task->src_dst_mac, sizeof(task->src_dst_mac)); } } else { for (uint16_t j = 0; j < n_pkts; ++j) { - hdr = rte_pktmbuf_mtod(mbufs[j], struct ether_hdr *); + hdr = rte_pktmbuf_mtod(mbufs[j], prox_rte_ether_hdr *); if ((task->runtime_flags & (TASK_ARG_DO_NOT_SET_SRC_MAC|TASK_ARG_SRC_MAC_SET)) == 0) { /* dst mac will be used as src mac */ - ether_addr_copy(&hdr->d_addr, &mac); + prox_rte_ether_addr_copy(&hdr->d_addr, &mac); } if (task->runtime_flags & TASK_ARG_DST_MAC_SET) - ether_addr_copy((struct ether_addr *)&task->src_dst_mac[0], &hdr->d_addr); + prox_rte_ether_addr_copy((prox_rte_ether_addr *)&task->src_dst_mac[0], &hdr->d_addr); else if ((task->runtime_flags & TASK_ARG_DO_NOT_SET_DST_MAC) == 0) - ether_addr_copy(&hdr->s_addr, &hdr->d_addr); + prox_rte_ether_addr_copy(&hdr->s_addr, &hdr->d_addr); if (task->runtime_flags & TASK_ARG_SRC_MAC_SET) { - ether_addr_copy((struct ether_addr *)&task->src_dst_mac[6], &hdr->s_addr); + prox_rte_ether_addr_copy((prox_rte_ether_addr *)&task->src_dst_mac[6], &hdr->s_addr); } else if ((task->runtime_flags & TASK_ARG_DO_NOT_SET_SRC_MAC) == 0) { - ether_addr_copy(&mac, &hdr->s_addr); + prox_rte_ether_addr_copy(&mac, &hdr->s_addr); } } } @@ -66,20 +66,24 @@ static int handle_l2fwd_bulk(struct task_base *tbase, struct rte_mbuf **mbufs, u static void init_task_l2fwd(struct task_base *tbase, struct task_args *targ) { struct task_l2fwd *task = (struct task_l2fwd *)tbase; - struct ether_addr *src_addr, *dst_addr; + prox_rte_ether_addr *src_addr, *dst_addr; /* - * Destination MAC can come from - * - pre-configured mac in case 'dst mac=xx:xx:xx:xx:xx:xx' in config file - * - src mac from the packet in case 'dst mac=packet' in config file - * - not written in case 'dst mac=no' in config file - * - (default - no 'dst mac') src mac from the packet - * Source MAC can come from - * - pre-configured mac in case 'src mac=xx:xx:xx:xx:xx:xx' in config file - * - dst mac from the packet in case 'src mac=packet' in config file - * - not written in case 'src mac=no' in config file - * - (default - no 'src mac') if (tx_port) port mac - * - (default - no 'src mac') if (no tx_port) dst mac from the packet + * The destination MAC of the outgoing packet is based on the config file: + * - 'dst mac=xx:xx:xx:xx:xx:xx' => the pre-configured mac will be used as dst mac + * - 'dst mac=packet' => the src mac of the incoming packet is used as dst mac + * - 'dst mac=no' => the dst mac is untouched + * - (default - no 'dst mac') => the src mac from the incoming packet is used as dst mac + * + * The source MAC of the outgoing packet is based on the config file: + * - 'src mac=xx:xx:xx:xx:xx:xx' => the pre-configured mac will be used as src mac + * - 'src mac=packet' => the dst mac of the incoming packet is used as src mac + * - 'src mac=hw' => the mac address of the tx port is used as src mac + * An error is returned if there are no physical tx ports + * - 'src mac=no' => the src mac is untouched + * - (default - no 'src mac') => if there is physical tx port, the mac of that port is used as src mac + * - (default - no 'src mac') if there are no physical tx ports the dst mac of the incoming packet + is used as src mac */ if (targ->flags & TASK_ARG_DST_MAC_SET) { @@ -92,6 +96,8 @@ static void init_task_l2fwd(struct task_base *tbase, struct task_args *targ) memcpy(&task->src_dst_mac[6], src_addr, sizeof(*dst_addr)); plog_info("\t\tCore %d: src mac set from config file\n", targ->lconf->id); } else if ((targ->flags & TASK_ARG_DO_NOT_SET_SRC_MAC) == 0) { + if (targ->flags & TASK_ARG_HW_SRC_MAC) + PROX_PANIC(targ->nb_txports == 0, "src mac set to hw but no tx port\n"); if (targ->nb_txports) { src_addr = &prox_port_cfg[task->base.tx_params_hw.tx_port_queue[0].port].eth_addr; targ->flags |= TASK_ARG_SRC_MAC_SET; @@ -106,9 +112,8 @@ static struct task_init task_init_l2fwd = { .mode_str = "l2fwd", .init = init_task_l2fwd, .handle = handle_l2fwd_bulk, - .flag_features = TASK_FEATURE_NEVER_DISCARDS|TASK_FEATURE_TXQ_FLAGS_NOOFFLOADS|TASK_FEATURE_TXQ_FLAGS_NOMULTSEGS, + .flag_features = TASK_FEATURE_NEVER_DISCARDS|TASK_FEATURE_TXQ_FLAGS_NOOFFLOADS, .size = sizeof(struct task_l2fwd), - .mbuf_size = 2048 + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM, }; __attribute__((constructor)) static void reg_task_l2fwd(void)