diff options
author | Ben Hutchings <bhutchings@solarflare.com> | 2013-03-05 15:13:54 -0500 |
---|---|---|
committer | Ben Hutchings <bhutchings@solarflare.com> | 2013-03-07 15:21:54 -0500 |
commit | 4a74dc65e3ad825a66dfbcb256f98c550f96445b (patch) | |
tree | 97f5e5ef4efaf339c59de29f1ac1475af398508b | |
parent | 86c2da58a70e02ece910a3bba3da86d61b6aeefd (diff) |
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: Ben Hutchings <bhutchings@solarflare.com>
-rw-r--r-- | drivers/net/ethernet/sfc/net_driver.h | 2 | ||||
-rw-r--r-- | drivers/net/ethernet/sfc/ptp.c | 16 | ||||
-rw-r--r-- | drivers/net/ethernet/sfc/rx.c | 10 |
3 files changed, 14 insertions, 14 deletions
diff --git a/drivers/net/ethernet/sfc/net_driver.h b/drivers/net/ethernet/sfc/net_driver.h index 0a90abd2421b..cdcf510311c3 100644 --- a/drivers/net/ethernet/sfc/net_driver.h +++ b/drivers/net/ethernet/sfc/net_driver.h | |||
@@ -410,7 +410,7 @@ struct efx_channel_type { | |||
410 | void (*post_remove)(struct efx_channel *); | 410 | void (*post_remove)(struct efx_channel *); |
411 | void (*get_name)(struct efx_channel *, char *buf, size_t len); | 411 | void (*get_name)(struct efx_channel *, char *buf, size_t len); |
412 | struct efx_channel *(*copy)(const struct efx_channel *); | 412 | struct efx_channel *(*copy)(const struct efx_channel *); |
413 | void (*receive_skb)(struct efx_channel *, struct sk_buff *); | 413 | bool (*receive_skb)(struct efx_channel *, struct sk_buff *); |
414 | bool keep_eventq; | 414 | bool keep_eventq; |
415 | }; | 415 | }; |
416 | 416 | ||
diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c index 3f93624fc273..faf4baf36861 100644 --- a/drivers/net/ethernet/sfc/ptp.c +++ b/drivers/net/ethernet/sfc/ptp.c | |||
@@ -1006,7 +1006,7 @@ bool efx_ptp_is_ptp_tx(struct efx_nic *efx, struct sk_buff *skb) | |||
1006 | * the receive timestamp from the MC - this will probably occur after the | 1006 | * the receive timestamp from the MC - this will probably occur after the |
1007 | * packet arrival because of the processing in the MC. | 1007 | * packet arrival because of the processing in the MC. |
1008 | */ | 1008 | */ |
1009 | static void efx_ptp_rx(struct efx_channel *channel, struct sk_buff *skb) | 1009 | static bool efx_ptp_rx(struct efx_channel *channel, struct sk_buff *skb) |
1010 | { | 1010 | { |
1011 | struct efx_nic *efx = channel->efx; | 1011 | struct efx_nic *efx = channel->efx; |
1012 | struct efx_ptp_data *ptp = efx->ptp_data; | 1012 | 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 | /* Correct version? */ | 1019 | /* Correct version? */ |
1020 | if (ptp->mode == MC_CMD_PTP_MODE_V1) { | 1020 | if (ptp->mode == MC_CMD_PTP_MODE_V1) { |
1021 | if (skb->len < PTP_V1_MIN_LENGTH) { | 1021 | if (skb->len < PTP_V1_MIN_LENGTH) { |
1022 | netif_receive_skb(skb); | 1022 | return false; |
1023 | return; | ||
1024 | } | 1023 | } |
1025 | version = ntohs(*(__be16 *)&skb->data[PTP_V1_VERSION_OFFSET]); | 1024 | version = ntohs(*(__be16 *)&skb->data[PTP_V1_VERSION_OFFSET]); |
1026 | if (version != PTP_VERSION_V1) { | 1025 | if (version != PTP_VERSION_V1) { |
1027 | netif_receive_skb(skb); | 1026 | return false; |
1028 | return; | ||
1029 | } | 1027 | } |
1030 | } else { | 1028 | } else { |
1031 | if (skb->len < PTP_V2_MIN_LENGTH) { | 1029 | if (skb->len < PTP_V2_MIN_LENGTH) { |
1032 | netif_receive_skb(skb); | 1030 | return false; |
1033 | return; | ||
1034 | } | 1031 | } |
1035 | version = skb->data[PTP_V2_VERSION_OFFSET]; | 1032 | version = skb->data[PTP_V2_VERSION_OFFSET]; |
1036 | 1033 | ||
@@ -1041,8 +1038,7 @@ static void efx_ptp_rx(struct efx_channel *channel, struct sk_buff *skb) | |||
1041 | BUILD_BUG_ON(PTP_V1_SEQUENCE_LENGTH != PTP_V2_SEQUENCE_LENGTH); | 1038 | BUILD_BUG_ON(PTP_V1_SEQUENCE_LENGTH != PTP_V2_SEQUENCE_LENGTH); |
1042 | 1039 | ||
1043 | if ((version & PTP_VERSION_V2_MASK) != PTP_VERSION_V2) { | 1040 | if ((version & PTP_VERSION_V2_MASK) != PTP_VERSION_V2) { |
1044 | netif_receive_skb(skb); | 1041 | return false; |
1045 | return; | ||
1046 | } | 1042 | } |
1047 | } | 1043 | } |
1048 | 1044 | ||
@@ -1073,6 +1069,8 @@ static void efx_ptp_rx(struct efx_channel *channel, struct sk_buff *skb) | |||
1073 | 1069 | ||
1074 | skb_queue_tail(&ptp->rxq, skb); | 1070 | skb_queue_tail(&ptp->rxq, skb); |
1075 | queue_work(ptp->workwq, &ptp->work); | 1071 | queue_work(ptp->workwq, &ptp->work); |
1072 | |||
1073 | return true; | ||
1076 | } | 1074 | } |
1077 | 1075 | ||
1078 | /* Transmit a PTP packet. This has to be transmitted by the MC | 1076 | /* Transmit a PTP packet. This has to be transmitted by the MC |
diff --git a/drivers/net/ethernet/sfc/rx.c b/drivers/net/ethernet/sfc/rx.c index bb579a6128c8..f31c23ea2a07 100644 --- a/drivers/net/ethernet/sfc/rx.c +++ b/drivers/net/ethernet/sfc/rx.c | |||
@@ -575,12 +575,14 @@ static void efx_rx_deliver(struct efx_channel *channel, | |||
575 | /* Record the rx_queue */ | 575 | /* Record the rx_queue */ |
576 | skb_record_rx_queue(skb, channel->rx_queue.core_index); | 576 | skb_record_rx_queue(skb, channel->rx_queue.core_index); |
577 | 577 | ||
578 | /* Pass the packet up */ | ||
579 | if (channel->type->receive_skb) | 578 | if (channel->type->receive_skb) |
580 | channel->type->receive_skb(channel, skb); | 579 | if (channel->type->receive_skb(channel, skb)) |
581 | else | 580 | goto handled; |
582 | netif_receive_skb(skb); | 581 | |
582 | /* Pass the packet up */ | ||
583 | netif_receive_skb(skb); | ||
583 | 584 | ||
585 | handled: | ||
584 | /* Update allocation strategy method */ | 586 | /* Update allocation strategy method */ |
585 | channel->rx_alloc_level += RX_ALLOC_FACTOR_SKB; | 587 | channel->rx_alloc_level += RX_ALLOC_FACTOR_SKB; |
586 | } | 588 | } |