Ethernet Products
Determine ramifications of Intel® Ethernet products and technologies
5026 Discussions

Receive Hardware timestamps (Ethernet Controller 82599)

ngrodzitski
Beginner
2,429 Views

I have a server with NIC: Ethernet controller: Intel Corporation 82599 10 Gigabit Dual Port Backplane Connection.

And I caoonot find a definite answer
: Does the NIC support hardware timestamps for tcp packets?

I use the following sample application that accepts connection ans tries  to get timestamps upon first read.

// This is a small no-deps example to do HW-timestamps.
// gcc -o sample_native_app main.c

#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <unistd.h>

#include <linux/net_tstamp.h>

#define MAX_BUF_LEN 1024

void scan_cb_buf(struct msghdr * msg)
{
    struct cmsghdr * cmsg;
    printf("scan_cb_buf...\n");

    cmsg = CMSG_FIRSTHDR(msg);
    if(!cmsg)
        printf("INITIAL CMSG_FIRSTHDR(msg) == NULL\n");

    for (; cmsg; cmsg = CMSG_NXTHDR(msg, cmsg)) {
        printf("!\n");
        if (cmsg->cmsg_level != SOL_SOCKET)
            continue;

        printf("!!\n");

        switch (cmsg->cmsg_type) {
            case SO_TIMESTAMPNS:
            case SO_TIMESTAMPING: {
                struct timespec *stamp =
                   (struct timespec *)CMSG_DATA(cmsg);
                printf("ts[0] %ld.%06ld\n",
                    (long)stamp[0].tv_sec, (long)stamp[0].tv_nsec);
                printf("ts[1] %ld.%06ld\n",
                    (long)stamp[1].tv_sec, (long)stamp[1].tv_nsec);
                printf("ts[2] %ld.%06ld\n",
                    (long)stamp[2].tv_sec, (long)stamp[2].tv_nsec);
            }
                break;
            default:
                printf("???\n");
                break;
        }
    }

    {
        struct timespec tp;


        clock_gettime(CLOCK_REALTIME, &tp);
        printf("CLOCK_REALTIME ts %ld.%06ld\n", (long)tp.tv_sec, (long)tp.tv_nsec);

        clock_gettime(CLOCK_MONOTONIC, &tp);
        printf("CLOCK_MONOTONIC ts %ld.%06ld\n", (long)tp.tv_sec, (long)tp.tv_nsec);

        clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &tp);
        printf("CLOCK_PROCESS_CPUTIME_ID ts %ld.%06ld\n", (long)tp.tv_sec, (long)tp.tv_nsec);

        clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp);
        printf("CLOCK_THREAD_CPUTIME_ID ts %ld.%06ld\n", (long)tp.tv_sec, (long)tp.tv_nsec);
    }
}


int main(int argc, char** argv) {
    int port = 55055;
    if( argc > 1 )
    {
        port = atoi(argv[1]);
    }

    int server_socket, client_socket, len;
    struct sockaddr_in server_address, client_address;
    char buffer[MAX_BUF_LEN];
    char control_block_buf[MAX_BUF_LEN];
    struct msghdr msg;
    struct iovec iovec_storage;

    iovec_storage.iov_base = buffer;
    iovec_storage.iov_len = MAX_BUF_LEN;

    msg.msg_iov = &iovec_storage;
    msg.msg_iovlen = 1;
    msg.msg_control = control_block_buf;
    msg.msg_controllen = MAX_BUF_LEN;
    msg.msg_name = NULL;
    msg.msg_namelen = 0;

    // Create the server socket
    server_socket = socket(AF_INET, SOCK_STREAM, 0);
    if (server_socket < 0) {
        perror("socket");
        return 1;
    }

    // Set up the server address structure
    memset(&server_address, 0, sizeof(server_address));
    server_address.sin_family = AF_INET;
    server_address.sin_addr.s_addr = INADDR_ANY;
    server_address.sin_port = htons(port);

    // Bind the socket to the address
    if (bind(server_socket, (struct sockaddr*) &server_address, sizeof(server_address)) < 0) {
        perror("bind");
        return 1;
    }

    // Listen for incoming connections
    if (listen(server_socket, 5) < 0) {
        perror("listen");
        return 1;
    }

    printf("TCP server is listening on port %d...\n", port);

    while (1) {
        len = sizeof(client_address);
        client_socket = accept(server_socket, (struct sockaddr*) &client_address, (socklen_t*) &len);
        if (client_socket < 0) {
            perror("accept");
            return 1;
        }

        {
            // int flags = SOF_TIMESTAMPING_RX_HARDWARE | SOF_TIMESTAMPING_RAW_HARDWARE;
            int flags = SOF_TIMESTAMPING_RX_HARDWARE
                        | SOF_TIMESTAMPING_RAW_HARDWARE
                        | SOF_TIMESTAMPING_RX_SOFTWARE
                        | SOF_TIMESTAMPING_SOFTWARE;
            if (setsockopt(client_socket, SOL_SOCKET, SO_TIMESTAMPING, &flags, sizeof(flags)) < 0) {
                perror("setsockopt");
                return 1;
            }
        }

        // Receive data from the client
        memset(buffer, 0, sizeof(buffer));
        int bytes_received = recvmsg(client_socket, &msg, 0);
        scan_cb_buf(&msg);
        // int bytes_received = recv(client_socket, buffer, MAX_BUF_LEN, 0);
        if (bytes_received < 0) {
            perror("recv");
            return 1;
        }

        // Print the received data
        printf("Received: %s\n", buffer);

        // Close the connection
        close(client_socket);
    }

    return 0;
}

 

