ethernet-util.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * This file is based on code from OCTEON SDK by Cavium Networks.
  4. *
  5. * Copyright (c) 2003-2007 Cavium Networks
  6. */
  7. #include <asm/octeon/cvmx-pip.h>
  8. #include <asm/octeon/cvmx-helper.h>
  9. #include <asm/octeon/cvmx-helper-util.h>
  10. /**
  11. * cvm_oct_get_buffer_ptr - convert packet data address to pointer
  12. * @packet_ptr: Packet data hardware address
  13. *
  14. * Returns Packet buffer pointer
  15. */
  16. static inline void *cvm_oct_get_buffer_ptr(union cvmx_buf_ptr packet_ptr)
  17. {
  18. return cvmx_phys_to_ptr(((packet_ptr.s.addr >> 7) - packet_ptr.s.back)
  19. << 7);
  20. }
  21. /**
  22. * INTERFACE - convert IPD port to logical interface
  23. * @ipd_port: Port to check
  24. *
  25. * Returns Logical interface
  26. */
  27. static inline int INTERFACE(int ipd_port)
  28. {
  29. int interface;
  30. if (ipd_port == CVMX_PIP_NUM_INPUT_PORTS)
  31. return 10;
  32. interface = cvmx_helper_get_interface_num(ipd_port);
  33. if (interface >= 0)
  34. return interface;
  35. panic("Illegal ipd_port %d passed to %s\n", ipd_port, __func__);
  36. }
  37. /**
  38. * INDEX - convert IPD/PKO port number to the port's interface index
  39. * @ipd_port: Port to check
  40. *
  41. * Returns Index into interface port list
  42. */
  43. static inline int INDEX(int ipd_port)
  44. {
  45. return cvmx_helper_get_interface_index_num(ipd_port);
  46. }