lmc_debug.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // SPDX-License-Identifier: GPL-2.0
  2. #include <linux/types.h>
  3. #include <linux/netdevice.h>
  4. #include <linux/interrupt.h>
  5. #include "lmc_debug.h"
  6. /*
  7. * Prints out len, max to 80 octets using printk, 20 per line
  8. */
  9. #ifdef DEBUG
  10. #ifdef LMC_PACKET_LOG
  11. void lmcConsoleLog(char *type, unsigned char *ucData, int iLen)
  12. {
  13. int iNewLine = 1;
  14. char str[80], *pstr;
  15. sprintf(str, KERN_DEBUG "lmc: %s: ", type);
  16. pstr = str+strlen(str);
  17. if(iLen > 240){
  18. printk(KERN_DEBUG "lmc: Printing 240 chars... out of: %d\n", iLen);
  19. iLen = 240;
  20. }
  21. else{
  22. printk(KERN_DEBUG "lmc: Printing %d chars\n", iLen);
  23. }
  24. while(iLen > 0)
  25. {
  26. sprintf(pstr, "%02x ", *ucData);
  27. pstr+=3;
  28. ucData++;
  29. if( !(iNewLine % 20))
  30. {
  31. sprintf(pstr, "\n");
  32. printk(str);
  33. sprintf(str, KERN_DEBUG "lmc: %s: ", type);
  34. pstr=str+strlen(str);
  35. }
  36. iNewLine++;
  37. iLen--;
  38. }
  39. sprintf(pstr, "\n");
  40. printk(str);
  41. }
  42. #endif
  43. #endif
  44. #ifdef DEBUG
  45. u32 lmcEventLogIndex;
  46. u32 lmcEventLogBuf[LMC_EVENTLOGSIZE * LMC_EVENTLOGARGS];
  47. void lmcEventLog(u32 EventNum, u32 arg2, u32 arg3)
  48. {
  49. lmcEventLogBuf[lmcEventLogIndex++] = EventNum;
  50. lmcEventLogBuf[lmcEventLogIndex++] = arg2;
  51. lmcEventLogBuf[lmcEventLogIndex++] = arg3;
  52. lmcEventLogBuf[lmcEventLogIndex++] = jiffies;
  53. lmcEventLogIndex &= (LMC_EVENTLOGSIZE * LMC_EVENTLOGARGS) - 1;
  54. }
  55. #endif /* DEBUG */
  56. void lmc_trace(struct net_device *dev, char *msg){
  57. #ifdef LMC_TRACE
  58. unsigned long j = jiffies + 3; /* Wait for 50 ms */
  59. if(in_interrupt()){
  60. printk("%s: * %s\n", dev->name, msg);
  61. // while(time_before(jiffies, j+10))
  62. // ;
  63. }
  64. else {
  65. printk("%s: %s\n", dev->name, msg);
  66. while(time_before(jiffies, j))
  67. schedule();
  68. }
  69. #endif
  70. }
  71. /* --------------------------- end if_lmc_linux.c ------------------------ */