All my test end up with

ts[2] 0.000000

Which means I don't get the hardware timestamps.

Is there any configuration I'm missing or some environment variables I should provide? Or are the timestamps implemented only for PTP?

Any reference to guides or manuals regarding the topic would be great.

0 Kudos
1 Solution
Yogaeasvaran
Employee
2,105 Views

Hello Mr. Nicolai,


Regarding your case number 05887626, we are following up 3rd time to find out if you were able to complete the actions, we previously recommended.


Please reply to this thread to confirm, so we can continue helping with a resolution. Looking forward to receiving your reply!



Thank You & Regards,


Yogaeasvaran

Intel® Customer Support


View solution in original post

0 Kudos
10 Replies
IntelSupport
Community Manager
2,395 Views

Greetings Mr. Nicolai,

 

Thank you for contacting Intel Customer Support.

 

For us to further check and investigate the issue, please provide the following details.

 

  1. What is your OS?
  2. Can you share the link of the driver that you are using?

 

If you have any further questions or queries, please kindly let us know.

 

 

Thank You & Regards,

 

Yogaeasvaran

Intel® Customer Support 


0 Kudos
ngrodzitski
Beginner
2,392 Views

Hi Yogaeasvaran,

Sure, here it is:

1.

Operating System: AlmaLinux 9.1 (Lime Lynx)           
     CPE OS Name: cpe:/o:almalinux:almalinux:9::baseos
          Kernel: Linux 5.14.0
    Architecture: x86-64
 Hardware Vendor: Dell Inc.
  Hardware Model: PowerEdge M630


2.
Output of ethtool -i eno2

driver: ixgbe
version: 5.14.0
firmware-version: 0x8000093f, 19.5.12
expansion-rom-version: 
bus-info: 0000:01:00.1
supports-statistics: yes
supports-test: yes
supports-eeprom-access: yes
supports-register-dump: yes
supports-priv-flags: yes


Output of modinfo ixgbe

