Skip to content

Commit f3816bf

Browse files
committed
Addressed more reviewer's comments
1 parent 47d4fef commit f3816bf

1 file changed

Lines changed: 5 additions & 23 deletions

File tree

src/wolfip.c

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -159,18 +159,6 @@ static inline void fifo_align_tail(struct fifo *f)
159159
f->tail = 0;
160160
}
161161

162-
static struct wolfIP_stats {
163-
uint64_t poll_calls;
164-
uint64_t tx_desc_seen;
165-
uint64_t tx_sent;
166-
uint64_t tx_bytes;
167-
uint64_t tx_filter_block;
168-
uint64_t tx_arp_block;
169-
uint64_t tx_cwnd_block;
170-
uint64_t tx_eagain;
171-
uint64_t tx_push_fail;
172-
} wolfip_stats;
173-
174162
/* TCP TX is a circular buffer and contains an array of full packets */
175163
/* TCP RX only contains application data */
176164

@@ -1800,6 +1788,10 @@ static int tcp_process_ts(struct tsocket *t, const struct wolfIP_tcp_seg *tcp)
18001788
}
18011789

18021790
#define SEQ_DIFF(a,b) ((a - b) > 0x7FFFFFFF) ? (b - a) : (a - b)
1791+
1792+
/* Return true if a <= b
1793+
* Take into account wrapping.
1794+
*/
18031795
static inline int tcp_seq_leq(uint32_t a, uint32_t b)
18041796
{
18051797
return (int32_t)(a - b) <= 0;
@@ -2128,7 +2120,7 @@ static void tcp_rto_cb(void *arg)
21282120
ts->sock.tcp.tmr_rto = NO_TIMER;
21292121
}
21302122
if (pending) {
2131-
ts->sock.tcp.rto_backoff++;
2123+
ts->sock.tcp.rto_backoff++;
21322124
ts->sock.tcp.cwnd = TCP_MSS;
21332125
ts->sock.tcp.ssthresh = ts->sock.tcp.cwnd / 2;
21342126

@@ -2453,7 +2445,6 @@ int wolfIP_sock_sendto(struct wolfIP *s, int sockfd, const void *buf, size_t len
24532445
ts->sock.tcp.seq += payload_len;
24542446
}
24552447
if (sent == 0) {
2456-
wolfip_stats.tx_eagain++;
24572448
return -WOLFIP_EAGAIN;
24582449
} else
24592450
return sent;
@@ -4052,7 +4043,6 @@ int wolfIP_poll(struct wolfIP *s, uint64_t now)
40524043
struct wolfIP_timer tmr;
40534044
memset(buf, 0, LINK_MTU);
40544045

4055-
wolfip_stats.poll_calls++;
40564046
s->last_tick = now;
40574047

40584048
/* Step 1: Poll the device */
@@ -4108,7 +4098,6 @@ int wolfIP_poll(struct wolfIP *s, uint64_t now)
41084098
desc = fifo_peek(&ts->sock.tcp.txbuf);
41094099
while (desc) {
41104100
unsigned int tx_if = wolfIP_socket_if_idx(ts);
4111-
wolfip_stats.tx_desc_seen++;
41124101
tcp = (struct wolfIP_tcp_seg *)(ts->txmem + desc->pos + sizeof(*desc));
41134102
if (desc->flags & PKT_FLAG_SENT) {
41144103
desc = fifo_next(&ts->sock.tcp.txbuf, desc);
@@ -4123,7 +4112,6 @@ int wolfIP_poll(struct wolfIP *s, uint64_t now)
41234112
memcpy(ts->nexthop_mac, loop->mac, 6);
41244113
} else if (arp_lookup(s, tx_if, nexthop, ts->nexthop_mac) < 0) {
41254114
/* Send ARP request */
4126-
wolfip_stats.tx_arp_block++;
41274115
arp_request(s, tx_if, nexthop);
41284116
break;
41294117
}
@@ -4150,16 +4138,13 @@ int wolfIP_poll(struct wolfIP *s, uint64_t now)
41504138
tcp->win = ee16(tcp_adv_win(ts));
41514139
ip_output_add_header(ts, (struct wolfIP_ip_packet *)tcp, WI_IPPROTO_TCP, size);
41524140
if (wolfIP_filter_notify_tcp(WOLFIP_FILT_SENDING, ts->S, tx_if, tcp, desc->len) != 0) {
4153-
wolfip_stats.tx_filter_block++;
41544141
break;
41554142
}
41564143
if (wolfIP_filter_notify_ip(WOLFIP_FILT_SENDING, ts->S, tx_if, &tcp->ip, desc->len) != 0) {
4157-
wolfip_stats.tx_filter_block++;
41584144
break;
41594145
}
41604146
#ifdef ETHERNET
41614147
if (wolfIP_filter_notify_eth(WOLFIP_FILT_SENDING, ts->S, tx_if, &tcp->ip.eth, desc->len) != 0) {
4162-
wolfip_stats.tx_filter_block++;
41634148
break;
41644149
}
41654150
#endif
@@ -4169,8 +4154,6 @@ int wolfIP_poll(struct wolfIP *s, uint64_t now)
41694154
ll->send(ll, tcp, desc->len);
41704155
}
41714156
}
4172-
wolfip_stats.tx_sent++;
4173-
wolfip_stats.tx_bytes += desc->len;
41744157
desc->flags |= PKT_FLAG_SENT;
41754158
desc->time_sent = now;
41764159
if (size == IP_HEADER_LEN + (uint32_t)(tcp->hlen >> 2)) {
@@ -4190,7 +4173,6 @@ int wolfIP_poll(struct wolfIP *s, uint64_t now)
41904173
desc = fifo_next(&ts->sock.tcp.txbuf, desc);
41914174
}
41924175
} else {
4193-
wolfip_stats.tx_cwnd_block++;
41944176
break;
41954177
}
41964178
}

0 commit comments

Comments
 (0)