Skip to content

Commit 5f99925

Browse files
amaftei-xilinxdavem330
authored andcommitted
sfc: move event queue management code
Signed-off-by: Alexandru-Mihai Maftei <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 37c45a4 commit 5f99925

File tree

2 files changed

+91
-92
lines changed

2 files changed

+91
-92
lines changed

drivers/net/ethernet/sfc/efx.c

Lines changed: 0 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -128,98 +128,6 @@ static int efx_xdp_xmit(struct net_device *dev, int n, struct xdp_frame **xdpfs,
128128
ASSERT_RTNL(); \
129129
} while (0)
130130

131-
/**************************************************************************
132-
*
133-
* Event queue processing
134-
*
135-
*************************************************************************/
136-
137-
/* Create event queue
138-
* Event queue memory allocations are done only once. If the channel
139-
* is reset, the memory buffer will be reused; this guards against
140-
* errors during channel reset and also simplifies interrupt handling.
141-
*/
142-
int efx_probe_eventq(struct efx_channel *channel)
143-
{
144-
struct efx_nic *efx = channel->efx;
145-
unsigned long entries;
146-
147-
netif_dbg(efx, probe, efx->net_dev,
148-
"chan %d create event queue\n", channel->channel);
149-
150-
/* Build an event queue with room for one event per tx and rx buffer,
151-
* plus some extra for link state events and MCDI completions. */
152-
entries = roundup_pow_of_two(efx->rxq_entries + efx->txq_entries + 128);
153-
EFX_WARN_ON_PARANOID(entries > EFX_MAX_EVQ_SIZE);
154-
channel->eventq_mask = max(entries, EFX_MIN_EVQ_SIZE) - 1;
155-
156-
return efx_nic_probe_eventq(channel);
157-
}
158-
159-
/* Prepare channel's event queue */
160-
int efx_init_eventq(struct efx_channel *channel)
161-
{
162-
struct efx_nic *efx = channel->efx;
163-
int rc;
164-
165-
EFX_WARN_ON_PARANOID(channel->eventq_init);
166-
167-
netif_dbg(efx, drv, efx->net_dev,
168-
"chan %d init event queue\n", channel->channel);
169-
170-
rc = efx_nic_init_eventq(channel);
171-
if (rc == 0) {
172-
efx->type->push_irq_moderation(channel);
173-
channel->eventq_read_ptr = 0;
174-
channel->eventq_init = true;
175-
}
176-
return rc;
177-
}
178-
179-
/* Enable event queue processing and NAPI */
180-
void efx_start_eventq(struct efx_channel *channel)
181-
{
182-
netif_dbg(channel->efx, ifup, channel->efx->net_dev,
183-
"chan %d start event queue\n", channel->channel);
184-
185-
/* Make sure the NAPI handler sees the enabled flag set */
186-
channel->enabled = true;
187-
smp_wmb();
188-
189-
napi_enable(&channel->napi_str);
190-
efx_nic_eventq_read_ack(channel);
191-
}
192-
193-
/* Disable event queue processing and NAPI */
194-
void efx_stop_eventq(struct efx_channel *channel)
195-
{
196-
if (!channel->enabled)
197-
return;
198-
199-
napi_disable(&channel->napi_str);
200-
channel->enabled = false;
201-
}
202-
203-
void efx_fini_eventq(struct efx_channel *channel)
204-
{
205-
if (!channel->eventq_init)
206-
return;
207-
208-
netif_dbg(channel->efx, drv, channel->efx->net_dev,
209-
"chan %d fini event queue\n", channel->channel);
210-
211-
efx_nic_fini_eventq(channel);
212-
channel->eventq_init = false;
213-
}
214-
215-
void efx_remove_eventq(struct efx_channel *channel)
216-
{
217-
netif_dbg(channel->efx, drv, channel->efx->net_dev,
218-
"chan %d remove event queue\n", channel->channel);
219-
220-
efx_nic_remove_eventq(channel);
221-
}
222-
223131
/**************************************************************************
224132
*
225133
* Channel handling

drivers/net/ethernet/sfc/efx_channels.c

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,97 @@ void efx_remove_interrupts(struct efx_nic *efx)
388388
efx->legacy_irq = 0;
389389
}
390390

391+
/***************
392+
* EVENT QUEUES
393+
***************/
394+
395+
/* Create event queue
396+
* Event queue memory allocations are done only once. If the channel
397+
* is reset, the memory buffer will be reused; this guards against
398+
* errors during channel reset and also simplifies interrupt handling.
399+
*/
400+
int efx_probe_eventq(struct efx_channel *channel)
401+
{
402+
struct efx_nic *efx = channel->efx;
403+
unsigned long entries;
404+
405+
netif_dbg(efx, probe, efx->net_dev,
406+
"chan %d create event queue\n", channel->channel);
407+
408+
/* Build an event queue with room for one event per tx and rx buffer,
409+
* plus some extra for link state events and MCDI completions.
410+
*/
411+
entries = roundup_pow_of_two(efx->rxq_entries + efx->txq_entries + 128);
412+
EFX_WARN_ON_PARANOID(entries > EFX_MAX_EVQ_SIZE);
413+
channel->eventq_mask = max(entries, EFX_MIN_EVQ_SIZE) - 1;
414+
415+
return efx_nic_probe_eventq(channel);
416+
}
417+
418+
/* Prepare channel's event queue */
419+
int efx_init_eventq(struct efx_channel *channel)
420+
{
421+
struct efx_nic *efx = channel->efx;
422+
int rc;
423+
424+
EFX_WARN_ON_PARANOID(channel->eventq_init);
425+
426+
netif_dbg(efx, drv, efx->net_dev,
427+
"chan %d init event queue\n", channel->channel);
428+
429+
rc = efx_nic_init_eventq(channel);
430+
if (rc == 0) {
431+
efx->type->push_irq_moderation(channel);
432+
channel->eventq_read_ptr = 0;
433+
channel->eventq_init = true;
434+
}
435+
return rc;
436+
}
437+
438+
/* Enable event queue processing and NAPI */
439+
void efx_start_eventq(struct efx_channel *channel)
440+
{
441+
netif_dbg(channel->efx, ifup, channel->efx->net_dev,
442+
"chan %d start event queue\n", channel->channel);
443+
444+
/* Make sure the NAPI handler sees the enabled flag set */
445+
channel->enabled = true;
446+
smp_wmb();
447+
448+
napi_enable(&channel->napi_str);
449+
efx_nic_eventq_read_ack(channel);
450+
}
451+
452+
/* Disable event queue processing and NAPI */
453+
void efx_stop_eventq(struct efx_channel *channel)
454+
{
455+
if (!channel->enabled)
456+
return;
457+
458+
napi_disable(&channel->napi_str);
459+
channel->enabled = false;
460+
}
461+
462+
void efx_fini_eventq(struct efx_channel *channel)
463+
{
464+
if (!channel->eventq_init)
465+
return;
466+
467+
netif_dbg(channel->efx, drv, channel->efx->net_dev,
468+
"chan %d fini event queue\n", channel->channel);
469+
470+
efx_nic_fini_eventq(channel);
471+
channel->eventq_init = false;
472+
}
473+
474+
void efx_remove_eventq(struct efx_channel *channel)
475+
{
476+
netif_dbg(channel->efx, drv, channel->efx->net_dev,
477+
"chan %d remove event queue\n", channel->channel);
478+
479+
efx_nic_remove_eventq(channel);
480+
}
481+
391482
/**************************************************************************
392483
*
393484
* Channel handling

0 commit comments

Comments
 (0)