filename:       /lib/modules/5.14.0/kernel/drivers/net/ethernet/intel/ixgbe/ixgbe.ko
license:        GPL v2
description:    Intel(R) 10 Gigabit PCI Express Network Driver
author:         Intel Corporation, <linux.nics@intel.com>
srcversion:     95229965C5033364F64287E
alias:          pci:v00008086d000015E5sv*sd*bc*sc*i*
alias:          pci:v00008086d000015E4sv*sd*bc*sc*i*
alias:          pci:v00008086d000015CEsv*sd*bc*sc*i*
alias:          pci:v00008086d000015C8sv*sd*bc*sc*i*
alias:          pci:v00008086d000015C7sv*sd*bc*sc*i*
alias:          pci:v00008086d000015C6sv*sd*bc*sc*i*
alias:          pci:v00008086d000015C4sv*sd*bc*sc*i*
alias:          pci:v00008086d000015C3sv*sd*bc*sc*i*
alias:          pci:v00008086d000015C2sv*sd*bc*sc*i*
alias:          pci:v00008086d000015AEsv*sd*bc*sc*i*
alias:          pci:v00008086d000015ACsv*sd*bc*sc*i*
alias:          pci:v00008086d000015ADsv*sd*bc*sc*i*
alias:          pci:v00008086d000015ABsv*sd*bc*sc*i*
alias:          pci:v00008086d000015B0sv*sd*bc*sc*i*
alias:          pci:v00008086d000015AAsv*sd*bc*sc*i*
alias:          pci:v00008086d000015D1sv*sd*bc*sc*i*
alias:          pci:v00008086d00001563sv*sd*bc*sc*i*
alias:          pci:v00008086d00001560sv*sd*bc*sc*i*
alias:          pci:v00008086d0000154Asv*sd*bc*sc*i*
alias:          pci:v00008086d00001557sv*sd*bc*sc*i*
alias:          pci:v00008086d00001558sv*sd*bc*sc*i*
alias:          pci:v00008086d0000154Fsv*sd*bc*sc*i*
alias:          pci:v00008086d0000154Dsv*sd*bc*sc*i*
alias:          pci:v00008086d00001528sv*sd*bc*sc*i*
alias:          pci:v00008086d000010F8sv*sd*bc*sc*i*
alias:          pci:v00008086d0000151Csv*sd*bc*sc*i*
alias:          pci:v00008086d00001529sv*sd*bc*sc*i*
alias:          pci:v00008086d0000152Asv*sd*bc*sc*i*
alias:          pci:v00008086d000010F9sv*sd*bc*sc*i*
alias:          pci:v00008086d00001514sv*sd*bc*sc*i*
alias:          pci:v00008086d00001507sv*sd*bc*sc*i*
alias:          pci:v00008086d000010FBsv*sd*bc*sc*i*
alias:          pci:v00008086d00001517sv*sd*bc*sc*i*
alias:          pci:v00008086d000010FCsv*sd*bc*sc*i*
alias:          pci:v00008086d000010F7sv*sd*bc*sc*i*
alias:          pci:v00008086d00001508sv*sd*bc*sc*i*
alias:          pci:v00008086d000010DBsv*sd*bc*sc*i*
alias:          pci:v00008086d000010F4sv*sd*bc*sc*i*
alias:          pci:v00008086d000010E1sv*sd*bc*sc*i*
alias:          pci:v00008086d000010F1sv*sd*bc*sc*i*
alias:          pci:v00008086d000010ECsv*sd*bc*sc*i*
alias:          pci:v00008086d000010DDsv*sd*bc*sc*i*
alias:          pci:v00008086d0000150Bsv*sd*bc*sc*i*
alias:          pci:v00008086d000010C8sv*sd*bc*sc*i*
alias:          pci:v00008086d000010C7sv*sd*bc*sc*i*
alias:          pci:v00008086d000010C6sv*sd*bc*sc*i*
alias:          pci:v00008086d000010B6sv*sd*bc*sc*i*
depends:        mdio,dca
retpoline:      Y
intree:         Y
name:           ixgbe
vermagic:       5.14.0 SMP mod_unload 
sig_id:         PKCS#7
signer:         Build time autogenerated kernel key
sig_key:        2E:8C:17:49:63:C8:3D:3E:B7:C4:36:7D:73:F4:32:41:33:BA:F8:0E
sig_hashalgo:   sha512
signature:      19:A4:BD:DE:57:5F:BC:31:39:2F:39:68:01:0C:1E:91:E8:FD:DA:82:
		4B:93:9D:68:AA:CA:F7:7E:F3:A5:83:56:9E:80:6C:C8:E7:B0:0A:2B:
		FA:0C:23:50:6A:6B:7E:39:28:B8:33:EA:F7:51:AD:EC:FD:0C:BB:7A:
		23:C9:A9:50:6E:85:57:75:4C:5A:92:E1:D8:FE:39:E0:A0:5D:B5:B7:
		4B:2E:BB:83:76:01:A1:80:C8:C2:37:28:0F:5D:66:2D:21:2A:32:F7:
		F5:76:3F:E2:89:3D:88:97:5A:F9:6F:24:65:BB:29:74:28:0F:93:92:
		35:5B:94:74:92:13:2E:59:EA:53:4A:CC:F3:5E:29:BF:E0:E1:41:F7:
		85:3C:86:22:5E:DE:E5:4E:E0:4F:1E:E3:B7:46:19:05:27:FF:3F:09:
		92:8E:57:C2:44:1D:0A:B3:91:AF:ED:A7:DA:0A:8D:C3:4A:0B:F5:BD:
		C5:E3:EA:BA:35:40:27:F7:E8:19:A6:45:9E:79:F2:33:77:FC:97:40:
		84:BD:A6:0C:15:84:5B:51:82:DB:A3:EA:77:85:71:D5:50:92:F7:92:
		AC:54:2E:E8:0F:F6:AA:63:23:E2:57:7F:1B:BA:E8:F2:72:3A:C6:7B:
		69:BC:33:E2:3E:1A:0B:1D:9B:2F:76:0E:77:22:62:C1:1A:7B:0F:AA:
		3D:9E:09:9F:68:A2:F6:96:E8:32:7D:CA:F1:BF:E6:E5:B4:01:10:0F:
		B4:46:51:66:68:04:18:FB:E5:BF:1B:35:B3:25:F1:CF:D2:3B:2A:FE:
		AA:C3:2C:19:2E:EC:84:1F:36:E3:BD:73:65:D9:27:96:CE:CA:8C:3F:
		B8:E2:3A:70:05:B9:6B:B0:88:02:12:1E:F9:AD:7A:C2:3F:AA:02:47:
		59:BE:B4:A3:F5:32:52:01:A1:72:3E:CF:CF:A0:0C:95:10:74:8C:FB:
		AF:FA:A4:C8:0E:9F:DA:75:10:F5:5E:96:9E:8B:23:1D:FC:A0:D3:9D:
		D9:F8:AD:7F:D0:F7:7A:89:42:A3:57:3C:BB:C7:28:F4:A5:E9:C1:63:
		91:CA:1E:BA:38:90:02:A8:DB:0E:C6:26:4C:2C:EB:BF:86:4A:28:FA:
		26:08:A8:D4:7A:F5:FD:83:51:72:92:7F:32:A3:24:CB:71:9C:88:73:
		3B:C2:87:1F:DC:BE:CA:E3:23:18:5E:97:18:CB:BD:9F:2E:E0:8D:F7:
		40:6F:BF:6E:B2:09:14:A4:46:1A:6A:1C:EF:54:E2:D4:FD:F5:43:CF:
		2C:C1:4D:F6:A7:70:9B:02:3B:7E:03:0A:D1:FF:44:EF:0B:14:54:28:
		54:55:6B:A8:32:5F:2F:59:4D:47:A9:F6
