net: add rte prefix to IP defines
[dpdk.git] / examples / l3fwd-power / main.c
index 3b448ac..2c6da3f 100644 (file)
@@ -135,7 +135,7 @@ static uint16_t nb_rxd = RTE_TEST_RX_DESC_DEFAULT;
 static uint16_t nb_txd = RTE_TEST_TX_DESC_DEFAULT;
 
 /* ethernet addresses of ports */
-static struct ether_addr ports_eth_addr[RTE_MAX_ETHPORTS];
+static struct rte_ether_addr ports_eth_addr[RTE_MAX_ETHPORTS];
 
 /* ethernet addresses of ports */
 static rte_spinlock_t locks[RTE_MAX_ETHPORTS];
@@ -200,7 +200,7 @@ uint16_t nb_lcore_params = sizeof(lcore_params_array_default) /
 static struct rte_eth_conf port_conf = {
        .rxmode = {
                .mq_mode        = ETH_MQ_RX_RSS,
-               .max_rx_pkt_len = ETHER_MAX_LEN,
+               .max_rx_pkt_len = RTE_ETHER_MAX_LEN,
                .split_hdr_size = 0,
                .offloads = DEV_RX_OFFLOAD_CHECKSUM,
        },
@@ -258,10 +258,10 @@ struct ipv6_l3fwd_route {
 };
 
 static struct ipv4_l3fwd_route ipv4_l3fwd_route_array[] = {
-       {{IPv4(100,10,0,1), IPv4(200,10,0,1), 101, 11, IPPROTO_TCP}, 0},
-       {{IPv4(100,20,0,2), IPv4(200,20,0,2), 102, 12, IPPROTO_TCP}, 1},
-       {{IPv4(100,30,0,3), IPv4(200,30,0,3), 103, 13, IPPROTO_TCP}, 2},
-       {{IPv4(100,40,0,4), IPv4(200,40,0,4), 104, 14, IPPROTO_TCP}, 3},
+       {{RTE_IPv4(100,10,0,1), RTE_IPv4(200,10,0,1), 101, 11, IPPROTO_TCP}, 0},
+       {{RTE_IPv4(100,20,0,2), RTE_IPv4(200,20,0,2), 102, 12, IPPROTO_TCP}, 1},
+       {{RTE_IPv4(100,30,0,3), RTE_IPv4(200,30,0,3), 103, 13, IPPROTO_TCP}, 2},
+       {{RTE_IPv4(100,40,0,4), RTE_IPv4(200,40,0,4), 104, 14, IPPROTO_TCP}, 3},
 };
 
 static struct ipv6_l3fwd_route ipv6_l3fwd_route_array[] = {
@@ -300,14 +300,14 @@ struct ipv4_l3fwd_route {
 };
 
 static struct ipv4_l3fwd_route ipv4_l3fwd_route_array[] = {
-       {IPv4(1,1,1,0), 24, 0},
-       {IPv4(2,1,1,0), 24, 1},
-       {IPv4(3,1,1,0), 24, 2},
-       {IPv4(4,1,1,0), 24, 3},
-       {IPv4(5,1,1,0), 24, 4},
-       {IPv4(6,1,1,0), 24, 5},
-       {IPv4(7,1,1,0), 24, 6},
-       {IPv4(8,1,1,0), 24, 7},
+       {RTE_IPv4(1,1,1,0), 24, 0},
+       {RTE_IPv4(2,1,1,0), 24, 1},
+       {RTE_IPv4(3,1,1,0), 24, 2},
+       {RTE_IPv4(4,1,1,0), 24, 3},
+       {RTE_IPv4(5,1,1,0), 24, 4},
+       {RTE_IPv4(6,1,1,0), 24, 5},
+       {RTE_IPv4(7,1,1,0), 24, 6},
+       {RTE_IPv4(8,1,1,0), 24, 7},
 };
 
 #define IPV4_L3FWD_NUM_ROUTES \
@@ -466,14 +466,14 @@ send_single_packet(struct rte_mbuf *m, uint16_t port)
 
 #ifdef DO_RFC_1812_CHECKS
 static inline int
-is_valid_ipv4_pkt(struct ipv4_hdr *pkt, uint32_t link_len)
+is_valid_ipv4_pkt(struct rte_ipv4_hdr *pkt, uint32_t link_len)
 {
        /* From http://www.rfc-editor.org/rfc/rfc1812.txt section 5.2.2 */
        /*
         * 1. The packet length reported by the Link Layer must be large
         * enough to hold the minimum length legal IP datagram (20 bytes).
         */
-       if (link_len < sizeof(struct ipv4_hdr))
+       if (link_len < sizeof(struct rte_ipv4_hdr))
                return -1;
 
        /* 2. The IP checksum must be correct. */
@@ -498,7 +498,7 @@ is_valid_ipv4_pkt(struct ipv4_hdr *pkt, uint32_t link_len)
         * datagram header, whose length is specified in the IP header length
         * field.
         */
-       if (rte_cpu_to_be_16(pkt->total_length) < sizeof(struct ipv4_hdr))
+       if (rte_cpu_to_be_16(pkt->total_length) < sizeof(struct rte_ipv4_hdr))
                return -5;
 
        return 0;
@@ -523,7 +523,7 @@ print_ipv6_key(struct ipv6_5tuple key)
 }
 
 static inline uint16_t
-get_ipv4_dst_port(struct ipv4_hdr *ipv4_hdr, uint16_t portid,
+get_ipv4_dst_port(struct rte_ipv4_hdr *ipv4_hdr, uint16_t portid,
                lookup_struct_t * ipv4_l3fwd_lookup_struct)
 {
        struct ipv4_5tuple key;
@@ -538,14 +538,14 @@ get_ipv4_dst_port(struct ipv4_hdr *ipv4_hdr, uint16_t portid,
        switch (ipv4_hdr->next_proto_id) {
        case IPPROTO_TCP:
                tcp = (struct tcp_hdr *)((unsigned char *)ipv4_hdr +
-                                       sizeof(struct ipv4_hdr));
+                                       sizeof(struct rte_ipv4_hdr));
                key.port_dst = rte_be_to_cpu_16(tcp->dst_port);
                key.port_src = rte_be_to_cpu_16(tcp->src_port);
                break;
 
        case IPPROTO_UDP:
                udp = (struct udp_hdr *)((unsigned char *)ipv4_hdr +
-                                       sizeof(struct ipv4_hdr));
+                                       sizeof(struct rte_ipv4_hdr));
                key.port_dst = rte_be_to_cpu_16(udp->dst_port);
                key.port_src = rte_be_to_cpu_16(udp->src_port);
                break;
@@ -562,7 +562,7 @@ get_ipv4_dst_port(struct ipv4_hdr *ipv4_hdr, uint16_t portid,
 }
 
 static inline uint16_t
-get_ipv6_dst_port(struct ipv6_hdr *ipv6_hdr, uint16_t portid,
+get_ipv6_dst_port(struct rte_ipv6_hdr *ipv6_hdr, uint16_t portid,
                        lookup_struct_t *ipv6_l3fwd_lookup_struct)
 {
        struct ipv6_5tuple key;
@@ -578,14 +578,14 @@ get_ipv6_dst_port(struct ipv6_hdr *ipv6_hdr, uint16_t portid,
        switch (ipv6_hdr->proto) {
        case IPPROTO_TCP:
                tcp = (struct tcp_hdr *)((unsigned char *) ipv6_hdr +
-                                       sizeof(struct ipv6_hdr));
+                                       sizeof(struct rte_ipv6_hdr));
                key.port_dst = rte_be_to_cpu_16(tcp->dst_port);
                key.port_src = rte_be_to_cpu_16(tcp->src_port);
                break;
 
        case IPPROTO_UDP:
                udp = (struct udp_hdr *)((unsigned char *) ipv6_hdr +
-                                       sizeof(struct ipv6_hdr));
+                                       sizeof(struct rte_ipv6_hdr));
                key.port_dst = rte_be_to_cpu_16(udp->dst_port);
                key.port_src = rte_be_to_cpu_16(udp->src_port);
                break;
@@ -604,7 +604,7 @@ get_ipv6_dst_port(struct ipv6_hdr *ipv6_hdr, uint16_t portid,
 
 #if (APP_LOOKUP_METHOD == APP_LOOKUP_LPM)
 static inline uint16_t
-get_ipv4_dst_port(struct ipv4_hdr *ipv4_hdr, uint16_t portid,
+get_ipv4_dst_port(struct rte_ipv4_hdr *ipv4_hdr, uint16_t portid,
                lookup_struct_t *ipv4_l3fwd_lookup_struct)
 {
        uint32_t next_hop;
@@ -618,15 +618,15 @@ get_ipv4_dst_port(struct ipv4_hdr *ipv4_hdr, uint16_t portid,
 static inline void
 parse_ptype_one(struct rte_mbuf *m)
 {
-       struct ether_hdr *eth_hdr;
+       struct rte_ether_hdr *eth_hdr;
        uint32_t packet_type = RTE_PTYPE_UNKNOWN;
        uint16_t ether_type;
 
-       eth_hdr = rte_pktmbuf_mtod(m, struct ether_hdr *);
+       eth_hdr = rte_pktmbuf_mtod(m, struct rte_ether_hdr *);
        ether_type = eth_hdr->ether_type;
-       if (ether_type == rte_cpu_to_be_16(ETHER_TYPE_IPv4))
+       if (ether_type == rte_cpu_to_be_16(RTE_ETHER_TYPE_IPv4))
                packet_type |= RTE_PTYPE_L3_IPV4_EXT_UNKNOWN;
-       else if (ether_type == rte_cpu_to_be_16(ETHER_TYPE_IPv6))
+       else if (ether_type == rte_cpu_to_be_16(RTE_ETHER_TYPE_IPv6))
                packet_type |= RTE_PTYPE_L3_IPV6_EXT_UNKNOWN;
 
        m->packet_type = packet_type;
@@ -661,18 +661,18 @@ static inline void
 l3fwd_simple_forward(struct rte_mbuf *m, uint16_t portid,
                                struct lcore_conf *qconf)
 {
-       struct ether_hdr *eth_hdr;
-       struct ipv4_hdr *ipv4_hdr;
+       struct rte_ether_hdr *eth_hdr;
+       struct rte_ipv4_hdr *ipv4_hdr;
        void *d_addr_bytes;
        uint16_t dst_port;
 
-       eth_hdr = rte_pktmbuf_mtod(m, struct ether_hdr *);
+       eth_hdr = rte_pktmbuf_mtod(m, struct rte_ether_hdr *);
 
        if (RTE_ETH_IS_IPV4_HDR(m->packet_type)) {
                /* Handle IPv4 headers.*/
                ipv4_hdr =
-                       rte_pktmbuf_mtod_offset(m, struct ipv4_hdr *,
-                                               sizeof(struct ether_hdr));
+                       rte_pktmbuf_mtod_offset(m, struct rte_ipv4_hdr *,
+                                               sizeof(struct rte_ether_hdr));
 
 #ifdef DO_RFC_1812_CHECKS
                /* Check to make sure the packet is valid (RFC1812) */
@@ -700,17 +700,18 @@ l3fwd_simple_forward(struct rte_mbuf *m, uint16_t portid,
 #endif
 
                /* src addr */
-               ether_addr_copy(&ports_eth_addr[dst_port], &eth_hdr->s_addr);
+               rte_ether_addr_copy(&ports_eth_addr[dst_port],
+                               &eth_hdr->s_addr);
 
                send_single_packet(m, dst_port);
        } else if (RTE_ETH_IS_IPV6_HDR(m->packet_type)) {
                /* Handle IPv6 headers.*/
 #if (APP_LOOKUP_METHOD == APP_LOOKUP_EXACT_MATCH)
-               struct ipv6_hdr *ipv6_hdr;
+               struct rte_ipv6_hdr *ipv6_hdr;
 
                ipv6_hdr =
-                       rte_pktmbuf_mtod_offset(m, struct ipv6_hdr *,
-                                               sizeof(struct ether_hdr));
+                       rte_pktmbuf_mtod_offset(m, struct rte_ipv6_hdr *,
+                                               sizeof(struct rte_ether_hdr));
 
                dst_port = get_ipv6_dst_port(ipv6_hdr, portid,
                                        qconf->ipv6_lookup_struct);
@@ -725,7 +726,8 @@ l3fwd_simple_forward(struct rte_mbuf *m, uint16_t portid,
                        0x000000000002 + ((uint64_t)dst_port << 40);
 
                /* src addr */
-               ether_addr_copy(&ports_eth_addr[dst_port], &eth_hdr->s_addr);
+               rte_ether_addr_copy(&ports_eth_addr[dst_port],
+                               &eth_hdr->s_addr);
 
                send_single_packet(m, dst_port);
 #else
@@ -1534,7 +1536,7 @@ parse_args(int argc, char **argv)
 
                                /**
                                 * if no max-pkt-len set, use the default value
-                                * ETHER_MAX_LEN
+                                * RTE_ETHER_MAX_LEN
                                 */
                                if (0 == getopt_long(argc, argvopt, "",
                                                &lenopts, &option_index)) {
@@ -1577,10 +1579,10 @@ parse_args(int argc, char **argv)
 }
 
 static void
-print_ethaddr(const char *name, const struct ether_addr *eth_addr)
+print_ethaddr(const char *name, const struct rte_ether_addr *eth_addr)
 {
-       char buf[ETHER_ADDR_FMT_SIZE];
-       ether_format_addr(buf, ETHER_ADDR_FMT_SIZE, eth_addr);
+       char buf[RTE_ETHER_ADDR_FMT_SIZE];
+       rte_ether_format_addr(buf, RTE_ETHER_ADDR_FMT_SIZE, eth_addr);
        printf("%s%s", name, buf);
 }