304-ixp4xx_eth_jumboframe.patch 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. --- a/drivers/net/ethernet/xscale/ixp4xx_eth.c
  2. +++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c
  3. @@ -57,7 +57,7 @@
  4. #define POOL_ALLOC_SIZE (sizeof(struct desc) * (RX_DESCS + TX_DESCS))
  5. #define REGS_SIZE 0x1000
  6. -#define MAX_MRU 1536 /* 0x600 */
  7. +#define MAX_MRU (14320 - ETH_HLEN - ETH_FCS_LEN)
  8. #define RX_BUFF_SIZE ALIGN((NET_IP_ALIGN) + MAX_MRU, 4)
  9. #define NAPI_WEIGHT 16
  10. @@ -1315,6 +1315,32 @@ static void destroy_queues(struct port *
  11. }
  12. }
  13. +static int eth_do_change_mtu(struct net_device *dev, int mtu)
  14. +{
  15. + struct port *port;
  16. + struct msg msg;
  17. + /* adjust for ethernet headers */
  18. + int framesize = mtu + ETH_HLEN + ETH_FCS_LEN;
  19. +
  20. + port = netdev_priv(dev);
  21. +
  22. + memset(&msg, 0, sizeof(msg));
  23. + msg.cmd = NPE_SETMAXFRAMELENGTHS;
  24. + msg.eth_id = port->id;
  25. +
  26. + /* max rx/tx 64 byte blocks */
  27. + msg.byte2 = ((framesize + 63) / 64) << 8;
  28. + msg.byte3 = ((framesize + 63) / 64) << 8;
  29. +
  30. + msg.byte4 = msg.byte6 = framesize >> 8;
  31. + msg.byte5 = msg.byte7 = framesize & 0xff;
  32. +
  33. + if (npe_send_recv_message(port->npe, &msg, "ETH_SET_MAX_FRAME_LENGTH"))
  34. + return -EIO;
  35. +
  36. + return 0;
  37. +}
  38. +
  39. static int eth_open(struct net_device *dev)
  40. {
  41. struct port *port = netdev_priv(dev);
  42. @@ -1366,6 +1392,8 @@ static int eth_open(struct net_device *d
  43. if (npe_send_recv_message(port->npe, &msg, "ETH_SET_FIREWALL_MODE"))
  44. return -EIO;
  45. + eth_do_change_mtu(dev, dev->mtu);
  46. +
  47. if ((err = request_queues(port)) != 0)
  48. return err;
  49. @@ -1505,7 +1533,26 @@ static int eth_close(struct net_device *
  50. return 0;
  51. }
  52. +static int ixp_eth_change_mtu(struct net_device *dev, int mtu)
  53. +{
  54. + int ret;
  55. +
  56. + if (mtu > MAX_MRU)
  57. + return -EINVAL;
  58. +
  59. + if (dev->flags & IFF_UP) {
  60. + ret = eth_do_change_mtu(dev, mtu);
  61. + if (ret < 0)
  62. + return ret;
  63. + }
  64. +
  65. + dev->mtu = mtu;
  66. +
  67. + return 0;
  68. +}
  69. +
  70. static const struct net_device_ops ixp4xx_netdev_ops = {
  71. + .ndo_change_mtu = ixp_eth_change_mtu,
  72. .ndo_open = eth_open,
  73. .ndo_stop = eth_close,
  74. .ndo_start_xmit = eth_xmit,