parm:           max_vfs:Maximum number of virtual functions to allocate per physical function - default is zero and maximum value is 63. (Deprecated) (uint)
parm:           allow_unsupported_sfp:Allow unsupported and untested SFP+ modules on 82599-based adapters (uint)
parm:           debug:Debug level (0=none,...,16=all) (int)

 

0 Kudos
ngrodzitski
Beginner
2,360 Views

And here is output of ethtool -T

 

Time stamping parameters for eno1:
Capabilities:
	hardware-transmit
	software-transmit
	hardware-receive
	software-receive
	software-system-clock
	hardware-raw-clock
PTP Hardware Clock: 0
Hardware Transmit Timestamp Modes:
	off
	on
Hardware Receive Filter Modes:
	none
	ptpv1-l4-sync
	ptpv1-l4-delay-req
	ptpv2-event

 

Do I need PTP Hardware Clock: 1 (not 0) so hw timestamps work? If so is the a configurable and if so then how can I do it?

 

 

 

0 Kudos
IntelSupport
Community Manager
2,333 Views

Greetings Mr. Nicolai,


Thank you for contacting Intel Customer Support.


To assist you further, we kindly request that you provide us with the SSU logs. You can use the following link to obtain the SSU Logs:


https://www.intel.com/content/www/us/en/support/articles/000057926/memory-and-storage.html.


If you have any further questions or queries, please kindly let us know.

 


Thank You & Regards,

Yogaeasvaran

Intel Customer Support


0 Kudos
ngrodzitski
Beginner
2,327 Views

Sure here you go.

I hope here will be an attached file...

0 Kudos
IntelSupport
Community Manager
2,241 Views

Greetings Mr. Nicolai,


The Ethernet Controller 82599 does NOT support ALL packet timestamping.


You could view the link below, Chapter 7.9 for overall timestamping information for more understanding:

https://www.intel.com/content/www/us/en/content-details/331520/intel-82599-10-gigabit-ethernet-controller-datasheet.html



Thank You & Regards

Yogaeasvaran

Intel® Customer Support 


0 Kudos
Yogaeasvaran
Employee
2,184 Views

Hello Mr. Hassan,


Regarding your case number 05887626, we are following up to find out if you were able to get those information's that we recommended previously.


Please reply to this thread to confirm, so we can continue helping with a resolution. Looking forward to receiving your reply!



Thank You & Regards,


Yogaeasvaran

Intel® Customer Support


0 Kudos
Yogaeasvaran
Employee
2,164 Views

Hello Mr. Nicolai,


Regarding your case number 05887626, we are following up to find out if you were able to get those information's that we recommended previously.


Please reply to this thread to confirm, so we can continue helping with a resolution. Looking forward to receiving your reply!



Thank You & Regards,


Yogaeasvaran

Intel® Customer Support


0 Kudos
Yogaeasvaran
Employee
2,106 Views

Hello Mr. Nicolai,


Regarding your case number 05887626, we are following up 3rd time to find out if you were able to complete the actions, we previously recommended.


Please reply to this thread to confirm, so we can continue helping with a resolution. Looking forward to receiving your reply!



Thank You & Regards,


Yogaeasvaran

Intel® Customer Support


0 Kudos
Yogaeasvaran
Employee
2,045 Views

Greetings Mr. Nicolai,


Kindly note that as we have not received any response from our previous follow-ups, we will be closing this request.

If you have any more questions in the future, please don't hesitate to post a new question, as this thread will no longer be monitored.



Thank You & Regards,


Yogaeasvaran

Intel® Customer Support



0 Kudos
Reply