| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: ISC */ |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (c) 2012-2016 Qualcomm Atheros, Inc. |
|---|
| 3 | | - * Copyright (c) 2018, The Linux Foundation. All rights reserved. |
|---|
| 4 | | - * |
|---|
| 5 | | - * Permission to use, copy, modify, and/or distribute this software for any |
|---|
| 6 | | - * purpose with or without fee is hereby granted, provided that the above |
|---|
| 7 | | - * copyright notice and this permission notice appear in all copies. |
|---|
| 8 | | - * |
|---|
| 9 | | - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
|---|
| 10 | | - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
|---|
| 11 | | - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
|---|
| 12 | | - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
|---|
| 13 | | - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
|---|
| 14 | | - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
|---|
| 15 | | - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
|---|
| 4 | + * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved. |
|---|
| 16 | 5 | */ |
|---|
| 17 | 6 | |
|---|
| 18 | 7 | #ifndef WIL6210_TXRX_H |
|---|
| .. | .. |
|---|
| 354 | 343 | u32 d0; |
|---|
| 355 | 344 | u32 d1; |
|---|
| 356 | 345 | u16 w4; |
|---|
| 357 | | - u16 pn_15_0; |
|---|
| 358 | | - u32 pn_47_16; |
|---|
| 346 | + struct_group_attr(pn, __packed, |
|---|
| 347 | + u16 pn_15_0; |
|---|
| 348 | + u32 pn_47_16; |
|---|
| 349 | + ); |
|---|
| 359 | 350 | } __packed; |
|---|
| 360 | 351 | |
|---|
| 361 | 352 | /* Rx descriptor - DMA part |
|---|
| .. | .. |
|---|
| 423 | 414 | #define RX_DMA_STATUS_PHY_INFO BIT(6) |
|---|
| 424 | 415 | #define RX_DMA_STATUS_FFM BIT(7) /* EtherType Flex Filter Match */ |
|---|
| 425 | 416 | |
|---|
| 417 | +/* IEEE 802.11, 8.5.2 EAPOL-Key frames */ |
|---|
| 418 | +#define WIL_KEY_INFO_KEY_TYPE BIT(3) /* val of 1 = Pairwise, 0 = Group key */ |
|---|
| 419 | + |
|---|
| 420 | +#define WIL_KEY_INFO_MIC BIT(8) |
|---|
| 421 | +#define WIL_KEY_INFO_ENCR_KEY_DATA BIT(12) /* for rsn only */ |
|---|
| 422 | + |
|---|
| 423 | +#define WIL_EAP_NONCE_LEN 32 |
|---|
| 424 | +#define WIL_EAP_KEY_RSC_LEN 8 |
|---|
| 425 | +#define WIL_EAP_REPLAY_COUNTER_LEN 8 |
|---|
| 426 | +#define WIL_EAP_KEY_IV_LEN 16 |
|---|
| 427 | +#define WIL_EAP_KEY_ID_LEN 8 |
|---|
| 428 | + |
|---|
| 429 | +enum { |
|---|
| 430 | + WIL_1X_TYPE_EAP_PACKET = 0, |
|---|
| 431 | + WIL_1X_TYPE_EAPOL_START = 1, |
|---|
| 432 | + WIL_1X_TYPE_EAPOL_LOGOFF = 2, |
|---|
| 433 | + WIL_1X_TYPE_EAPOL_KEY = 3, |
|---|
| 434 | +}; |
|---|
| 435 | + |
|---|
| 436 | +#define WIL_EAPOL_KEY_TYPE_RSN 2 |
|---|
| 437 | +#define WIL_EAPOL_KEY_TYPE_WPA 254 |
|---|
| 438 | + |
|---|
| 439 | +struct wil_1x_hdr { |
|---|
| 440 | + u8 version; |
|---|
| 441 | + u8 type; |
|---|
| 442 | + __be16 length; |
|---|
| 443 | + /* followed by data */ |
|---|
| 444 | +} __packed; |
|---|
| 445 | + |
|---|
| 446 | +struct wil_eapol_key { |
|---|
| 447 | + u8 type; |
|---|
| 448 | + __be16 key_info; |
|---|
| 449 | + __be16 key_length; |
|---|
| 450 | + u8 replay_counter[WIL_EAP_REPLAY_COUNTER_LEN]; |
|---|
| 451 | + u8 key_nonce[WIL_EAP_NONCE_LEN]; |
|---|
| 452 | + u8 key_iv[WIL_EAP_KEY_IV_LEN]; |
|---|
| 453 | + u8 key_rsc[WIL_EAP_KEY_RSC_LEN]; |
|---|
| 454 | + u8 key_id[WIL_EAP_KEY_ID_LEN]; |
|---|
| 455 | +} __packed; |
|---|
| 456 | + |
|---|
| 426 | 457 | struct vring_rx_dma { |
|---|
| 427 | 458 | u32 d0; |
|---|
| 428 | 459 | struct wil_ring_dma_addr addr; |
|---|
| .. | .. |
|---|
| 457 | 488 | union wil_tx_desc tx; |
|---|
| 458 | 489 | union wil_rx_desc rx; |
|---|
| 459 | 490 | } __packed; |
|---|
| 491 | + |
|---|
| 492 | +struct packet_rx_info { |
|---|
| 493 | + u8 cid; |
|---|
| 494 | +}; |
|---|
| 495 | + |
|---|
| 496 | +/* this struct will be stored in the skb cb buffer |
|---|
| 497 | + * max length of the struct is limited to 48 bytes |
|---|
| 498 | + */ |
|---|
| 499 | +struct skb_rx_info { |
|---|
| 500 | + struct vring_rx_desc rx_desc; |
|---|
| 501 | + struct packet_rx_info rx_info; |
|---|
| 502 | +}; |
|---|
| 460 | 503 | |
|---|
| 461 | 504 | static inline int wil_rxdesc_tid(struct vring_rx_desc *d) |
|---|
| 462 | 505 | { |
|---|
| .. | .. |
|---|
| 530 | 573 | return WIL_GET_BITS(d->mac.d1, 13, 14); |
|---|
| 531 | 574 | } |
|---|
| 532 | 575 | |
|---|
| 533 | | -static inline int wil_rxdesc_phy_length(struct vring_rx_desc *d) |
|---|
| 534 | | -{ |
|---|
| 535 | | - return WIL_GET_BITS(d->dma.d0, 16, 29); |
|---|
| 536 | | -} |
|---|
| 537 | | - |
|---|
| 538 | 576 | static inline struct vring_rx_desc *wil_skb_rxdesc(struct sk_buff *skb) |
|---|
| 539 | 577 | { |
|---|
| 540 | 578 | return (void *)skb->cb; |
|---|
| .. | .. |
|---|
| 560 | 598 | return wil_ring_next_tail(ring) == ring->swhead; |
|---|
| 561 | 599 | } |
|---|
| 562 | 600 | |
|---|
| 563 | | -static inline bool wil_need_txstat(struct sk_buff *skb) |
|---|
| 601 | +static inline u8 *wil_skb_get_da(struct sk_buff *skb) |
|---|
| 564 | 602 | { |
|---|
| 565 | 603 | struct ethhdr *eth = (void *)skb->data; |
|---|
| 566 | 604 | |
|---|
| 567 | | - return is_unicast_ether_addr(eth->h_dest) && skb->sk && |
|---|
| 605 | + return eth->h_dest; |
|---|
| 606 | +} |
|---|
| 607 | + |
|---|
| 608 | +static inline u8 *wil_skb_get_sa(struct sk_buff *skb) |
|---|
| 609 | +{ |
|---|
| 610 | + struct ethhdr *eth = (void *)skb->data; |
|---|
| 611 | + |
|---|
| 612 | + return eth->h_source; |
|---|
| 613 | +} |
|---|
| 614 | + |
|---|
| 615 | +static inline bool wil_need_txstat(struct sk_buff *skb) |
|---|
| 616 | +{ |
|---|
| 617 | + const u8 *da = wil_skb_get_da(skb); |
|---|
| 618 | + |
|---|
| 619 | + return is_unicast_ether_addr(da) && skb->sk && |
|---|
| 568 | 620 | (skb_shinfo(skb)->tx_flags & SKBTX_WIFI_STATUS); |
|---|
| 569 | 621 | } |
|---|
| 570 | 622 | |
|---|
| .. | .. |
|---|
| 610 | 662 | return val >= min && val < max; |
|---|
| 611 | 663 | } |
|---|
| 612 | 664 | |
|---|
| 665 | +static inline u8 wil_skb_get_cid(struct sk_buff *skb) |
|---|
| 666 | +{ |
|---|
| 667 | + struct skb_rx_info *skb_rx_info = (void *)skb->cb; |
|---|
| 668 | + |
|---|
| 669 | + return skb_rx_info->rx_info.cid; |
|---|
| 670 | +} |
|---|
| 671 | + |
|---|
| 672 | +static inline void wil_skb_set_cid(struct sk_buff *skb, u8 cid) |
|---|
| 673 | +{ |
|---|
| 674 | + struct skb_rx_info *skb_rx_info = (void *)skb->cb; |
|---|
| 675 | + |
|---|
| 676 | + skb_rx_info->rx_info.cid = cid; |
|---|
| 677 | +} |
|---|
| 678 | + |
|---|
| 613 | 679 | void wil_netif_rx_any(struct sk_buff *skb, struct net_device *ndev); |
|---|
| 680 | +void wil_netif_rx(struct sk_buff *skb, struct net_device *ndev, int cid, |
|---|
| 681 | + struct wil_net_stats *stats, bool gro); |
|---|
| 614 | 682 | void wil_rx_reorder(struct wil6210_priv *wil, struct sk_buff *skb); |
|---|
| 615 | 683 | void wil_rx_bar(struct wil6210_priv *wil, struct wil6210_vif *vif, |
|---|
| 616 | 684 | u8 cid, u8 tid, u16 seq); |
|---|