349-0008-brcmfmac-create-common-function-for-handling-brcmf_p.patch 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. From: Arend van Spriel <arend@broadcom.com>
  2. Date: Mon, 11 Apr 2016 11:35:28 +0200
  3. Subject: [PATCH] brcmfmac: create common function for handling
  4. brcmf_proto_hdrpull()
  5. In receive path brcmf_proto_hdrpull() needs to be called and handled
  6. similar in brcmf_rx_frame() and brcmf_rx_event(). Move that duplicated
  7. code in separate function.
  8. Reviewed-by: Hante Meuleman <hante.meuleman@broadcom.com>
  9. Reviewed-by: Pieter-Paul Giesberts <pieter-paul.giesberts@broadcom.com>
  10. Reviewed-by: Franky Lin <franky.lin@broadcom.com>
  11. Signed-off-by: Arend van Spriel <arend@broadcom.com>
  12. Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
  13. ---
  14. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
  15. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
  16. @@ -322,26 +322,35 @@ void brcmf_netif_rx(struct brcmf_if *ifp
  17. netif_rx_ni(skb);
  18. }
  19. -void brcmf_rx_frame(struct device *dev, struct sk_buff *skb, bool handle_event)
  20. +static int brcmf_rx_hdrpull(struct brcmf_pub *drvr, struct sk_buff *skb,
  21. + struct brcmf_if **ifp)
  22. {
  23. - struct brcmf_if *ifp;
  24. - struct brcmf_bus *bus_if = dev_get_drvdata(dev);
  25. - struct brcmf_pub *drvr = bus_if->drvr;
  26. int ret;
  27. - brcmf_dbg(DATA, "Enter: %s: rxp=%p\n", dev_name(dev), skb);
  28. -
  29. /* process and remove protocol-specific header */
  30. - ret = brcmf_proto_hdrpull(drvr, true, skb, &ifp);
  31. + ret = brcmf_proto_hdrpull(drvr, true, skb, ifp);
  32. - if (ret || !ifp || !ifp->ndev) {
  33. + if (ret || !(*ifp) || !(*ifp)->ndev) {
  34. if (ret != -ENODATA && ifp)
  35. - ifp->stats.rx_errors++;
  36. + (*ifp)->stats.rx_errors++;
  37. brcmu_pkt_buf_free_skb(skb);
  38. - return;
  39. + return -ENODATA;
  40. }
  41. - skb->protocol = eth_type_trans(skb, ifp->ndev);
  42. + skb->protocol = eth_type_trans(skb, (*ifp)->ndev);
  43. + return 0;
  44. +}
  45. +
  46. +void brcmf_rx_frame(struct device *dev, struct sk_buff *skb, bool handle_event)
  47. +{
  48. + struct brcmf_if *ifp;
  49. + struct brcmf_bus *bus_if = dev_get_drvdata(dev);
  50. + struct brcmf_pub *drvr = bus_if->drvr;
  51. +
  52. + brcmf_dbg(DATA, "Enter: %s: rxp=%p\n", dev_name(dev), skb);
  53. +
  54. + if (brcmf_rx_hdrpull(drvr, skb, &ifp))
  55. + return;
  56. if (brcmf_proto_is_reorder_skb(skb)) {
  57. brcmf_proto_rxreorder(ifp, skb);
  58. @@ -359,21 +368,11 @@ void brcmf_rx_event(struct device *dev,
  59. struct brcmf_if *ifp;
  60. struct brcmf_bus *bus_if = dev_get_drvdata(dev);
  61. struct brcmf_pub *drvr = bus_if->drvr;
  62. - int ret;
  63. brcmf_dbg(EVENT, "Enter: %s: rxp=%p\n", dev_name(dev), skb);
  64. - /* process and remove protocol-specific header */
  65. - ret = brcmf_proto_hdrpull(drvr, true, skb, &ifp);
  66. -
  67. - if (ret || !ifp || !ifp->ndev) {
  68. - if (ret != -ENODATA && ifp)
  69. - ifp->stats.rx_errors++;
  70. - brcmu_pkt_buf_free_skb(skb);
  71. + if (brcmf_rx_hdrpull(drvr, skb, &ifp))
  72. return;
  73. - }
  74. -
  75. - skb->protocol = eth_type_trans(skb, ifp->ndev);
  76. brcmf_fweh_process_skb(ifp->drvr, skb);
  77. brcmu_pkt_buf_free_skb(skb);