diff options
author | Klaus-Dieter Wacker <kdwacker@de.ibm.com> | 2009-08-25 22:01:08 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-08-26 20:34:18 -0400 |
commit | ce73e10ee0cb6cde1c5075a2803da0f0eb5b2324 (patch) | |
tree | 1152542d22e94fb892f03e6de52bfc538c47e7a3 /drivers/s390/net | |
parent | e806904057253e4f7651a8594456e68857c24e1b (diff) |
qeth: Cleanup for cast-type determination.
Clear separation of cast-type determination (send path) for layer-2
resp. layer-3. Allowing to have inline functions for qeth layer-
discipline.
Signed-off-by: Klaus-Dieter Wacker <kdwacker@de.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/s390/net')
-rw-r--r-- | drivers/s390/net/qeth_core.h | 1 | ||||
-rw-r--r-- | drivers/s390/net/qeth_core_main.c | 49 | ||||
-rw-r--r-- | drivers/s390/net/qeth_l2_main.c | 42 | ||||
-rw-r--r-- | drivers/s390/net/qeth_l3_main.c | 47 |
4 files changed, 57 insertions, 82 deletions
diff --git a/drivers/s390/net/qeth_core.h b/drivers/s390/net/qeth_core.h index 03161e650b24..31a2b4e502ce 100644 --- a/drivers/s390/net/qeth_core.h +++ b/drivers/s390/net/qeth_core.h | |||
@@ -843,7 +843,6 @@ int qeth_default_setadapterparms_cb(struct qeth_card *, struct qeth_reply *, | |||
843 | int qeth_send_control_data(struct qeth_card *, int, struct qeth_cmd_buffer *, | 843 | int qeth_send_control_data(struct qeth_card *, int, struct qeth_cmd_buffer *, |
844 | int (*reply_cb)(struct qeth_card *, struct qeth_reply*, unsigned long), | 844 | int (*reply_cb)(struct qeth_card *, struct qeth_reply*, unsigned long), |
845 | void *reply_param); | 845 | void *reply_param); |
846 | int qeth_get_cast_type(struct qeth_card *, struct sk_buff *); | ||
847 | int qeth_get_priority_queue(struct qeth_card *, struct sk_buff *, int, int); | 846 | int qeth_get_priority_queue(struct qeth_card *, struct sk_buff *, int, int); |
848 | int qeth_get_elements_no(struct qeth_card *, void *, struct sk_buff *, int); | 847 | int qeth_get_elements_no(struct qeth_card *, void *, struct sk_buff *, int); |
849 | int qeth_do_send_packet_fast(struct qeth_card *, struct qeth_qdio_out_q *, | 848 | int qeth_do_send_packet_fast(struct qeth_card *, struct qeth_qdio_out_q *, |
diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c index ac7270d21708..1560bb621a3b 100644 --- a/drivers/s390/net/qeth_core_main.c +++ b/drivers/s390/net/qeth_core_main.c | |||
@@ -2952,55 +2952,6 @@ void qeth_qdio_output_handler(struct ccw_device *ccwdev, | |||
2952 | } | 2952 | } |
2953 | EXPORT_SYMBOL_GPL(qeth_qdio_output_handler); | 2953 | EXPORT_SYMBOL_GPL(qeth_qdio_output_handler); |
2954 | 2954 | ||
2955 | int qeth_get_cast_type(struct qeth_card *card, struct sk_buff *skb) | ||
2956 | { | ||
2957 | int cast_type = RTN_UNSPEC; | ||
2958 | |||
2959 | if (card->info.type == QETH_CARD_TYPE_OSN) | ||
2960 | return cast_type; | ||
2961 | |||
2962 | if (skb_dst(skb) && skb_dst(skb)->neighbour) { | ||
2963 | cast_type = skb_dst(skb)->neighbour->type; | ||
2964 | if ((cast_type == RTN_BROADCAST) || | ||
2965 | (cast_type == RTN_MULTICAST) || | ||
2966 | (cast_type == RTN_ANYCAST)) | ||
2967 | return cast_type; | ||
2968 | else | ||
2969 | return RTN_UNSPEC; | ||
2970 | } | ||
2971 | /* try something else */ | ||
2972 | if (skb->protocol == ETH_P_IPV6) | ||
2973 | return (skb_network_header(skb)[24] == 0xff) ? | ||
2974 | RTN_MULTICAST : 0; | ||
2975 | else if (skb->protocol == ETH_P_IP) | ||
2976 | return ((skb_network_header(skb)[16] & 0xf0) == 0xe0) ? | ||
2977 | RTN_MULTICAST : 0; | ||
2978 | /* ... */ | ||
2979 | if (!memcmp(skb->data, skb->dev->broadcast, 6)) | ||
2980 | return RTN_BROADCAST; | ||
2981 | else { | ||
2982 | u16 hdr_mac; | ||
2983 | |||
2984 | hdr_mac = *((u16 *)skb->data); | ||
2985 | /* tr multicast? */ | ||
2986 | switch (card->info.link_type) { | ||
2987 | case QETH_LINK_TYPE_HSTR: | ||
2988 | case QETH_LINK_TYPE_LANE_TR: | ||
2989 | if ((hdr_mac == QETH_TR_MAC_NC) || | ||
2990 | (hdr_mac == QETH_TR_MAC_C)) | ||
2991 | return RTN_MULTICAST; | ||
2992 | break; | ||
2993 | /* eth or so multicast? */ | ||
2994 | default: | ||
2995 | if ((hdr_mac == QETH_ETH_MAC_V4) || | ||
2996 | (hdr_mac == QETH_ETH_MAC_V6)) | ||
2997 | return RTN_MULTICAST; | ||
2998 | } | ||
2999 | } | ||
3000 | return cast_type; | ||
3001 | } | ||
3002 | EXPORT_SYMBOL_GPL(qeth_get_cast_type); | ||
3003 | |||
3004 | int qeth_get_priority_queue(struct qeth_card *card, struct sk_buff *skb, | 2955 | int qeth_get_priority_queue(struct qeth_card *card, struct sk_buff *skb, |
3005 | int ipv, int cast_type) | 2956 | int ipv, int cast_type) |
3006 | { | 2957 | { |
diff --git a/drivers/s390/net/qeth_l2_main.c b/drivers/s390/net/qeth_l2_main.c index 2cfc338c4625..12ee7a35ca59 100644 --- a/drivers/s390/net/qeth_l2_main.c +++ b/drivers/s390/net/qeth_l2_main.c | |||
@@ -216,36 +216,16 @@ static void qeth_l2_del_all_mc(struct qeth_card *card) | |||
216 | spin_unlock_bh(&card->mclock); | 216 | spin_unlock_bh(&card->mclock); |
217 | } | 217 | } |
218 | 218 | ||
219 | static void qeth_l2_get_packet_type(struct qeth_card *card, | 219 | static inline int qeth_l2_get_cast_type(struct qeth_card *card, |
220 | struct qeth_hdr *hdr, struct sk_buff *skb) | 220 | struct sk_buff *skb) |
221 | { | 221 | { |
222 | __u16 hdr_mac; | 222 | if (card->info.type == QETH_CARD_TYPE_OSN) |
223 | 223 | return RTN_UNSPEC; | |
224 | if (!memcmp(skb->data + QETH_HEADER_SIZE, | 224 | if (is_broadcast_ether_addr(skb->data)) |
225 | skb->dev->broadcast, 6)) { | 225 | return RTN_BROADCAST; |
226 | /* broadcast? */ | 226 | if (is_multicast_ether_addr(skb->data)) |
227 | hdr->hdr.l2.flags[2] |= QETH_LAYER2_FLAG_BROADCAST; | 227 | return RTN_MULTICAST; |
228 | return; | 228 | return RTN_UNSPEC; |
229 | } | ||
230 | hdr_mac = *((__u16 *)skb->data); | ||
231 | /* tr multicast? */ | ||
232 | switch (card->info.link_type) { | ||
233 | case QETH_LINK_TYPE_HSTR: | ||
234 | case QETH_LINK_TYPE_LANE_TR: | ||
235 | if ((hdr_mac == QETH_TR_MAC_NC) || | ||
236 | (hdr_mac == QETH_TR_MAC_C)) | ||
237 | hdr->hdr.l2.flags[2] |= QETH_LAYER2_FLAG_MULTICAST; | ||
238 | else | ||
239 | hdr->hdr.l2.flags[2] |= QETH_LAYER2_FLAG_UNICAST; | ||
240 | break; | ||
241 | /* eth or so multicast? */ | ||
242 | default: | ||
243 | if ((hdr_mac == QETH_ETH_MAC_V4) || | ||
244 | (hdr_mac == QETH_ETH_MAC_V6)) | ||
245 | hdr->hdr.l2.flags[2] |= QETH_LAYER2_FLAG_MULTICAST; | ||
246 | else | ||
247 | hdr->hdr.l2.flags[2] |= QETH_LAYER2_FLAG_UNICAST; | ||
248 | } | ||
249 | } | 229 | } |
250 | 230 | ||
251 | static void qeth_l2_fill_header(struct qeth_card *card, struct qeth_hdr *hdr, | 231 | static void qeth_l2_fill_header(struct qeth_card *card, struct qeth_hdr *hdr, |
@@ -262,7 +242,7 @@ static void qeth_l2_fill_header(struct qeth_card *card, struct qeth_hdr *hdr, | |||
262 | else if (cast_type == RTN_BROADCAST) | 242 | else if (cast_type == RTN_BROADCAST) |
263 | hdr->hdr.l2.flags[2] |= QETH_LAYER2_FLAG_BROADCAST; | 243 | hdr->hdr.l2.flags[2] |= QETH_LAYER2_FLAG_BROADCAST; |
264 | else | 244 | else |
265 | qeth_l2_get_packet_type(card, hdr, skb); | 245 | hdr->hdr.l2.flags[2] |= QETH_LAYER2_FLAG_UNICAST; |
266 | 246 | ||
267 | hdr->hdr.l2.pkt_length = skb->len-QETH_HEADER_SIZE; | 247 | hdr->hdr.l2.pkt_length = skb->len-QETH_HEADER_SIZE; |
268 | /* VSWITCH relies on the VLAN | 248 | /* VSWITCH relies on the VLAN |
@@ -672,7 +652,7 @@ static int qeth_l2_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
672 | struct qeth_card *card = dev->ml_priv; | 652 | struct qeth_card *card = dev->ml_priv; |
673 | struct sk_buff *new_skb = skb; | 653 | struct sk_buff *new_skb = skb; |
674 | int ipv = qeth_get_ip_version(skb); | 654 | int ipv = qeth_get_ip_version(skb); |
675 | int cast_type = qeth_get_cast_type(card, skb); | 655 | int cast_type = qeth_l2_get_cast_type(card, skb); |
676 | struct qeth_qdio_out_q *queue = card->qdio.out_qs | 656 | struct qeth_qdio_out_q *queue = card->qdio.out_qs |
677 | [qeth_get_priority_queue(card, skb, ipv, cast_type)]; | 657 | [qeth_get_priority_queue(card, skb, ipv, cast_type)]; |
678 | int tx_bytes = skb->len; | 658 | int tx_bytes = skb->len; |
diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c index 77e04b7fad1d..d9fabe30c0da 100644 --- a/drivers/s390/net/qeth_l3_main.c +++ b/drivers/s390/net/qeth_l3_main.c | |||
@@ -2525,6 +2525,51 @@ static int qeth_l3_do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) | |||
2525 | return rc; | 2525 | return rc; |
2526 | } | 2526 | } |
2527 | 2527 | ||
2528 | int inline qeth_l3_get_cast_type(struct qeth_card *card, struct sk_buff *skb) | ||
2529 | { | ||
2530 | int cast_type = RTN_UNSPEC; | ||
2531 | |||
2532 | if (skb_dst(skb) && skb_dst(skb)->neighbour) { | ||
2533 | cast_type = skb_dst(skb)->neighbour->type; | ||
2534 | if ((cast_type == RTN_BROADCAST) || | ||
2535 | (cast_type == RTN_MULTICAST) || | ||
2536 | (cast_type == RTN_ANYCAST)) | ||
2537 | return cast_type; | ||
2538 | else | ||
2539 | return RTN_UNSPEC; | ||
2540 | } | ||
2541 | /* try something else */ | ||
2542 | if (skb->protocol == ETH_P_IPV6) | ||
2543 | return (skb_network_header(skb)[24] == 0xff) ? | ||
2544 | RTN_MULTICAST : 0; | ||
2545 | else if (skb->protocol == ETH_P_IP) | ||
2546 | return ((skb_network_header(skb)[16] & 0xf0) == 0xe0) ? | ||
2547 | RTN_MULTICAST : 0; | ||
2548 | /* ... */ | ||
2549 | if (!memcmp(skb->data, skb->dev->broadcast, 6)) | ||
2550 | return RTN_BROADCAST; | ||
2551 | else { | ||
2552 | u16 hdr_mac; | ||
2553 | |||
2554 | hdr_mac = *((u16 *)skb->data); | ||
2555 | /* tr multicast? */ | ||
2556 | switch (card->info.link_type) { | ||
2557 | case QETH_LINK_TYPE_HSTR: | ||
2558 | case QETH_LINK_TYPE_LANE_TR: | ||
2559 | if ((hdr_mac == QETH_TR_MAC_NC) || | ||
2560 | (hdr_mac == QETH_TR_MAC_C)) | ||
2561 | return RTN_MULTICAST; | ||
2562 | break; | ||
2563 | /* eth or so multicast? */ | ||
2564 | default: | ||
2565 | if ((hdr_mac == QETH_ETH_MAC_V4) || | ||
2566 | (hdr_mac == QETH_ETH_MAC_V6)) | ||
2567 | return RTN_MULTICAST; | ||
2568 | } | ||
2569 | } | ||
2570 | return cast_type; | ||
2571 | } | ||
2572 | |||
2528 | static void qeth_l3_fill_header(struct qeth_card *card, struct qeth_hdr *hdr, | 2573 | static void qeth_l3_fill_header(struct qeth_card *card, struct qeth_hdr *hdr, |
2529 | struct sk_buff *skb, int ipv, int cast_type) | 2574 | struct sk_buff *skb, int ipv, int cast_type) |
2530 | { | 2575 | { |
@@ -2650,7 +2695,7 @@ static int qeth_l3_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
2650 | struct qeth_card *card = dev->ml_priv; | 2695 | struct qeth_card *card = dev->ml_priv; |
2651 | struct sk_buff *new_skb = NULL; | 2696 | struct sk_buff *new_skb = NULL; |
2652 | int ipv = qeth_get_ip_version(skb); | 2697 | int ipv = qeth_get_ip_version(skb); |
2653 | int cast_type = qeth_get_cast_type(card, skb); | 2698 | int cast_type = qeth_l3_get_cast_type(card, skb); |
2654 | struct qeth_qdio_out_q *queue = card->qdio.out_qs | 2699 | struct qeth_qdio_out_q *queue = card->qdio.out_qs |
2655 | [qeth_get_priority_queue(card, skb, ipv, cast_type)]; | 2700 | [qeth_get_priority_queue(card, skb, ipv, cast_type)]; |
2656 | int tx_bytes = skb->len; | 2701 | int tx_bytes = skb->len; |