Skip to content

Commit

Permalink
Fix setting range pkt sizes.
Browse files Browse the repository at this point in the history
Signed-off-by: Keith Wiles <keith.wiles@intel.com>
  • Loading branch information
KeithWiles authored and pktgen committed Jun 18, 2024
1 parent 957c10c commit bf32ae8
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 5 deletions.
5 changes: 3 additions & 2 deletions app/pktgen-cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -3606,9 +3606,10 @@ range_set_pkt_size(port_info_t *pinfo, char *what, uint16_t size)
} else {
if (size < RTE_ETHER_MIN_LEN)
size = RTE_ETHER_MIN_LEN;
else if ((pktgen.flags & JUMBO_PKTS_FLAG) && (size > RTE_ETHER_MAX_JUMBO_FRAME_LEN))

if ((pktgen.flags & JUMBO_PKTS_FLAG) && (size > RTE_ETHER_MAX_JUMBO_FRAME_LEN))
size = RTE_ETHER_MAX_JUMBO_FRAME_LEN;
else
else if (size > RTE_ETHER_MAX_LEN)
size = RTE_ETHER_MAX_LEN;

if (pinfo->seq_pkt[RANGE_PKT].ethType == RTE_ETHER_TYPE_IPV6 && size < MIN_v6_PKT_SIZE)
Expand Down
3 changes: 1 addition & 2 deletions app/pktgen-range.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
void
pktgen_range_ctor(range_info_t *range, pkt_seq_t *pkt)
{

if (pkt->ipProto == PG_IPPROTO_TCP) {
if (unlikely(range->tcp_seq_inc != 0)) {
uint32_t seq = pkt->tcp_seq;
Expand Down Expand Up @@ -332,7 +331,7 @@ pktgen_range_ctor(range_info_t *range, pkt_seq_t *pkt)

if (unlikely(range->vlan_id_inc != 0)) {
/* Since VLAN is set to MIN_VLAN_ID, check this and skip first increment
* to maintian the range sequence in sync with other range fields */
* to maintain the range sequence in sync with other range fields */
uint32_t p;
static uint8_t min_vlan_set = 0;

Expand Down
1 change: 0 additions & 1 deletion app/pktgen.c
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,6 @@ pktgen_setup_packets(uint16_t pid)

if (pktgen_tst_port_flags(pinfo, SEND_RANGE_PKTS)) {
idx = RANGE_PKT;
pktgen_range_setup(pinfo);
} else if (pktgen_tst_port_flags(pinfo, SEND_SEQ_PKTS))
idx = FIRST_SEQ_PKT;
else if (pktgen_tst_port_flags(pinfo, (SEND_SINGLE_PKTS | SEND_RANDOM_PKTS)))
Expand Down
57 changes: 57 additions & 0 deletions cfg/2-ports.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
description = 'A Pktgen default simple configuration'

# Setup configuration
setup = {
'exec': (
'sudo', '-E'
),

'devices': (
'03:00.0',
'03:00.1',
),
# UIO module type, igb_uio, vfio-pci or uio_pci_generic
'uio': 'vfio-pci'
}

# Run command and options
run = {
'exec': ('sudo', '-E'),

# Application name and use app_path to help locate the app
'app_name': 'pktgen',

# using (sdk) or (target) for specific variables
# add (app_name) of the application
# Each path is tested for the application
'app_path': (
'./usr/local/bin/%(app_name)s',
'/usr/local/bin/%(app_name)s'
),

'cores': '1,2-4,5-7',
'nrank': '4',
'proc': 'auto',
'log': '7',
'prefix': 'pg',

'allowlist': (
'03:00.0',
'03:00.1',
),

'opts': (
'-v',
'-T',
'-P',
'-G',
#'-j',
),
'map': (
'[2:3-4].0',
'[5:6-7].1',
),

'theme': 'themes/black-yellow.theme',
'loadfile': 'cnet-fwd'
}

12 comments on commit bf32ae8

@liangxwa
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Keith,

Thanks for the fix. But in our test, if a large packet size is configured, e.g., range 0 size 1024 1024 1024 0, the pktgen still doesn't work.

@KeithWiles
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In what way does it not work? The size does not get set or what?

@liangxwa
Copy link

@liangxwa liangxwa commented on bf32ae8 Jun 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I didn't mention the issue clearly. On our intel cascade lake server, if more than 8 cores are used by pktgen to transmit the traffic in range mode with large packet size e.g. 1024, pktgen only sends a few packet then stops as shown by below image. Packet size 64 and 256 can work well.

pktgen start and run command:

./pktgen -l 24-41 -a af:00.0 -- -m "[25-32:33-41].0" -P
range 0 size 1024 1024 1024 0
enable 0 range
start 0

image

If 8 cores or less are used by pktgen to transmit the traffic, then all packet sizes can work well in range mode.

@KeithWiles
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the non-range mode (single) work at all sizes?

@liangxwa
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, non-range mode work at all sizes.

@KeithWiles
Copy link
Collaborator Author

@KeithWiles KeithWiles commented on bf32ae8 Jun 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just noticed the screen shot above has the same source and destination MAC address (for single mode packets) that can cause the NIC to think someone is spoofing packets. Please change the destination address to something else.

Also please look at the range packets they maybe the same way, using the page range command to see the range packet setup. This maybe the error message you are seeing.

@liangxwa
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the response. Changed the destination mac address to something else, but this didn't help. The "page range" looks good with expected ip dst range.

@KeithWiles
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my testing it looks like any packet size greater then 99 bytes is dropped by the NIC even in single packet mode and counted as an error. Maybe the checksums are wrong, will continue looking at the problem. It also seems to count Rx packets as error, but I have not verified the size is the trigger for the error on Rx side.

@KeithWiles
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found the problem the MTU size was set at MIN size :-(

Please checkout the latest version 24.07.0 and let me know if this fixes the problem

@liangxwa
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested latest version 24.07.0. I still saw the same issue I mentioned at the begining. If more than 8 cores are used by pktgen to transmit the traffic in range mode with large packet size e.g. 1024, pktgen only sends a few packet then stops.

@KeithWiles
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most likely this problem is related to the total number of mbufs created as each thread will consume a number of mbufs from the single mbuf pool. We can try to increase the number of mbufs to see if that fixes the problem.

In file app/pktgen-constants.h DEFAULT_MBUFS_PER_PORT_MULTIPLIER we can try increasing the number to 10. You can also try reducing the number of cores and determine when it start working again.

@liangxwa
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. Changed DEFAULT_MBUFS_PER_PORT_MULTIPLIER to 10, the issue is improved. Pktgen now can use more than 8 cores to transmit the traffic in range mode with large packet size e.g. 1024 bytes. Thanks.

Please sign in to comment.