Commit 4a74dc65 authored by Ben Hutchings's avatar Ben Hutchings

sfc: Allow efx_channel_type::receive_skb() to reject a packet

Instead of having efx_ptp_rx() call netif_receive_skb() for an invalid
PTP packet, make it return false for rejected packets and have
efx_rx_deliver() pass them up.
Signed-off-by: default avatarBen Hutchings <bhutchings@solarflare.com>
parent 86c2da58
...@@ -410,7 +410,7 @@ struct efx_channel_type { ...@@ -410,7 +410,7 @@ struct efx_channel_type {
void (*post_remove)(struct efx_channel *); void (*post_remove)(struct efx_channel *);
void (*get_name)(struct efx_channel *, char *buf, size_t len); void (*get_name)(struct efx_channel *, char *buf, size_t len);
struct efx_channel *(*copy)(const struct efx_channel *); struct efx_channel *(*copy)(const struct efx_channel *);
void (*receive_skb)(struct efx_channel *, struct sk_buff *); bool (*receive_skb)(struct efx_channel *, struct sk_buff *);
bool keep_eventq; bool keep_eventq;
}; };
......
...@@ -1006,7 +1006,7 @@ bool efx_ptp_is_ptp_tx(struct efx_nic *efx, struct sk_buff *skb) ...@@ -1006,7 +1006,7 @@ bool efx_ptp_is_ptp_tx(struct efx_nic *efx, struct sk_buff *skb)
* the receive timestamp from the MC - this will probably occur after the * the receive timestamp from the MC - this will probably occur after the
* packet arrival because of the processing in the MC. * packet arrival because of the processing in the MC.
*/ */
static void efx_ptp_rx(struct efx_channel *channel, struct sk_buff *skb) static bool efx_ptp_rx(struct efx_channel *channel, struct sk_buff *skb)
{ {
struct efx_nic *efx = channel->efx; struct efx_nic *efx = channel->efx;
struct efx_ptp_data *ptp = efx->ptp_data; struct efx_ptp_data *ptp = efx->ptp_data;
...@@ -1019,18 +1019,15 @@ static void efx_ptp_rx(struct efx_channel *channel, struct sk_buff *skb) ...@@ -1019,18 +1019,15 @@ static void efx_ptp_rx(struct efx_channel *channel, struct sk_buff *skb)
/* Correct version? */ /* Correct version? */
if (ptp->mode == MC_CMD_PTP_MODE_V1) { if (ptp->mode == MC_CMD_PTP_MODE_V1) {
if (skb->len < PTP_V1_MIN_LENGTH) { if (skb->len < PTP_V1_MIN_LENGTH) {
netif_receive_skb(skb); return false;
return;
} }
version = ntohs(*(__be16 *)&skb->data[PTP_V1_VERSION_OFFSET]); version = ntohs(*(__be16 *)&skb->data[PTP_V1_VERSION_OFFSET]);
if (version != PTP_VERSION_V1) { if (version != PTP_VERSION_V1) {
netif_receive_skb(skb); return false;
return;
} }
} else { } else {
if (skb->len < PTP_V2_MIN_LENGTH) { if (skb->len < PTP_V2_MIN_LENGTH) {
netif_receive_skb(skb); return false;
return;
} }
version = skb->data[PTP_V2_VERSION_OFFSET]; version = skb->data[PTP_V2_VERSION_OFFSET];
...@@ -1041,8 +1038,7 @@ static void efx_ptp_rx(struct efx_channel *channel, struct sk_buff *skb) ...@@ -1041,8 +1038,7 @@ static void efx_ptp_rx(struct efx_channel *channel, struct sk_buff *skb)
BUILD_BUG_ON(PTP_V1_SEQUENCE_LENGTH != PTP_V2_SEQUENCE_LENGTH); BUILD_BUG_ON(PTP_V1_SEQUENCE_LENGTH != PTP_V2_SEQUENCE_LENGTH);
if ((version & PTP_VERSION_V2_MASK) != PTP_VERSION_V2) { if ((version & PTP_VERSION_V2_MASK) != PTP_VERSION_V2) {
netif_receive_skb(skb); return false;
return;
} }
} }
...@@ -1073,6 +1069,8 @@ static void efx_ptp_rx(struct efx_channel *channel, struct sk_buff *skb) ...@@ -1073,6 +1069,8 @@ static void efx_ptp_rx(struct efx_channel *channel, struct sk_buff *skb)
skb_queue_tail(&ptp->rxq, skb); skb_queue_tail(&ptp->rxq, skb);
queue_work(ptp->workwq, &ptp->work); queue_work(ptp->workwq, &ptp->work);
return true;
} }
/* Transmit a PTP packet. This has to be transmitted by the MC /* Transmit a PTP packet. This has to be transmitted by the MC
......
...@@ -575,12 +575,14 @@ static void efx_rx_deliver(struct efx_channel *channel, ...@@ -575,12 +575,14 @@ static void efx_rx_deliver(struct efx_channel *channel,
/* Record the rx_queue */ /* Record the rx_queue */
skb_record_rx_queue(skb, channel->rx_queue.core_index); skb_record_rx_queue(skb, channel->rx_queue.core_index);
/* Pass the packet up */
if (channel->type->receive_skb) if (channel->type->receive_skb)
channel->type->receive_skb(channel, skb); if (channel->type->receive_skb(channel, skb))
else goto handled;
/* Pass the packet up */
netif_receive_skb(skb); netif_receive_skb(skb);
handled:
/* Update allocation strategy method */ /* Update allocation strategy method */
channel->rx_alloc_level += RX_ALLOC_FACTOR_SKB; channel->rx_alloc_level += RX_ALLOC_FACTOR_SKB;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment