[dpdk-dev] time triggered send with the I210 controller ...
Hi All, I'm trying to implement the "time triggered send" as an extension of the PMD driver of the i210 controller. Are there ans application guides or sample codes showing how to handle the specific timer(s) of the i210 ? This nice feature isn't well documented ... Best Regards Armin Steinhpff
[dpdk-dev] Packet crafting....
Hello friends, As of now... I know on how to create an ipv4 header using the 'struct ipv4_hdr'. My requirement is to craft a packet and sent it via 'rte_eth_tx_burst'. I know that there should be an 'ether_hdr' created before, the packet could be sent. Could someone help me on how to set the address fields and type in 'ether_hdr' and how to put the ipv4 header as the payload for ether_hdr. Thanks in advance
[dpdk-dev] Packet crafting....
> Hello friends, > > As of now... I know on how to create an ipv4 header using the 'struct > ipv4_hdr'. > My requirement is to craft a packet and sent it via 'rte_eth_tx_burst'. > I know that there should be an 'ether_hdr' created before, the packet could > be sent. > Could someone help me on how to set the address fields and type in > 'ether_hdr' and how to put the ipv4 header as the payload for ether_hdr. > You probably want to do something like this to craft a full packet. First allocate an mbuf, then get it's data pointer as a ether_hdr structure, then an ip_hdr beyond that and then any L4 headers, e.g. udp, beyond that. For example, assuming mempool variable p: struct rte_mbuf *buf = rte_pktmbuf_alloc(p); struct ether_hdr *ehdr = rte_pktmbuf_mtod(buf, struct ether_hdr *); /* set ether_hdr fields here e.g. */ ehdr->ether_type = rte_bswap16(ETHER_TYPE_IPv4); struct ipv4_hdr *iphdr = (struct ipv4_hdr *)(&ehdr[1]); /* set ipv4 header fields here */ struct udp_hdr *uhdr = (struct udp_hdr *)(&iphdr[1]); /* set udp header fields here, e.g. */ uhdr->src_port = rte_bswap16(0x5000);
[dpdk-dev] Packet crafting....
Thank you very much Richardson for your valuable reply. But is there another way of doing it using the rte_pktmbuf_append / rte_pktmbuf_prepend ? Can you please tell me on how to do that ? Regards On Fri, Mar 14, 2014 at 3:27 PM, Richardson, Bruce < bruce.richardson at intel.com> wrote: > > Hello friends, > > > > As of now... I know on how to create an ipv4 header using the 'struct > > ipv4_hdr'. > > My requirement is to craft a packet and sent it via 'rte_eth_tx_burst'. > > I know that there should be an 'ether_hdr' created before, the packet > could > > be sent. > > Could someone help me on how to set the address fields and type in > > 'ether_hdr' and how to put the ipv4 header as the payload for ether_hdr. > > > > You probably want to do something like this to craft a full packet. First > allocate an mbuf, then get it's data pointer as a ether_hdr structure, then > an ip_hdr beyond that and then any L4 headers, e.g. udp, beyond that. For > example, assuming mempool variable p: > > struct rte_mbuf *buf = rte_pktmbuf_alloc(p); > struct ether_hdr *ehdr = rte_pktmbuf_mtod(buf, struct ether_hdr *); > /* set ether_hdr fields here e.g. */ > ehdr->ether_type = rte_bswap16(ETHER_TYPE_IPv4); > struct ipv4_hdr *iphdr = (struct ipv4_hdr *)(&ehdr[1]); > /* set ipv4 header fields here */ > struct udp_hdr *uhdr = (struct udp_hdr *)(&iphdr[1]); > /* set udp header fields here, e.g. */ > uhdr->src_port = rte_bswap16(0x5000); >
[dpdk-dev] Segmentation Fault on printf()
Hello friends, I'm trying to print the ether_type for a packet that I captured from a port on my machine. Suppose 'm' holds the packet. 'm' is of type 'struct rte_mbuf'. Intels API reference for DPDK says 'ether_type' is of uint16_t. I used the following code to retrieve ether_type. void * eth_type; struct ether_hdr *eth; eth = rte_pktmbuf_mtod(m, struct ether_hdr *); eth_type = ð->ether_type; printf("\n Type is %" PRIu16 , *((uint16_t *)eth_type)); rte_pktmbuf_free(m); I get a 'Segmentation fault' when the printf() statement gets executed. Where am I going wrong ? Thanks in advance
[dpdk-dev] Packet crafting....
> From: sabu kurian [mailto:sabu2kurian at gmail.com] > Sent: Friday, March 14, 2014 10:09 AM > To: Richardson, Bruce > Cc: dev at dpdk.org > Subject: Re: [dpdk-dev] Packet crafting > > Thank you very much Richardson for your valuable reply. But is there another > way of doing it using the?rte_pktmbuf_append / rte_pktmbuf_prepend ? Can you > please tell me on how to do that ? You could use pktmbuf_append and pktmbuf_prepend, but they are primarily designed to add headers/footers on to an existing packet that already has headers, so that you don't need to move the existing data. In the case of having to craft a packet from scratch, there is no existing data in the mbuf, so the whole packet can just be filled in sequentially. [Don't forget that when you get the mbuf from rte_pktmbuf_alloc, you also need to set the length value to the appropriate size.] However, if you first write the data to the mbuf and then want to add the headers in order, like a packet moving down through layers of a stack, you can use prepend to add udp, then ip, then your ethernet header, but this will be no faster than just writing the data directly to the mbuf space, and may be slightly slower as each prepend call has to just the length values and data pointer values in the mbuf. Each header prepended also uses up headroom in the mbuf, so you can only add 128-bytes of headers by default to each packet. In short, if you are creating a single packet, I'd recommend just getting the data pointer from the returned mbuf and writing directly to that. Regards, /Bruce
[dpdk-dev] Packet crafting....
Thanks on the reply Richardson. You did mention something like "Don't forget that when you get the mbuf from rte_pktmbuf_alloc, you also need to set the length value to the appropriate size." . Like I'm allocating the mbuf using rte_mbuf . The rte_mempool_create has already set the maximum packet size for a mbuf and the number of mbuf's and all. So do I really need to use rte_pktmbuf_alloc ? On Fri, Mar 14, 2014 at 4:38 PM, Richardson, Bruce < bruce.richardson at intel.com> wrote: > > > From: sabu kurian [mailto:sabu2kurian at gmail.com] > > Sent: Friday, March 14, 2014 10:09 AM > > To: Richardson, Bruce > > Cc: dev at dpdk.org > > Subject: Re: [dpdk-dev] Packet crafting > > > > Thank you very much Richardson for your valuable reply. But is there > another way of doing it using the rte_pktmbuf_append / rte_pktmbuf_prepend > ? Can you please tell me on how to do that ? > > You could use pktmbuf_append and pktmbuf_prepend, but they are primarily > designed to add headers/footers on to an existing packet that already has > headers, so that you don't need to move the existing data. In the case of > having to craft a packet from scratch, there is no existing data in the > mbuf, so the whole packet can just be filled in sequentially. [Don't forget > that when you get the mbuf from rte_pktmbuf_alloc, you also need to set the > length value to the appropriate size.] > > However, if you first write the data to the mbuf and then want to add the > headers in order, like a packet moving down through layers of a stack, you > can use prepend to add udp, then ip, then your ethernet header, but this > will be no faster than just writing the data directly to the mbuf space, > and may be slightly slower as each prepend call has to just the length > values and data pointer values in the mbuf. Each header prepended also uses > up headroom in the mbuf, so you can only add 128-bytes of headers by > default to each packet. > > In short, if you are creating a single packet, I'd recommend just getting > the data pointer from the returned mbuf and writing directly to that. > > Regards, > /Bruce >
[dpdk-dev] Packet crafting....
> From: sabu kurian [mailto:sabu2kurian at gmail.com] > Sent: Friday, March 14, 2014 11:38 AM > To: Richardson, Bruce > Cc: dev at dpdk.org > Subject: Re: [dpdk-dev] Packet crafting > > Thanks on the reply Richardson. You did mention something like "Don't forget > that when you get the mbuf from > rte_pktmbuf_alloc, you also need to set the length value to the appropriate > size." . > >?Like I'm allocating the mbuf using rte_mbuf . The?rte_mempool_create has >already set the maximum packet size > for a mbuf and the number of mbuf's and all. So do I really need to > use?rte_pktmbuf_alloc ? How are you getting an mbuf from the pool, if not using rte_pktmbuf_alloc? When you have an mbuf, that buffer has a maximum size, generally around 2k. However, the packet inside that buffer is generally smaller than the overall buffer size and you must configure that size, otherwise the PMD, and therefore the NIC, has no idea how much data out of that 2k buffer needs to be transmitted.
[dpdk-dev] Packet crafting....
Ok thanks a lot Richardson. I got your point. What confused me was that the size of MBUF and the maximum size are all passed to 'rte_mempool_create' . rte_pktmbuf_alloc has only one parameter , a pointer to the mbuf pool. I got it cleared now. Thanks for your valuable time. Can you answer my other question ?... like I get a segmentation fault when I try to print the ether_type for a packet. This is the print statement: printf("\n Type is %" PRIu16 , *((uint16_t *)eth_type)); Regards On Fri, Mar 14, 2014 at 5:19 PM, Richardson, Bruce < bruce.richardson at intel.com> wrote: > > > From: sabu kurian [mailto:sabu2kurian at gmail.com] > > Sent: Friday, March 14, 2014 11:38 AM > > To: Richardson, Bruce > > Cc: dev at dpdk.org > > Subject: Re: [dpdk-dev] Packet crafting > > > > Thanks on the reply Richardson. You did mention something like "Don't > forget that when you get the mbuf from > > rte_pktmbuf_alloc, you also need to set the length value to the > appropriate size." . > > > > Like I'm allocating the mbuf using rte_mbuf . The rte_mempool_create has > already set the maximum packet size > > for a mbuf and the number of mbuf's and all. So do I really need to > use rte_pktmbuf_alloc ? > > How are you getting an mbuf from the pool, if not using rte_pktmbuf_alloc? > When you have an mbuf, that buffer has a maximum size, generally around > 2k. However, the packet inside that buffer is generally smaller than the > overall buffer size and you must configure that size, otherwise the PMD, > and therefore the NIC, has no idea how much data out of that 2k buffer > needs to be transmitted. >
[dpdk-dev] Segmentation Fault on printf()
* sabu kurian (sabu2kurian at gmail.com) wrote: > Hello friends, > > I'm trying to print the ether_type for a packet that I captured from a port > on my machine. Suppose 'm' holds the packet. 'm' is of type 'struct > rte_mbuf'. Intels API reference for DPDK says 'ether_type' is of uint16_t. > I used the following code to retrieve ether_type. > > void * eth_type; > struct ether_hdr *eth; > > eth = rte_pktmbuf_mtod(m, struct ether_hdr *); > eth_type = ð->ether_type; > > printf("\n Type is %" PRIu16 , *((uint16_t *)eth_type)); Looks ok, albeit slightly overly complicated. struct ether_hdr *eth; uint16_t eth_type; eth = rte_pktmbuf_mtod(m, struct ether_hdr *); eth_type = eth->ether_type; printf("\n Type is %" PRIu16 , eth_type)); This would remove all the extra casting. Perhaps the mbuf is the problem here. And if so, the above snippet would segfault on eth->ether_type showing you that mbuf is invalid. You could try to (above mtod): rte_pktmbuf_dump(m, sizeof(struct ether_hdr)); as that will show key contents of mbuf and packet data (and do some basic validation along the way). thanks, -chris