630-phy_packets.patch 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. --- a/drivers/net/phy/phy_device.c
  2. +++ b/drivers/net/phy/phy_device.c
  3. @@ -146,6 +146,18 @@ int phy_scan_fixups(struct phy_device *p
  4. }
  5. EXPORT_SYMBOL(phy_scan_fixups);
  6. +static int generic_receive_skb(struct sk_buff *skb)
  7. +{
  8. + skb->protocol = eth_type_trans(skb, skb->dev);
  9. + return netif_receive_skb(skb);
  10. +}
  11. +
  12. +static int generic_rx(struct sk_buff *skb)
  13. +{
  14. + skb->protocol = eth_type_trans(skb, skb->dev);
  15. + return netif_rx(skb);
  16. +}
  17. +
  18. struct phy_device* phy_device_create(struct mii_bus *bus, int addr, int phy_id)
  19. {
  20. struct phy_device *dev;
  21. @@ -175,6 +187,8 @@ struct phy_device* phy_device_create(str
  22. dev_set_name(&dev->dev, PHY_ID_FMT, bus->id, addr);
  23. dev->state = PHY_DOWN;
  24. + dev->netif_receive_skb = &generic_receive_skb;
  25. + dev->netif_rx = &generic_rx;
  26. mutex_init(&dev->lock);
  27. INIT_DELAYED_WORK(&dev->state_queue, phy_state_machine);
  28. --- a/include/linux/phy.h
  29. +++ b/include/linux/phy.h
  30. @@ -325,6 +325,20 @@ struct phy_device {
  31. void (*adjust_link)(struct net_device *dev);
  32. void (*adjust_state)(struct net_device *dev);
  33. +
  34. + /*
  35. + * By default these point to the original functions
  36. + * with the same name. adding them to the phy_device
  37. + * allows the phy driver to override them for packet
  38. + * mangling if the ethernet driver supports it
  39. + * This is required to support some really horrible
  40. + * switches such as the Marvell 88E6060
  41. + */
  42. + int (*netif_receive_skb)(struct sk_buff *skb);
  43. + int (*netif_rx)(struct sk_buff *skb);
  44. +
  45. + /* alignment offset for packets */
  46. + int pkt_align;
  47. };
  48. #define to_phy_device(d) container_of(d, struct phy_device, dev)
  49. --- a/include/linux/netdevice.h
  50. +++ b/include/linux/netdevice.h
  51. @@ -844,6 +844,7 @@ struct net_device {
  52. void *ax25_ptr; /* AX.25 specific data */
  53. struct wireless_dev *ieee80211_ptr; /* IEEE 802.11 specific data,
  54. assign before registering */
  55. + void *phy_ptr; /* PHY device specific data */
  56. /*
  57. * Cache line mostly used on receive path (including eth_type_trans())