70
70
struct lo_driver_s
71
71
{
72
72
bool lo_bifup ; /* true:ifup false:ifdown */
73
- bool lo_txdone ; /* One RX packet was looped back */
74
73
struct work_s lo_work ; /* For deferring poll work to the work queue */
75
74
76
75
/* This holds the information visible to the NuttX network */
@@ -89,10 +88,6 @@ static uint8_t g_iobuffer[NET_LO_PKTSIZE + CONFIG_NET_GUARDSIZE];
89
88
* Private Function Prototypes
90
89
****************************************************************************/
91
90
92
- /* Polling logic */
93
-
94
- static int lo_txpoll (FAR struct net_driver_s * dev );
95
-
96
91
/* NuttX callback functions */
97
92
98
93
static int lo_ifup (FAR struct net_driver_s * dev );
@@ -108,80 +103,6 @@ static int lo_rmmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac);
108
103
* Private Functions
109
104
****************************************************************************/
110
105
111
- /****************************************************************************
112
- * Name: lo_txpoll
113
- *
114
- * Description:
115
- * Check if the network has any outgoing packets ready to send. This is
116
- * a callback from devif_poll(). devif_poll() will be called only during
117
- * normal TX polling.
118
- *
119
- * Input Parameters:
120
- * dev - Reference to the NuttX driver state structure
121
- *
122
- * Returned Value:
123
- * OK on success; a negated errno on failure
124
- *
125
- * Assumptions:
126
- * May or may not be called from an interrupt handler. In either case,
127
- * the network is locked.
128
- *
129
- ****************************************************************************/
130
-
131
- static int lo_txpoll (FAR struct net_driver_s * dev )
132
- {
133
- FAR struct lo_driver_s * priv = (FAR struct lo_driver_s * )dev -> d_private ;
134
-
135
- /* Loop while there is data "sent", i.e., while d_len > 0. That should be
136
- * the case upon entry here and while the processing of the IPv4/6 packet
137
- * generates a new packet to be sent. Sending, of course, just means
138
- * relaying back through the network for this driver.
139
- */
140
-
141
- while (priv -> lo_dev .d_len > 0 )
142
- {
143
- NETDEV_TXPACKETS (& priv -> lo_dev );
144
- NETDEV_RXPACKETS (& priv -> lo_dev );
145
-
146
- #ifdef CONFIG_NET_PKT
147
- /* When packet sockets are enabled, feed the frame into the tap */
148
-
149
- pkt_input (& priv -> lo_dev );
150
- #endif
151
-
152
- /* We only accept IP packets of the configured type and ARP packets */
153
-
154
- #ifdef CONFIG_NET_IPv4
155
- if ((IPv4BUF -> vhl & IP_VERSION_MASK ) == IPv4_VERSION )
156
- {
157
- ninfo ("IPv4 frame\n" );
158
- NETDEV_RXIPV4 (& priv -> lo_dev );
159
- ipv4_input (& priv -> lo_dev );
160
- }
161
- else
162
- #endif
163
- #ifdef CONFIG_NET_IPv6
164
- if ((IPv6BUF -> vtc & IP_VERSION_MASK ) == IPv6_VERSION )
165
- {
166
- ninfo ("IPv6 frame\n" );
167
- NETDEV_RXIPV6 (& priv -> lo_dev );
168
- ipv6_input (& priv -> lo_dev );
169
- }
170
- else
171
- #endif
172
- {
173
- nwarn ("WARNING: Unrecognized IP version\n" );
174
- NETDEV_RXDROPPED (& priv -> lo_dev );
175
- priv -> lo_dev .d_len = 0 ;
176
- }
177
-
178
- priv -> lo_txdone = true;
179
- NETDEV_TXDONE (& priv -> lo_dev );
180
- }
181
-
182
- return 0 ;
183
- }
184
-
185
106
/****************************************************************************
186
107
* Name: lo_ifup
187
108
*
@@ -275,14 +196,11 @@ static void lo_txavail_work(FAR void *arg)
275
196
net_lock ();
276
197
if (priv -> lo_bifup )
277
198
{
278
- do
279
- {
280
- /* If so, then poll the network for new XMIT data */
281
-
282
- priv -> lo_txdone = false;
283
- devif_poll (& priv -> lo_dev , lo_txpoll );
284
- }
285
- while (priv -> lo_txdone );
199
+ /* Reuse the devif_loopback() logic, Polling all pending events until
200
+ * return stop
201
+ */
202
+
203
+ while (devif_poll (& priv -> lo_dev , NULL ));
286
204
}
287
205
288
206
net_unlock ();
0 commit comments