Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Klaus-Dieter Wacker and committed by
David S. Miller
ce73e10e e8069040

+57 -82
-1
drivers/s390/net/qeth_core.h
··· 843 843 int qeth_send_control_data(struct qeth_card *, int, struct qeth_cmd_buffer *, 844 844 int (*reply_cb)(struct qeth_card *, struct qeth_reply*, unsigned long), 845 845 void *reply_param); 846 - int qeth_get_cast_type(struct qeth_card *, struct sk_buff *); 847 846 int qeth_get_priority_queue(struct qeth_card *, struct sk_buff *, int, int); 848 847 int qeth_get_elements_no(struct qeth_card *, void *, struct sk_buff *, int); 849 848 int qeth_do_send_packet_fast(struct qeth_card *, struct qeth_qdio_out_q *,
-49
drivers/s390/net/qeth_core_main.c
··· 2952 2952 } 2953 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 2955 int qeth_get_priority_queue(struct qeth_card *card, struct sk_buff *skb, 3005 2956 int ipv, int cast_type) 3006 2957 {
+11 -31
drivers/s390/net/qeth_l2_main.c
··· 216 216 spin_unlock_bh(&card->mclock); 217 217 } 218 218 219 - static void qeth_l2_get_packet_type(struct qeth_card *card, 220 - struct qeth_hdr *hdr, struct sk_buff *skb) 219 + static inline int qeth_l2_get_cast_type(struct qeth_card *card, 220 + struct sk_buff *skb) 221 221 { 222 - __u16 hdr_mac; 223 - 224 - if (!memcmp(skb->data + QETH_HEADER_SIZE, 225 - skb->dev->broadcast, 6)) { 226 - /* broadcast? */ 227 - hdr->hdr.l2.flags[2] |= QETH_LAYER2_FLAG_BROADCAST; 228 - return; 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 - } 222 + if (card->info.type == QETH_CARD_TYPE_OSN) 223 + return RTN_UNSPEC; 224 + if (is_broadcast_ether_addr(skb->data)) 225 + return RTN_BROADCAST; 226 + if (is_multicast_ether_addr(skb->data)) 227 + return RTN_MULTICAST; 228 + return RTN_UNSPEC; 249 229 } 250 230 251 231 static void qeth_l2_fill_header(struct qeth_card *card, struct qeth_hdr *hdr, ··· 242 262 else if (cast_type == RTN_BROADCAST) 243 263 hdr->hdr.l2.flags[2] |= QETH_LAYER2_FLAG_BROADCAST; 244 264 else 245 - qeth_l2_get_packet_type(card, hdr, skb); 265 + hdr->hdr.l2.flags[2] |= QETH_LAYER2_FLAG_UNICAST; 246 266 247 267 hdr->hdr.l2.pkt_length = skb->len-QETH_HEADER_SIZE; 248 268 /* VSWITCH relies on the VLAN ··· 652 672 struct qeth_card *card = dev->ml_priv; 653 673 struct sk_buff *new_skb = skb; 654 674 int ipv = qeth_get_ip_version(skb); 655 - int cast_type = qeth_get_cast_type(card, skb); 675 + int cast_type = qeth_l2_get_cast_type(card, skb); 656 676 struct qeth_qdio_out_q *queue = card->qdio.out_qs 657 677 [qeth_get_priority_queue(card, skb, ipv, cast_type)]; 658 678 int tx_bytes = skb->len;
+46 -1
drivers/s390/net/qeth_l3_main.c
··· 2525 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 2573 static void qeth_l3_fill_header(struct qeth_card *card, struct qeth_hdr *hdr, 2529 2574 struct sk_buff *skb, int ipv, int cast_type) 2530 2575 { ··· 2695 2650 struct qeth_card *card = dev->ml_priv; 2696 2651 struct sk_buff *new_skb = NULL; 2697 2652 int ipv = qeth_get_ip_version(skb); 2698 - int cast_type = qeth_get_cast_type(card, skb); 2653 + int cast_type = qeth_l3_get_cast_type(card, skb); 2699 2654 struct qeth_qdio_out_q *queue = card->qdio.out_qs 2700 2655 [qeth_get_priority_queue(card, skb, ipv, cast_type)]; 2701 2656 int tx_bytes = skb->len;