-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathlinux-net-for-4.14.113.patch
222 lines (208 loc) · 8.97 KB
/
linux-net-for-4.14.113.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
From 8b0e3cb51f0c24dbf2f04c8f5659ac495a36af5d Mon Sep 17 00:00:00 2001
From: Dongli Zhang <dongli.zhang0129@gmail.com>
Date: Mon, 17 Jun 2019 13:27:09 +0800
Subject: [PATCH 1/1] linux-net-for-4.14.113
Signed-off-by: Dongli Zhang <dongli.zhangi0129@gmail.com>
---
drivers/net/ethernet/intel/igb/igb_main.c | 5 +++
include/linux/netdevice.h | 30 +++++++++++++++
net/sched/sch_generic.c | 64 +++++++++++++++++++++++++++++++
3 files changed, 99 insertions(+)
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index 8892ea5..c7ea2a7 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -7096,6 +7096,11 @@ static bool igb_clean_tx_irq(struct igb_q_vector *q_vector, int napi_budget)
* sees the new next_to_clean.
*/
smp_mb();
+ /*
+ * igb调用netif_wake_subqueue()的例子:
+ * - drivers/net/ethernet/intel/igb/igb_main.c|5187| <<__igb_maybe_stop_tx>> netif_wake_subqueue(netdev, tx_ring->queue_index);
+ * - drivers/net/ethernet/intel/igb/igb_main.c|7102| <<igb_clean_tx_irq>> netif_wake_subqueue(tx_ring->netdev,
+ */
if (__netif_subqueue_stopped(tx_ring->netdev,
tx_ring->queue_index) &&
!(test_bit(__IGB_DOWN, &adapter->state))) {
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 40b830d..efd791c 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -532,7 +532,17 @@ enum netdev_queue_state_t {
#define QUEUE_STATE_STACK_XOFF (1 << __QUEUE_STATE_STACK_XOFF)
#define QUEUE_STATE_FROZEN (1 << __QUEUE_STATE_FROZEN)
+/*
+ * 在以下使用:
+ * - include/linux/netdevice.h|536| <<QUEUE_STATE_ANY_XOFF_OR_FROZEN>> #define QUEUE_STATE_ANY_XOFF_OR_FROZEN (QUEUE_STATE_ANY_XOFF | \
+ * - include/linux/netdevice.h|2923| <<netif_xmit_stopped>> return dev_queue->state & QUEUE_STATE_ANY_XOFF;
+ * - net/core/dev.c|2484| <<netif_schedule_queue>> if (!(txq->state & QUEUE_STATE_ANY_XOFF)) {
+ */
#define QUEUE_STATE_ANY_XOFF (QUEUE_STATE_DRV_XOFF | QUEUE_STATE_STACK_XOFF)
+/*
+ * 在以下使用:
+ * - include/linux/netdevice.h|2929| <<netif_xmit_frozen_or_stopped>> return dev_queue->state & QUEUE_STATE_ANY_XOFF_OR_FROZEN;
+ */
#define QUEUE_STATE_ANY_XOFF_OR_FROZEN (QUEUE_STATE_ANY_XOFF | \
QUEUE_STATE_FROZEN)
#define QUEUE_STATE_DRV_XOFF_OR_FROZEN (QUEUE_STATE_DRV_XOFF | \
@@ -575,6 +585,12 @@ struct netdev_queue {
/*
* Time (in jiffies) of last Tx
*/
+ /*
+ * 在以下修改netdev_queue->trans_start:
+ * - include/linux/netdevice.h|3584| <<txq_trans_update>> txq->trans_start = jiffies;
+ * - include/linux/netdevice.h|3593| <<netif_trans_update>> txq->trans_start = jiffies;
+ * - net/sched/sch_generic.c|861| <<transition_one_qdisc>> dev_queue->trans_start = 0;
+ */
unsigned long trans_start;
unsigned long state;
@@ -3154,6 +3170,11 @@ static inline bool netif_subqueue_stopped(const struct net_device *dev,
*
* Resume individual transmit queue of a device with multiple transmit queues.
*/
+/*
+ * igb调用的例子:
+ * - drivers/net/ethernet/intel/igb/igb_main.c|5187| <<__igb_maybe_stop_tx>> netif_wake_subqueue(netdev, tx_ring->queue_index);
+ * - drivers/net/ethernet/intel/igb/igb_main.c|7102| <<igb_clean_tx_irq>> netif_wake_subqueue(tx_ring->netdev,
+ */
static inline void netif_wake_subqueue(struct net_device *dev, u16 queue_index)
{
struct netdev_queue *txq = netdev_get_tx_queue(dev, queue_index);
@@ -3568,6 +3589,10 @@ static inline void __netif_tx_unlock_bh(struct netdev_queue *txq)
spin_unlock_bh(&txq->_xmit_lock);
}
+/*
+ * called by:
+ * - include/linux/netdevice.h|4060| <<netdev_start_xmit>> txq_trans_update(txq);
+ */
static inline void txq_trans_update(struct netdev_queue *txq)
{
if (txq->xmit_lock_owner != -1)
@@ -3575,6 +3600,11 @@ static inline void txq_trans_update(struct netdev_queue *txq)
}
/* legacy drivers only, netdev_start_xmit() sets txq->trans_start */
+/*
+ * called by:
+ * - drivers/net/ethernet/intel/ixgbe/ixgbe_main.c|5610| <<ixgbe_reinit_locked>> netif_trans_update(adapter->netdev);
+ * - net/sched/sch_generic.c|894| <<dev_activate>> netif_trans_update(dev);
+ */
static inline void netif_trans_update(struct net_device *dev)
{
struct netdev_queue *txq = netdev_get_tx_queue(dev, 0);
diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
index 79549ba..cd5481c 100644
--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
@@ -288,12 +288,34 @@ unsigned long dev_trans_start(struct net_device *dev)
}
EXPORT_SYMBOL(dev_trans_start);
+/*
+ * used by:
+ * - net/sched/sch_generic.c|973| <<dev_init_scheduler>> setup_timer(&dev->watchdog_timer, dev_watchdog, (unsigned long )dev);
+ *
+ * 似乎主要在以下使用:
+ * - net/sched/sch_generic.c|323| <<dev_watchdog>> if (!mod_timer(&dev->watchdog_timer,
+ * - net/sched/sch_generic.c|339| <<__netdev_watchdog_up>> if (!mod_timer(&dev->watchdog_timer,
+ * - net/sched/sch_generic.c|353| <<dev_watchdog_down>> if (del_timer(&dev->watchdog_timer))
+ * - net/sched/sch_generic.c|973| <<dev_init_scheduler>> setup_timer(&dev->watchdog_timer, dev_watchdog, (unsigned long )dev);
+ * - net/sched/sch_generic.c|999| <<dev_shutdown>> WARN_ON(timer_pending(&dev->watchdog_timer));
+ */
static void dev_watchdog(unsigned long arg)
{
struct net_device *dev = (struct net_device *)arg;
netif_tx_lock(dev);
+ /* Is the device using the noop qdisc on all queues? */
if (!qdisc_tx_is_noop(dev)) {
+ /*
+ * netif_device_present():
+ * net_device->state设置了__LINK_STATE_PRESENT
+ *
+ * netif_running():
+ * net_device->state设置了__LINK_STATE_START
+ *
+ * netif_carrier_ok():
+ * net_device->state设置了__LINK_STATE_NOCARRIER
+ */
if (netif_device_present(dev) &&
netif_running(dev) &&
netif_carrier_ok(dev)) {
@@ -304,8 +326,22 @@ static void dev_watchdog(unsigned long arg)
for (i = 0; i < dev->num_tx_queues; i++) {
struct netdev_queue *txq;
+ /* 返回net_device->_tx[index] */
txq = netdev_get_tx_queue(dev, i);
+ /*
+ * 在以下修改netdev_queue->trans_start:
+ * - include/linux/netdevice.h|3584| <<txq_trans_update>> txq->trans_start = jiffies;
+ * - include/linux/netdevice.h|3593| <<netif_trans_update>> txq->trans_start = jiffies;
+ * - net/sched/sch_generic.c|861| <<transition_one_qdisc>> dev_queue->trans_start = 0;
+ */
trans_start = txq->trans_start;
+ /*
+ * igb设置net_device->watchdog_timeo的例子:
+ * - drivers/net/ethernet/intel/igb/igb_main.c|2389| <<igb_probe>> netdev->watchdog_timeo = 5 * HZ;
+ * - drivers/net/ethernet/intel/igbvf/netdev.c|2813| <<igbvf_probe>> netdev->watchdog_timeo = 5 * HZ;
+ *
+ * netif_tx_stop_queue()和netif_stop_queue()不知道有没有关系
+ */
if (netif_xmit_stopped(txq) &&
time_after(jiffies, (trans_start +
dev->watchdog_timeo))) {
@@ -315,9 +351,19 @@ static void dev_watchdog(unsigned long arg)
}
}
+ /*
+ * some_queue_timedout只在上面一处更新
+ */
if (some_queue_timedout) {
WARN_ONCE(1, KERN_INFO "NETDEV WATCHDOG: %s (%s): transmit queue %u timed out\n",
dev->name, netdev_drivername(dev), i);
+ /*
+ * 几个ndo_tx_timeout的例子:
+ * - drivers/net/ethernet/intel/e1000/e1000_main.c|857| <<global>> .ndo_tx_timeout = e1000_tx_timeout,
+ * - drivers/net/ethernet/intel/e1000e/netdev.c|7017| <<global>> .ndo_tx_timeout = e1000_tx_timeout,
+ * - drivers/net/ethernet/intel/igb/igb_main.c|2162| <<global>> .ndo_tx_timeout = igb_tx_timeout,
+ * - drivers/net/ethernet/intel/igbvf/netdev.c|2710| <<global>> .ndo_tx_timeout = igbvf_tx_timeout,
+ */
dev->netdev_ops->ndo_tx_timeout(dev);
}
if (!mod_timer(&dev->watchdog_timer,
@@ -331,6 +377,12 @@ static void dev_watchdog(unsigned long arg)
dev_put(dev);
}
+/*
+ * called by:
+ * - net/core/dev.c|2564| <<netif_device_attach>> __netdev_watchdog_up(dev);
+ * - net/sched/sch_generic.c|375| <<dev_watchdog_up>> __netdev_watchdog_up(dev);
+ * - net/sched/sch_generic.c|400| <<netif_carrier_on>> __netdev_watchdog_up(dev);
+ */
void __netdev_watchdog_up(struct net_device *dev)
{
if (dev->netdev_ops->ndo_tx_timeout) {
@@ -817,6 +869,14 @@ static void transition_one_qdisc(struct net_device *dev,
}
}
+/*
+ * called by:
+ * - net/core/dev.c|1380| <<__dev_open>> dev_activate(dev);
+ * - net/core/link_watch.c|160| <<linkwatch_do_dev>> dev_activate(dev);
+ * - net/sched/sch_api.c|953| <<qdisc_graft>> dev_activate(dev);
+ * - net/sched/sch_mq.c|157| <<mq_graft>> dev_activate(dev);
+ * - net/sched/sch_mqprio.c|221| <<mqprio_graft>> dev_activate(dev);
+ */
void dev_activate(struct net_device *dev)
{
int need_watchdog;
@@ -963,6 +1023,10 @@ static void dev_init_scheduler_queue(struct net_device *dev,
dev_queue->qdisc_sleeping = qdisc;
}
+/*
+ * called by:
+ * - net/core/dev.c|7681| <<register_netdevice>> dev_init_scheduler(dev);
+ */
void dev_init_scheduler(struct net_device *dev)
{
dev->qdisc = &noop_qdisc;
--
2.7.4