net: Remove support for CONFIG_NET_CONTEXT_TIMESTAMP option

This option was only able to collect statistics of transmitted
data. The same functionality is available if one sets the
CONFIG_NET_PKT_RXTIME_STATS and/or CONFIG_NET_PKT_TXTIME_STATS
options.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
Jukka Rissanen 2021-04-22 11:04:04 +03:00 committed by Jukka Rissanen
commit 9f2fa87e05
14 changed files with 22 additions and 208 deletions

View file

@ -92,6 +92,13 @@ Deprecated in this release
* :c:func:`flash_write_protection_set()`.
* The ``CONFIG_NET_CONTEXT_TIMESTAMP`` is removed as it was only able to work
with transmitted data. The same functionality can be achieved by setting
``CONFIG_NET_PKT_RXTIME_STATS`` and ``CONFIG_NET_PKT_TXTIME_STATS`` options.
These options are also able to calculate the RX & TX times more accurately.
This means that support for the SO_TIMESTAMPING socket option is also removed
as it was used by the removed config option.
==========================
Removed APIs in this release

View file

@ -298,9 +298,6 @@ __net_socket struct net_context {
/** Priority of the network data sent via this net_context */
uint8_t priority;
#endif
#if defined(CONFIG_NET_CONTEXT_TIMESTAMP)
bool timestamp;
#endif
#if defined(CONFIG_NET_CONTEXT_TXTIME)
bool txtime;
#endif
@ -1059,11 +1056,10 @@ int net_context_update_recv_wnd(struct net_context *context,
enum net_context_option {
NET_OPT_PRIORITY = 1,
NET_OPT_TIMESTAMP = 2,
NET_OPT_TXTIME = 3,
NET_OPT_SOCKS5 = 4,
NET_OPT_RCVTIMEO = 5,
NET_OPT_SNDTIMEO = 6,
NET_OPT_TXTIME = 2,
NET_OPT_SOCKS5 = 3,
NET_OPT_RCVTIMEO = 4,
NET_OPT_SNDTIMEO = 5,
};
/**

View file

@ -316,14 +316,6 @@ struct net_stats {
struct net_stats_tc tc;
#endif
#if defined(CONFIG_NET_CONTEXT_TIMESTAMP) && \
defined(CONFIG_NET_PKT_TXTIME_STATS)
#error \
"Cannot define both CONFIG_NET_CONTEXT_TIMESTAMP and CONFIG_NET_PKT_TXTIME_STATS"
#endif
#if defined(CONFIG_NET_CONTEXT_TIMESTAMP) || \
defined(CONFIG_NET_PKT_TXTIME_STATS) || \
defined(CONFIG_NET_PKT_RXTIME_STATS)
#if defined(CONFIG_NET_PKT_TXTIME_STATS)
/** Network packet TX time statistics */
struct net_stats_tx_time tx_time;
@ -342,7 +334,6 @@ struct net_stats {
/** Network packet RX time detail statistics */
struct net_stats_rx_time rx_time_detail[NET_PKT_DETAIL_STATS_COUNT];
#endif
#endif
#if defined(CONFIG_NET_STATISTICS_POWER_MANAGEMENT)
struct net_stats_pm pm;

View file

@ -77,12 +77,6 @@ static int start_udp_proto(struct data *data, struct sockaddr *bind_addr,
}
#endif
#if defined(CONFIG_NET_CONTEXT_TIMESTAMP)
bool val = 1;
setsockopt(data->udp.sock, SOL_SOCKET, SO_TIMESTAMPING, &val, sizeof(val));
#endif
ret = bind(data->udp.sock, bind_addr, bind_addrlen);
if (ret < 0) {
NET_ERR("Failed to bind UDP socket (%s): %d", data->proto,

View file

@ -527,13 +527,6 @@ config NET_CONTEXT_PRIORITY
It is possible to prioritize network traffic. This requires
also traffic class support to work as expected.
config NET_CONTEXT_TIMESTAMP
bool "Add timestamp support to net_context"
select NET_PKT_TIMESTAMP
help
It is possible to timestamp outgoing packets and get information
about these timestamps.
config NET_CONTEXT_TXTIME
bool "Add TXTIME support to net_context"
select NET_PKT_TXTIME

View file

@ -1165,22 +1165,6 @@ static int get_context_priority(struct net_context *context,
#endif
}
static int get_context_timepstamp(struct net_context *context,
void *value, size_t *len)
{
#if defined(CONFIG_NET_CONTEXT_TIMESTAMP)
*((bool *)value) = context->options.timestamp;
if (len) {
*len = sizeof(bool);
}
return 0;
#else
return -ENOTSUP;
#endif
}
static int get_context_proxy(struct net_context *context,
void *value, size_t *len)
{
@ -1205,23 +1189,6 @@ static int get_context_proxy(struct net_context *context,
#endif
}
#if defined(CONFIG_NET_CONTEXT_TIMESTAMP)
int net_context_get_timestamp(struct net_context *context,
struct net_pkt *pkt,
struct net_ptp_time *timestamp)
{
bool is_timestamped;
get_context_timepstamp(context, &is_timestamped, NULL);
if (is_timestamped) {
memcpy(timestamp, net_pkt_timestamp(pkt), sizeof(*timestamp));
return 0;
}
return -ENOENT;
}
#endif /* CONFIG_NET_CONTEXT_TIMESTAMP */
static int get_context_txtime(struct net_context *context,
void *value, size_t *len)
{
@ -1660,36 +1627,6 @@ static int context_sendto(struct net_context *context,
net_pkt_set_priority(pkt, priority);
}
if (IS_ENABLED(CONFIG_NET_CONTEXT_TIMESTAMP)) {
bool timestamp;
get_context_timepstamp(context, &timestamp, NULL);
if (timestamp) {
struct net_ptp_time tp = {
/* Use the nanosecond field to temporarily
* store the cycle count as it is a 32-bit
* variable. The value is checked in
* net_if.c:net_if_tx()
*
* The net_pkt timestamp field is used in two
* roles here:
* 1) To calculate how long it takes the packet
* from net_context to be sent by the
* network device driver.
* 2) gPTP enabled Ethernet device driver will
* use the value to tell gPTP what time the
* packet was sent.
*
* Because these two things are happening at
* different times, we can share the variable.
*/
.nanosecond = k_cycle_get_32(),
};
net_pkt_set_timestamp(pkt, &tp);
}
}
/* If there is ancillary data in msghdr, then we need to add that
* to net_pkt as there is no other way to store it.
*/
@ -2190,22 +2127,6 @@ static int set_context_priority(struct net_context *context,
#endif
}
static int set_context_timestamp(struct net_context *context,
const void *value, size_t len)
{
#if defined(CONFIG_NET_CONTEXT_TIMESTAMP)
if (len > sizeof(bool)) {
return -EINVAL;
}
context->options.timestamp = *((bool *)value);
return 0;
#else
return -ENOTSUP;
#endif
}
static int set_context_txtime(struct net_context *context,
const void *value, size_t len)
{
@ -2295,9 +2216,6 @@ int net_context_set_option(struct net_context *context,
case NET_OPT_PRIORITY:
ret = set_context_priority(context, value, len);
break;
case NET_OPT_TIMESTAMP:
ret = set_context_timestamp(context, value, len);
break;
case NET_OPT_TXTIME:
ret = set_context_txtime(context, value, len);
break;
@ -2335,9 +2253,6 @@ int net_context_get_option(struct net_context *context,
case NET_OPT_PRIORITY:
ret = get_context_priority(context, value, len);
break;
case NET_OPT_TIMESTAMP:
ret = get_context_timepstamp(context, value, len);
break;
case NET_OPT_TXTIME:
ret = get_context_txtime(context, value, len);
break;

View file

@ -214,7 +214,6 @@ static bool net_if_tx(struct net_if *iface, struct net_pkt *pkt)
/* Timestamp of the current network packet sent if enabled */
struct net_ptp_time start_timestamp;
uint32_t curr_time = 0;
/* We collect send statistics for each socket priority if enabled */
uint8_t pkt_priority;
@ -247,15 +246,6 @@ static bool net_if_tx(struct net_if *iface, struct net_pkt *pkt)
net_pkt_set_queued(pkt, false);
}
if (IS_ENABLED(CONFIG_NET_CONTEXT_TIMESTAMP) && context) {
if (net_context_get_timestamp(context, pkt,
&start_timestamp) < 0) {
start_timestamp.nanosecond = 0;
} else {
pkt_priority = net_pkt_priority(pkt);
}
}
if (IS_ENABLED(CONFIG_NET_PKT_TXTIME_STATS)) {
memcpy(&start_timestamp, net_pkt_timestamp(pkt),
sizeof(start_timestamp));
@ -271,13 +261,6 @@ static bool net_if_tx(struct net_if *iface, struct net_pkt *pkt)
status = net_if_l2(iface)->send(iface, pkt);
if (IS_ENABLED(CONFIG_NET_CONTEXT_TIMESTAMP) && status >= 0 &&
context) {
if (start_timestamp.nanosecond > 0) {
curr_time = k_cycle_get_32();
}
}
if (IS_ENABLED(CONFIG_NET_PKT_TXTIME_STATS)) {
uint32_t end_tick = k_cycle_get_32();
@ -326,18 +309,6 @@ static bool net_if_tx(struct net_if *iface, struct net_pkt *pkt)
context, status);
net_context_send_cb(context, status);
if (IS_ENABLED(CONFIG_NET_CONTEXT_TIMESTAMP) && status >= 0 &&
start_timestamp.nanosecond && curr_time > 0) {
/* So we know now how long the network packet was in
* transit from when it was allocated to when we
* got information that it was sent successfully.
*/
net_stats_update_tc_tx_time(iface,
pkt_priority,
start_timestamp.nanosecond,
curr_time);
}
}
if (ll_dst.addr) {

View file

@ -96,23 +96,6 @@ char *net_sprint_addr(sa_family_t af, const void *addr);
#define net_sprint_ipv6_addr(_addr) net_sprint_addr(AF_INET6, _addr)
#if defined(CONFIG_NET_CONTEXT_TIMESTAMP)
int net_context_get_timestamp(struct net_context *context,
struct net_pkt *pkt,
struct net_ptp_time *timestamp);
#else
static inline int net_context_get_timestamp(struct net_context *context,
struct net_pkt *pkt,
struct net_ptp_time *timestamp)
{
ARG_UNUSED(context);
ARG_UNUSED(pkt);
ARG_UNUSED(timestamp);
return -ENOTSUP;
}
#endif
#if defined(CONFIG_COAP)
/**
* @brief CoAP init function declaration. It belongs here because we don't want

View file

@ -1007,8 +1007,7 @@ static char *get_net_pkt_stats_detail(struct net_if *iface, bool is_tx)
CONFIG_NET_PKT_RXTIME_STATS_DETAIL */
#if defined(CONFIG_NET_PKT_TXTIME_STATS) || \
defined(CONFIG_NET_PKT_RXTIME_STATS) || \
defined(CONFIG_NET_CONTEXT_TIMESTAMP)
defined(CONFIG_NET_PKT_RXTIME_STATS)
#if (NET_TC_TX_COUNT > 1) || (NET_TC_RX_COUNT > 1)
static char *get_net_pkt_tc_stats_detail(struct net_if *iface, int i,
@ -1031,8 +1030,7 @@ static char *get_net_pkt_stats_detail(struct net_if *iface, bool is_tx)
return "\0";
}
#endif
#endif /* CONFIG_NET_PKT_TXTIME_STATS) || CONFIG_NET_PKT_RXTIME_STATS ||
CONFIG_NET_CONTEXT_TIMESTAMP */
#endif /* CONFIG_NET_PKT_TXTIME_STATS) || CONFIG_NET_PKT_RXTIME_STATS */
#endif /* CONFIG_NET_PKT_TXTIME_STATS_DETAIL ||
CONFIG_NET_PKT_RXTIME_STATS_DETAIL */
@ -1043,8 +1041,7 @@ static void print_tc_tx_stats(const struct shell *shell, struct net_if *iface)
PR("TX traffic class statistics:\n");
#if defined(CONFIG_NET_CONTEXT_TIMESTAMP) || \
defined(CONFIG_NET_PKT_TXTIME_STATS)
#if defined(CONFIG_NET_PKT_TXTIME_STATS)
PR("TC Priority\tSent pkts\tbytes\ttime\n");
for (i = 0; i < NET_TC_TX_COUNT; i++) {
@ -1078,7 +1075,7 @@ static void print_tc_tx_stats(const struct shell *shell, struct net_if *iface)
GET_STAT(iface, tc.sent[i].pkts),
GET_STAT(iface, tc.sent[i].bytes));
}
#endif /* CONFIG_NET_CONTEXT_TIMESTAMP */
#endif /* CONFIG_NET_PKT_TXTIME_STATS */
#else
ARG_UNUSED(shell);
@ -1269,14 +1266,6 @@ static void net_shell_print_statistics(struct net_if *iface, void *user_data)
PR("TCP pkt drop %d\n", GET_STAT(iface, tcp.drop));
#endif
#if defined(CONFIG_NET_CONTEXT_TIMESTAMP) && defined(CONFIG_NET_NATIVE)
if (GET_STAT(iface, tx_time.count) > 0) {
PR("Network pkt TX time %lu us\n",
(uint32_t)(GET_STAT(iface, tx_time.sum) /
(uint64_t)GET_STAT(iface, tx_time.count)));
}
#endif
PR("Bytes received %u\n", GET_STAT(iface, bytes.received));
PR("Bytes sent %u\n", GET_STAT(iface, bytes.sent));
PR("Processing err %d\n", GET_STAT(iface, processing_error));

View file

@ -324,8 +324,7 @@ static inline void net_stats_update_ipv6_mld_drop(struct net_if *iface)
#define net_stats_update_ipv6_mld_drop(iface)
#endif /* CONFIG_NET_STATISTICS_MLD */
#if (defined(CONFIG_NET_CONTEXT_TIMESTAMP) || \
defined(CONFIG_NET_PKT_TXTIME_STATS)) && defined(CONFIG_NET_STATISTICS)
#if defined(CONFIG_NET_PKT_TXTIME_STATS) && defined(CONFIG_NET_STATISTICS)
static inline void net_stats_update_tx_time(struct net_if *iface,
uint32_t start_time,
uint32_t end_time)
@ -338,7 +337,7 @@ static inline void net_stats_update_tx_time(struct net_if *iface,
}
#else
#define net_stats_update_tx_time(iface, start_time, end_time)
#endif /* (TIMESTAMP || NET_PKT_TXTIME_STATS) && NET_STATISTICS */
#endif /* NET_PKT_TXTIME_STATS && NET_STATISTICS */
#if defined(CONFIG_NET_PKT_TXTIME_STATS_DETAIL)
static inline void net_stats_update_tx_time_detail(struct net_if *iface,
@ -371,7 +370,7 @@ static inline void net_stats_update_rx_time(struct net_if *iface,
}
#else
#define net_stats_update_rx_time(iface, start_time, end_time)
#endif /* NET_CONTEXT_TIMESTAMP && STATISTICS */
#endif /* NET_PKT_RXTIME_STATS && STATISTICS */
#if defined(CONFIG_NET_PKT_RXTIME_STATS_DETAIL)
static inline void net_stats_update_rx_time_detail(struct net_if *iface,
@ -410,8 +409,7 @@ static inline void net_stats_update_tc_sent_priority(struct net_if *iface,
UPDATE_STAT(iface, stats.tc.sent[tc].priority = priority);
}
#if (defined(CONFIG_NET_CONTEXT_TIMESTAMP) || \
defined(CONFIG_NET_PKT_TXTIME_STATS)) && \
#if defined(CONFIG_NET_PKT_TXTIME_STATS) && \
defined(CONFIG_NET_STATISTICS) && defined(CONFIG_NET_NATIVE)
static inline void net_stats_update_tc_tx_time(struct net_if *iface,
uint8_t priority,
@ -429,7 +427,7 @@ static inline void net_stats_update_tc_tx_time(struct net_if *iface,
}
#else
#define net_stats_update_tc_tx_time(iface, tc, start_time, end_time)
#endif /* (NET_CONTEXT_TIMESTAMP || NET_PKT_TXTIME_STATS) && NET_STATISTICS */
#endif /* NET_PKT_TXTIME_STATS && NET_STATISTICS && NET_NATIVE */
#if defined(CONFIG_NET_PKT_TXTIME_STATS_DETAIL)
static inline void net_stats_update_tc_tx_time_detail(struct net_if *iface,
@ -519,8 +517,7 @@ static inline void net_stats_update_tc_recv_priority(struct net_if *iface,
#define net_stats_update_tc_recv_bytes(iface, tc, bytes)
#define net_stats_update_tc_recv_priority(iface, tc, priority)
#if (defined(CONFIG_NET_CONTEXT_TIMESTAMP) || \
defined(CONFIG_NET_PKT_TXTIME_STATS)) && \
#if defined(CONFIG_NET_PKT_TXTIME_STATS) && \
defined(CONFIG_NET_STATISTICS) && defined(CONFIG_NET_NATIVE)
static inline void net_stats_update_tc_tx_time(struct net_if *iface,
uint8_t pkt_priority,
@ -533,7 +530,7 @@ static inline void net_stats_update_tc_tx_time(struct net_if *iface,
}
#else
#define net_stats_update_tc_tx_time(iface, priority, start_time, end_time)
#endif /* (NET_CONTEXT_TIMESTAMP || NET_PKT_TXTIME_STATS) && NET_STATISTICS */
#endif /* NET_PKT_TXTIME_STATS && NET_STATISTICS && NET_NATIVE */
#if defined(CONFIG_NET_PKT_TXTIME_STATS_DETAIL)
static inline void net_stats_update_tc_tx_time_detail(struct net_if *iface,

View file

@ -1744,22 +1744,6 @@ int zsock_setsockopt_ctx(struct net_context *ctx, int level, int optname,
break;
case SO_TIMESTAMPING:
/* Calculate TX network packet timings */
if (IS_ENABLED(CONFIG_NET_CONTEXT_TIMESTAMP)) {
ret = net_context_set_option(ctx,
NET_OPT_TIMESTAMP,
optval, optlen);
if (ret < 0) {
errno = -ret;
return -1;
}
return 0;
}
break;
case SO_RCVTIMEO:
if (IS_ENABLED(CONFIG_NET_CONTEXT_RCVTIMEO)) {
const struct zsock_timeval *tv = optval;

View file

@ -144,7 +144,6 @@ CONFIG_NET_CONTEXT_NET_PKT_POOL=y
CONFIG_NET_CONTEXT_SYNC_RECV=y
CONFIG_NET_CONTEXT_CHECK=y
CONFIG_NET_CONTEXT_PRIORITY=y
CONFIG_NET_CONTEXT_TIMESTAMP=y
# SLIP
CONFIG_NET_SLIP_TAP=y

View file

@ -21,6 +21,5 @@ CONFIG_NET_IPV6_ND=n
CONFIG_ZTEST=y
CONFIG_NET_CONFIG_SETTINGS=n
CONFIG_NET_SHELL=n
CONFIG_NET_CONTEXT_TIMESTAMP=y
CONFIG_NET_PKT_TIMESTAMP=y
CONFIG_NET_PKT_TIMESTAMP_THREAD=y

View file

@ -435,7 +435,6 @@ static void send_some_data(struct net_if *iface)
.sin6_family = AF_INET6,
.sin6_port = 0,
};
bool timestamp = true;
int ret;
ret = net_context_get(AF_INET6, SOCK_DGRAM, IPPROTO_UDP,
@ -452,9 +451,6 @@ static void send_some_data(struct net_if *iface)
ret = add_neighbor(iface, &dst_addr);
zassert_true(ret, "Cannot add neighbor\n");
net_context_set_option(udp_v6_ctx, NET_OPT_TIMESTAMP,
&timestamp, sizeof(timestamp));
ret = net_context_sendto(udp_v6_ctx, test_data, strlen(test_data),
(struct sockaddr *)&dst_addr6,
sizeof(struct sockaddr_in6),