* [RFT] simplify skge /proc interface.
@ 2003-09-04 23:06 Stephen Hemminger
2003-09-05 9:27 ` Mirko Lindner
0 siblings, 1 reply; 6+ messages in thread
From: Stephen Hemminger @ 2003-09-04 23:06 UTC (permalink / raw)
To: Jeff Garzik, Mirko Lindner, Ralph Roesler; +Cc: netdev
This patch is against 2.6.0-test4 and simplifys the /proc interface for
the skge driver.
* Use seq_file single_open interface to avoid possible buffer over
run and formatting issues.
* Put pointer to device in the proc dir private data to avoid having
to search through devices to find the info.
* Use %lld rather than special formatting code
* use proc_mkdir
* Don't die if proc fs is not configured or creating entries fails.
New code is written in kernel style.
Builds and loads but don't have real hardware. Could someone
please test this with a real board?
Somewhere in this 8K line driver is a 1000 line driver waiting to get out...
diff -Nru a/drivers/net/sk98lin/skge.c b/drivers/net/sk98lin/skge.c
--- a/drivers/net/sk98lin/skge.c Thu Sep 4 15:53:18 2003
+++ b/drivers/net/sk98lin/skge.c Thu Sep 4 15:53:18 2003
@@ -526,13 +526,11 @@
******************************************************************************/
static const char SK_Root_Dir_entry[] = "sk98lin";
+
+#ifdef CONFIG_PROC_FS
static struct proc_dir_entry *pSkRootDir;
-extern int sk_proc_read( char *buffer,
- char **buffer_location,
- off_t offset,
- int buffer_length,
- int *eof,
- void *data);
+extern struct file_operations sk_proc_fops;
+#endif
extern void SkDimEnableModerationIfNeeded(SK_AC *pAC);
extern void SkDimDisplayModerationSettings(SK_AC *pAC);
@@ -573,7 +571,6 @@
*/
static int __init skge_probe (void)
{
- int proc_root_initialized = 0;
int boards_found = 0;
int vendor_flag = SK_FALSE;
SK_AC *pAC;
@@ -724,30 +721,31 @@
SK_MEMCPY(&SK_Root_Dir_entry, BootString,
sizeof(SK_Root_Dir_entry) - 1);
+#ifdef CONFIG_PROC_FS
/*Create proc (directory)*/
- if(!proc_root_initialized) {
- pSkRootDir = create_proc_entry(SK_Root_Dir_entry,
- S_IFDIR | S_IWUSR | S_IRUGO | S_IXUGO, proc_net);
- pSkRootDir->owner = THIS_MODULE;
- proc_root_initialized = 1;
+ if(!pSkRootDir) {
+ pSkRootDir = proc_mkdir(SK_Root_Dir_entry,
+ proc_net);
+ if (!pSkRootDir) {
+ printk(KERN_WARNING "%s: Unable to create /proc/net/%s",
+ dev->name, SK_Root_Dir_entry);
+ /* not fatal */
+ } else
+ pSkRootDir->owner = THIS_MODULE;
}
-
+#endif
}
-
+#ifdef CONFIG_PROC_FS
/* Create proc file */
- pProcFile = create_proc_entry(dev->name,
- S_IFREG | S_IXUSR | S_IWGRP | S_IROTH,
- pSkRootDir);
-
-
- pProcFile->read_proc = sk_proc_read;
- pProcFile->write_proc = NULL;
- pProcFile->nlink = 1;
- pProcFile->size = sizeof(dev->name + 1);
- pProcFile->data = (void *)pProcFile;
- pProcFile->owner = THIS_MODULE;
+ if (pSkRootDir) {
+ pProcFile = create_proc_entry(dev->name, S_IRUGO,
+ pSkRootDir);
+ pProcFile->proc_fops = &sk_proc_fops;
+ pProcFile->data = dev;
+ }
+#endif
pNet->PortNr = 0;
pNet->NetNr = 0;
@@ -798,17 +796,14 @@
#endif
#endif
- pProcFile = create_proc_entry(dev->name,
- S_IFREG | S_IXUSR | S_IWGRP | S_IROTH,
- pSkRootDir);
-
-
- pProcFile->read_proc = sk_proc_read;
- pProcFile->write_proc = NULL;
- pProcFile->nlink = 1;
- pProcFile->size = sizeof(dev->name + 1);
- pProcFile->data = (void *)pProcFile;
- pProcFile->owner = THIS_MODULE;
+#ifdef CONFIG_PROC_FS
+ if (pSkRootDir) {
+ pProcFile = create_proc_entry(dev->name, S_IRUGO,
+ pSkRootDir);
+ pProcFile->proc_fops = &sk_proc_fops;
+ pProcFile->data = dev;
+ }
+#endif
memcpy((caddr_t) &dev->dev_addr,
(caddr_t) &pAC->Addr.Net[1].CurrentMacAddress, 6);
diff -Nru a/drivers/net/sk98lin/skproc.c b/drivers/net/sk98lin/skproc.c
--- a/drivers/net/sk98lin/skproc.c Thu Sep 4 15:53:18 2003
+++ b/drivers/net/sk98lin/skproc.c Thu Sep 4 15:53:18 2003
@@ -83,452 +83,219 @@
******************************************************************************/
#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
#include "h/skdrv1st.h"
#include "h/skdrv2nd.h"
-#define ZEROPAD 1 /* pad with zero */
-#define SIGN 2 /* unsigned/signed long */
-#define PLUS 4 /* show plus */
-#define SPACE 8 /* space if plus */
-#define LEFT 16 /* left justified */
-#define SPECIALX 32 /* 0x */
-#define LARGE 64
-
- extern struct net_device *SkGeRootDev;
-
-extern char * SkNumber(
- char * str,
- long long num,
- int base,
- int size,
- int precision,
- int type);
-
-int sk_proc_read(char *buffer,
- char **buffer_location,
- off_t offset,
- int buffer_length,
- int *eof,
- void *data);
+#ifdef CONFIG_PROC_FS
-
-/*****************************************************************************
- *
- * sk_proc_read - print "summaries" entry
- *
- * Description:
- * This function fills the proc entry with statistic data about
- * the ethernet device.
- *
- *
- * Returns: buffer with statistic data
- *
- */
-int sk_proc_read(char *buffer,
-char **buffer_location,
-off_t offset,
-int buffer_length,
-int *eof,
-void *data)
+static int sk_seq_show(struct seq_file *seq, void *v)
{
- int len = 0;
- int t;
+ const struct net_device *dev = v;
+ const struct s_DevNet *pNet = dev->priv;
+ const struct s_AC *pAC = pNet->pAC;
+ const struct s_PnmiStrucData *pPnmiStruct = &pAC->PnmiStruct;
+ const struct s_PnmiStat *pPnmiStat = &pPnmiStruct->Stat[0];
int i;
- DEV_NET *pNet;
- SK_AC *pAC;
- char test_buf[100];
- char sens_msg[50];
- unsigned long Flags;
- unsigned int Size;
- struct SK_NET_DEVICE *next;
- struct SK_NET_DEVICE *SkgeProcDev = SkGeRootDev;
-
- SK_PNMI_STRUCT_DATA *pPnmiStruct;
- SK_PNMI_STAT *pPnmiStat;
- struct proc_dir_entry *file = (struct proc_dir_entry*) data;
-
- while (SkgeProcDev) {
- pNet = (DEV_NET*) SkgeProcDev->priv;
- pAC = pNet->pAC;
- next = pAC->Next;
- pPnmiStruct = &pAC->PnmiStruct;
- /* NetIndex in GetStruct is now required, zero is only dummy */
-
- for (t=pAC->GIni.GIMacsFound; t > 0; t--) {
- if ((pAC->GIni.GIMacsFound == 2) && pAC->RlmtNets == 1)
- t--;
-
- spin_lock_irqsave(&pAC->SlowPathLock, Flags);
- Size = SK_PNMI_STRUCT_SIZE;
- SkPnmiGetStruct(pAC, pAC->IoBase,
- pPnmiStruct, &Size, t-1);
- spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
-
- if (strcmp(pAC->dev[t-1]->name, file->name) == 0) {
- pPnmiStat = &pPnmiStruct->Stat[0];
- len = sprintf(buffer,
- "\nDetailed statistic for device %s\n",
- pAC->dev[t-1]->name);
- len += sprintf(buffer + len,
- "=======================================\n");
+ int unit = !(pAC->dev[0] == dev);
+ char sens_msg[50];
+
+ seq_printf(seq,
+ "\nDetailed statistic for device %s\n",
+ dev->name);
+ seq_puts(seq,
+ "=======================================\n");
+
+ /* Board statistics */
+ seq_puts(seq, "\nBoard statistics\n\n");
- /* Board statistics */
- len += sprintf(buffer + len,
- "\nBoard statistics\n\n");
- len += sprintf(buffer + len,
- "Active Port %c\n",
- 'A' + pAC->Rlmt.Net[t-1].Port[pAC->Rlmt.
- Net[t-1].PrefPort]->PortNumber);
- len += sprintf(buffer + len,
- "Preferred Port %c\n",
- 'A' + pAC->Rlmt.Net[t-1].Port[pAC->Rlmt.
- Net[t-1].PrefPort]->PortNumber);
-
- len += sprintf(buffer + len,
- "Bus speed (MHz) %d\n",
- pPnmiStruct->BusSpeed);
-
- len += sprintf(buffer + len,
- "Bus width (Bit) %d\n",
- pPnmiStruct->BusWidth);
- len += sprintf(buffer + len,
- "Hardware revision v%d.%d\n",
- (pAC->GIni.GIPciHwRev >> 4) & 0x0F,
- pAC->GIni.GIPciHwRev & 0x0F);
-
- /* Print sensor informations */
- for (i=0; i < pAC->I2c.MaxSens; i ++) {
- /* Check type */
- switch (pAC->I2c.SenTable[i].SenType) {
- case 1:
- strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
- strcat(sens_msg, " (C)");
- len += sprintf(buffer + len,
- "%-25s %d.%02d\n",
- sens_msg,
- pAC->I2c.SenTable[i].SenValue / 10,
- pAC->I2c.SenTable[i].SenValue % 10);
-
- strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
- strcat(sens_msg, " (F)");
- len += sprintf(buffer + len,
- "%-25s %d.%02d\n",
- sens_msg,
- ((((pAC->I2c.SenTable[i].SenValue)
- *10)*9)/5 + 3200)/100,
- ((((pAC->I2c.SenTable[i].SenValue)
- *10)*9)/5 + 3200) % 10);
- break;
- case 2:
- strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
- strcat(sens_msg, " (V)");
- len += sprintf(buffer + len,
- "%-25s %d.%03d\n",
- sens_msg,
- pAC->I2c.SenTable[i].SenValue / 1000,
- pAC->I2c.SenTable[i].SenValue % 1000);
- break;
- case 3:
- strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
- strcat(sens_msg, " (rpm)");
- len += sprintf(buffer + len,
- "%-25s %d\n",
- sens_msg,
- pAC->I2c.SenTable[i].SenValue);
- break;
- default:
- break;
- }
- }
+ seq_printf(seq, "Active Port %c\n",
+ 'A' + pAC->Rlmt.Net[unit].Port[pAC->Rlmt.
+ Net[unit].PrefPort]->PortNumber);
+
+ seq_printf(seq, "Preferred Port %c\n",
+ 'A' + pAC->Rlmt.Net[unit].Port[pAC->Rlmt.
+ Net[unit].PrefPort]->PortNumber);
+
+ seq_printf(seq, "Bus speed (MHz) %d\n",
+ pPnmiStruct->BusSpeed);
+
+ seq_printf(seq,
+ "Bus width (Bit) %d\n",
+ pPnmiStruct->BusWidth);
+ seq_printf(seq,
+ "Hardware revision v%d.%d\n",
+ (pAC->GIni.GIPciHwRev >> 4) & 0x0F,
+ pAC->GIni.GIPciHwRev & 0x0F);
+
+ /* Print sensor informations */
+ for (i=0; i < pAC->I2c.MaxSens; i ++) {
+ /* Check type */
+ switch (pAC->I2c.SenTable[i].SenType) {
+ case 1:
+ strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
+ strcat(sens_msg, " (C)");
+ seq_printf(seq,
+ "%-25s %d.%02d\n",
+ sens_msg,
+ pAC->I2c.SenTable[i].SenValue / 10,
+ pAC->I2c.SenTable[i].SenValue % 10);
+
+ strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
+ strcat(sens_msg, " (F)");
+ seq_printf(seq,
+ "%-25s %d.%02d\n",
+ sens_msg,
+ ((((pAC->I2c.SenTable[i].SenValue)
+ *10)*9)/5 + 3200)/100,
+ ((((pAC->I2c.SenTable[i].SenValue)
+ *10)*9)/5 + 3200) % 10);
+ break;
+ case 2:
+ strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
+ strcat(sens_msg, " (V)");
+ seq_printf(seq,
+ "%-25s %d.%03d\n",
+ sens_msg,
+ pAC->I2c.SenTable[i].SenValue / 1000,
+ pAC->I2c.SenTable[i].SenValue % 1000);
+ break;
+ case 3:
+ strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
+ strcat(sens_msg, " (rpm)");
+ seq_printf(seq,
+ "%-25s %d\n",
+ sens_msg,
+ pAC->I2c.SenTable[i].SenValue);
+ break;
+ default:
+ break;
+ }
+ }
- /*Receive statistics */
- len += sprintf(buffer + len,
- "\nReceive statistics\n\n");
-
- len += sprintf(buffer + len,
- "Received bytes %s\n",
- SkNumber(test_buf, pPnmiStat->StatRxOctetsOkCts,
- 10,0,-1,0));
- len += sprintf(buffer + len,
- "Received packets %s\n",
- SkNumber(test_buf, pPnmiStat->StatRxOkCts,
- 10,0,-1,0));
+ /*Receive statistics */
+ seq_printf(seq,
+ "\nReceive statistics\n\n");
+
+ seq_printf(seq,
+ "Received bytes %lld\n",
+ pPnmiStat->StatRxOctetsOkCts);
+ seq_printf(seq,
+ "Received packets %lld\n",
+ pPnmiStat->StatRxOkCts);
#if 0
- if (pAC->GIni.GP[0].PhyType == SK_PHY_XMAC &&
- pAC->HWRevision < 12) {
- pPnmiStruct->InErrorsCts = pPnmiStruct->InErrorsCts -
- pPnmiStat->StatRxShortsCts;
- pPnmiStat->StatRxShortsCts = 0;
- }
+ if (pAC->GIni.GP[0].PhyType == SK_PHY_XMAC &&
+ pAC->HWRevision < 12) {
+ pPnmiStruct->InErrorsCts = pPnmiStruct->InErrorsCts -
+ pPnmiStat->StatRxShortsCts;
+ pPnmiStat->StatRxShortsCts = 0;
+ }
#endif
- if (pNet->Mtu > 1500)
- pPnmiStruct->InErrorsCts = pPnmiStruct->InErrorsCts -
- pPnmiStat->StatRxTooLongCts;
-
- len += sprintf(buffer + len,
- "Receive errors %s\n",
- SkNumber(test_buf, pPnmiStruct->InErrorsCts,
- 10,0,-1,0));
- len += sprintf(buffer + len,
- "Receive dropped %s\n",
- SkNumber(test_buf, pPnmiStruct->RxNoBufCts,
- 10,0,-1,0));
- len += sprintf(buffer + len,
- "Received multicast %s\n",
- SkNumber(test_buf, pPnmiStat->StatRxMulticastOkCts,
- 10,0,-1,0));
- len += sprintf(buffer + len,
- "Receive error types\n");
- len += sprintf(buffer + len,
- " length %s\n",
- SkNumber(test_buf, pPnmiStat->StatRxRuntCts,
- 10, 0, -1, 0));
- len += sprintf(buffer + len,
- " buffer overflow %s\n",
- SkNumber(test_buf, pPnmiStat->StatRxFifoOverflowCts,
- 10, 0, -1, 0));
- len += sprintf(buffer + len,
- " bad crc %s\n",
- SkNumber(test_buf, pPnmiStat->StatRxFcsCts,
- 10, 0, -1, 0));
- len += sprintf(buffer + len,
- " framing %s\n",
- SkNumber(test_buf, pPnmiStat->StatRxFramingCts,
- 10, 0, -1, 0));
- len += sprintf(buffer + len,
- " missed frames %s\n",
- SkNumber(test_buf, pPnmiStat->StatRxMissedCts,
- 10, 0, -1, 0));
-
- if (pNet->Mtu > 1500)
- pPnmiStat->StatRxTooLongCts = 0;
-
- len += sprintf(buffer + len,
- " too long %s\n",
- SkNumber(test_buf, pPnmiStat->StatRxTooLongCts,
- 10, 0, -1, 0));
- len += sprintf(buffer + len,
- " carrier extension %s\n",
- SkNumber(test_buf, pPnmiStat->StatRxCextCts,
- 10, 0, -1, 0));
- len += sprintf(buffer + len,
- " too short %s\n",
- SkNumber(test_buf, pPnmiStat->StatRxShortsCts,
- 10, 0, -1, 0));
- len += sprintf(buffer + len,
- " symbol %s\n",
- SkNumber(test_buf, pPnmiStat->StatRxSymbolCts,
- 10, 0, -1, 0));
- len += sprintf(buffer + len,
- " LLC MAC size %s\n",
- SkNumber(test_buf, pPnmiStat->StatRxIRLengthCts,
- 10, 0, -1, 0));
- len += sprintf(buffer + len,
- " carrier event %s\n",
- SkNumber(test_buf, pPnmiStat->StatRxCarrierCts,
- 10, 0, -1, 0));
- len += sprintf(buffer + len,
- " jabber %s\n",
- SkNumber(test_buf, pPnmiStat->StatRxJabberCts,
- 10, 0, -1, 0));
-
-
- /*Transmit statistics */
- len += sprintf(buffer + len,
- "\nTransmit statistics\n\n");
-
- len += sprintf(buffer + len,
- "Transmited bytes %s\n",
- SkNumber(test_buf, pPnmiStat->StatTxOctetsOkCts,
- 10,0,-1,0));
- len += sprintf(buffer + len,
- "Transmited packets %s\n",
- SkNumber(test_buf, pPnmiStat->StatTxOkCts,
- 10,0,-1,0));
- len += sprintf(buffer + len,
- "Transmit errors %s\n",
- SkNumber(test_buf, pPnmiStat->StatTxSingleCollisionCts,
- 10,0,-1,0));
- len += sprintf(buffer + len,
- "Transmit dropped %s\n",
- SkNumber(test_buf, pPnmiStruct->TxNoBufCts,
- 10,0,-1,0));
- len += sprintf(buffer + len,
- "Transmit collisions %s\n",
- SkNumber(test_buf, pPnmiStat->StatTxSingleCollisionCts,
- 10,0,-1,0));
- len += sprintf(buffer + len,
- "Transmit error types\n");
- len += sprintf(buffer + len,
- " excessive collision %ld\n",
- pAC->stats.tx_aborted_errors);
- len += sprintf(buffer + len,
- " carrier %s\n",
- SkNumber(test_buf, pPnmiStat->StatTxCarrierCts,
- 10, 0, -1, 0));
- len += sprintf(buffer + len,
- " fifo underrun %s\n",
- SkNumber(test_buf, pPnmiStat->StatTxFifoUnderrunCts,
- 10, 0, -1, 0));
- len += sprintf(buffer + len,
- " heartbeat %s\n",
- SkNumber(test_buf, pPnmiStat->StatTxCarrierCts,
- 10, 0, -1, 0));
- len += sprintf(buffer + len,
- " window %ld\n",
- pAC->stats.tx_window_errors);
+ seq_printf(seq,"Receive errors %lld\n",
+ (pNet->Mtu > 1500)
+ ? pPnmiStruct->InErrorsCts - pPnmiStat->StatRxTooLongCts
+ : pPnmiStruct->InErrorsCts);
+
+ seq_printf(seq,
+ "Receive dropped %lld\n",
+ pPnmiStruct->RxNoBufCts);
+ seq_printf(seq,
+ "Received multicast %lld\n",
+ pPnmiStat->StatRxMulticastOkCts);
+ seq_printf(seq,
+ "Receive error types\n");
+ seq_printf(seq,
+ " length %lld\n",
+ pPnmiStat->StatRxRuntCts);
+ seq_printf(seq,
+ " buffer overflow %lld\n",
+ pPnmiStat->StatRxFifoOverflowCts);
+ seq_printf(seq,
+ " bad crc %lld\n",
+ pPnmiStat->StatRxFcsCts);
+ seq_printf(seq,
+ " framing %lld\n",
+ pPnmiStat->StatRxFramingCts);
+ seq_printf(seq,
+ " missed frames %lld\n",
+ pPnmiStat->StatRxMissedCts);
+
+ seq_printf(seq,
+ " too long %lld\n",
+ pPnmiStat->StatRxTooLongCts);
+
+ seq_printf(seq,
+ " carrier extension %lld\n",
+ pPnmiStat->StatRxCextCts);
+ seq_printf(seq,
+ " too short %lld\n",
+ pPnmiStat->StatRxShortsCts);
+ seq_printf(seq,
+ " symbol %lld\n",
+ pPnmiStat->StatRxSymbolCts);
+ seq_printf(seq,
+ " LLC MAC size %lld\n",
+ pPnmiStat->StatRxIRLengthCts);
+ seq_printf(seq,
+ " carrier event %lld\n",
+ pPnmiStat->StatRxCarrierCts);
+ seq_printf(seq,
+ " jabber %lld\n",
+ pPnmiStat->StatRxJabberCts);
+
+
+ /*Transmit statistics */
+ seq_printf(seq,
+ "\nTransmit statistics\n\n");
- }
- }
- SkgeProcDev = next;
- }
- if (offset >= len) {
- *eof = 1;
- return 0;
- }
+ seq_printf(seq,
+ "Transmited bytes %lld\n",
+ pPnmiStat->StatTxOctetsOkCts);
+ seq_printf(seq,
+ "Transmited packets %lld\n",
+ pPnmiStat->StatTxOkCts);
+ seq_printf(seq,
+ "Transmit errors %lld\n",
+ pPnmiStat->StatTxSingleCollisionCts);
+ seq_printf(seq,
+ "Transmit dropped %lld\n",
+ pPnmiStruct->TxNoBufCts);
+ seq_printf(seq,
+ "Transmit collisions %lld\n",
+ pPnmiStat->StatTxSingleCollisionCts);
+ seq_printf(seq,
+ "Transmit error types\n");
+ seq_printf(seq,
+ " excessive collision %ld\n",
+ pAC->stats.tx_aborted_errors);
+ seq_printf(seq,
+ " carrier %lld\n",
+ pPnmiStat->StatTxCarrierCts);
+ seq_printf(seq,
+ " fifo underrun %lld\n",
+ pPnmiStat->StatTxFifoUnderrunCts);
+ seq_printf(seq,
+ " heartbeat %lld\n",
+ pPnmiStat->StatTxCarrierCts);
+ seq_printf(seq,
+ " window %ld\n",
+ pAC->stats.tx_window_errors);
- *buffer_location = buffer + offset;
- if (buffer_length >= len - offset) {
- *eof = 1;
- }
- return (min_t(int, buffer_length, len - offset));
+ return 0;
}
-
-
-
-
-/*****************************************************************************
- *
- * SkDoDiv - convert 64bit number
- *
- * Description:
- * This function "converts" a long long number.
- *
- * Returns:
- * remainder of division
- */
-static long SkDoDiv (long long Dividend, int Divisor, long long *pErg)
+static int sk_proc_open(struct inode *inode, struct file *file)
{
- long Rest;
- long long Ergebnis;
- long Akku;
-
-
- Akku = Dividend >> 32;
-
- Ergebnis = ((long long) (Akku / Divisor)) << 32;
- Rest = Akku % Divisor ;
-
- Akku = Rest << 16;
- Akku |= ((Dividend & 0xFFFF0000) >> 16);
-
-
- Ergebnis += ((long long) (Akku / Divisor)) << 16;
- Rest = Akku % Divisor ;
-
- Akku = Rest << 16;
- Akku |= (Dividend & 0xFFFF);
-
- Ergebnis += (Akku / Divisor);
- Rest = Akku % Divisor ;
-
- *pErg = Ergebnis;
- return (Rest);
+ return single_open(file, sk_seq_show, PDE(inode)->data);
}
-
-#if 0
-#define do_div(n,base) ({ \
-long long __res; \
-__res = ((unsigned long long) n) % (unsigned) base; \
-n = ((unsigned long long) n) / (unsigned) base; \
-__res; })
+struct file_operations sk_proc_fops = {
+ .owner = THIS_MODULE,
+ .open = sk_proc_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
#endif
-
-
-/*****************************************************************************
- *
- * SkNumber - Print results
- *
- * Description:
- * This function converts a long long number into a string.
- *
- * Returns:
- * number as string
- */
-char * SkNumber(char * str, long long num, int base, int size, int precision
- ,int type)
-{
- char c,sign,tmp[66], *strorg = str;
- const char *digits="0123456789abcdefghijklmnopqrstuvwxyz";
- int i;
-
- if (type & LARGE)
- digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- if (type & LEFT)
- type &= ~ZEROPAD;
- if (base < 2 || base > 36)
- return 0;
- c = (type & ZEROPAD) ? '0' : ' ';
- sign = 0;
- if (type & SIGN) {
- if (num < 0) {
- sign = '-';
- num = -num;
- size--;
- } else if (type & PLUS) {
- sign = '+';
- size--;
- } else if (type & SPACE) {
- sign = ' ';
- size--;
- }
- }
- if (type & SPECIALX) {
- if (base == 16)
- size -= 2;
- else if (base == 8)
- size--;
- }
- i = 0;
- if (num == 0)
- tmp[i++]='0';
- else while (num != 0)
- tmp[i++] = digits[SkDoDiv(num,base, &num)];
-
- if (i > precision)
- precision = i;
- size -= precision;
- if (!(type&(ZEROPAD+LEFT)))
- while(size-->0)
- *str++ = ' ';
- if (sign)
- *str++ = sign;
- if (type & SPECIALX) {
- if (base==8)
- *str++ = '0';
- else if (base==16) {
- *str++ = '0';
- *str++ = digits[33];
- }
- }
- if (!(type & LEFT))
- while (size-- > 0)
- *str++ = c;
- while (i < precision--)
- *str++ = '0';
- while (i-- > 0)
- *str++ = tmp[i];
- while (size-- > 0)
- *str++ = ' ';
-
- str[0] = '\0';
-
- return strorg;
-}
-
-
-
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFT] simplify skge /proc interface.
2003-09-04 23:06 [RFT] simplify skge /proc interface Stephen Hemminger
@ 2003-09-05 9:27 ` Mirko Lindner
2003-09-26 18:17 ` [PATCH] (1/3) sk98lin -- build on smp fix Stephen Hemminger
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Mirko Lindner @ 2003-09-05 9:27 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: Jeff Garzik, Ralph Roesler, netdev
Thank you for the submission,
the latest driver version 6.17 (still by Linus) has a lot of
proc-changes. I´ll insert the remaining changes into our tree and make a
new release next week.
Cheers,
Mirko
On Fri, 2003-09-05 at 01:06, Stephen Hemminger wrote:
> This patch is against 2.6.0-test4 and simplifys the /proc interface for
> the skge driver.
>
> * Use seq_file single_open interface to avoid possible buffer over
> run and formatting issues.
> * Put pointer to device in the proc dir private data to avoid having
> to search through devices to find the info.
> * Use %lld rather than special formatting code
> * use proc_mkdir
> * Don't die if proc fs is not configured or creating entries fails.
>
> New code is written in kernel style.
>
> Builds and loads but don't have real hardware. Could someone
> please test this with a real board?
>
> Somewhere in this 8K line driver is a 1000 line driver waiting to get out...
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] (1/3) sk98lin -- build on smp fix
2003-09-05 9:27 ` Mirko Lindner
@ 2003-09-26 18:17 ` Stephen Hemminger
2003-09-27 9:57 ` Jeff Garzik
2003-09-26 18:17 ` [PATCH] (2/3) skge -- handle proc_fs errors Stephen Hemminger
2003-09-26 18:17 ` [PATCH] (3/3) sk98lin -- use seq_file for /proc Stephen Hemminger
2 siblings, 1 reply; 6+ messages in thread
From: Stephen Hemminger @ 2003-09-26 18:17 UTC (permalink / raw)
To: Mirko Lindner; +Cc: Jeff Garzik, Ralph Roesler, netdev
There is no exported variable called smp_num_cpus! so this driver
won't build on SMP. Since the local variable is never used anyway
just get rid of it.
This applies against 2.6.0-test5-bk13 which has the last vendor
driver update.
diff -Nru a/drivers/net/sk98lin/skdim.c b/drivers/net/sk98lin/skdim.c
--- a/drivers/net/sk98lin/skdim.c Fri Sep 26 11:01:04 2003
+++ b/drivers/net/sk98lin/skdim.c Fri Sep 26 11:01:04 2003
@@ -318,11 +318,6 @@
unsigned int TotalTime = 0;
unsigned int UsedTime = 0;
unsigned int SystemLoad = 0;
-#ifdef CONFIG_SMP
- unsigned int SKNumCpus = smp_num_cpus;
-#else
- unsigned int SKNumCpus = 1;
-#endif
/* unsigned int NbrCpu = 0; */
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] (2/3) skge -- handle proc_fs errors.
2003-09-05 9:27 ` Mirko Lindner
2003-09-26 18:17 ` [PATCH] (1/3) sk98lin -- build on smp fix Stephen Hemminger
@ 2003-09-26 18:17 ` Stephen Hemminger
2003-09-26 18:17 ` [PATCH] (3/3) sk98lin -- use seq_file for /proc Stephen Hemminger
2 siblings, 0 replies; 6+ messages in thread
From: Stephen Hemminger @ 2003-09-26 18:17 UTC (permalink / raw)
To: Mirko Lindner; +Cc: Jeff Garzik, Ralph Roesler, netdev
Existing code does not
- check if proc_fs functions return error.
- use proc_mkdir to make the directory.
Note pSkRootDir defined twice.
diff -Nru a/drivers/net/sk98lin/skge.c b/drivers/net/sk98lin/skge.c
--- a/drivers/net/sk98lin/skge.c Fri Sep 26 11:09:24 2003
+++ b/drivers/net/sk98lin/skge.c Fri Sep 26 11:09:24 2003
@@ -607,12 +607,6 @@
static uintptr_t RxQueueAddr[SK_MAX_MACS] = {0x400, 0x480};
-#ifdef CONFIG_PROC_FS
-static struct proc_dir_entry *pSkRootDir;
-#endif
-
-
-
/*****************************************************************************
*
* skge_probe - find all SK-98xx adapters
@@ -638,7 +632,6 @@
SK_BOOL BootStringCount = SK_FALSE;
int retval;
#ifdef CONFIG_PROC_FS
- int proc_root_initialized = 0;
struct proc_dir_entry *pProcFile;
#endif
@@ -758,26 +751,28 @@
sizeof(SK_Root_Dir_entry) - 1);
/*Create proc (directory)*/
- if(!proc_root_initialized) {
- pSkRootDir = create_proc_entry(SK_Root_Dir_entry,
- S_IFDIR | S_IWUSR | S_IRUGO | S_IXUGO, proc_net);
- pSkRootDir->owner = THIS_MODULE;
- proc_root_initialized = 1;
+ if(!pSkRootDir) {
+ pSkRootDir = proc_mkdir(SK_Root_Dir_entry, proc_net);
+ if (!pSkRootDir)
+ printk(KERN_WARNING "%s: Unable to create /proc/net/%s",
+ dev->name, SK_Root_Dir_entry);
+ else
+ pSkRootDir->owner = THIS_MODULE;
}
}
-
- /* Create proc file */
- pProcFile = create_proc_entry(dev->name,
- S_IFREG | S_IXUSR | S_IWGRP | S_IROTH,
- pSkRootDir);
-
- pProcFile->read_proc = sk_proc_read;
- pProcFile->write_proc = NULL;
- pProcFile->nlink = 1;
- pProcFile->size = sizeof(dev->name + 1);
- pProcFile->data = (void *)pProcFile;
- pProcFile->owner = THIS_MODULE;
+ /* Create proc file */
+ if (pSkRootDir &&
+ (pProcFile = create_proc_entry(dev->name,
+ S_IFREG | S_IXUSR | S_IWGRP | S_IROTH,
+ pSkRootDir))) {
+ pProcFile->read_proc = sk_proc_read;
+ pProcFile->write_proc = NULL;
+ pProcFile->nlink = 1;
+ pProcFile->size = sizeof(dev->name + 1);
+ pProcFile->data = (void *)pProcFile;
+ pProcFile->owner = THIS_MODULE;
+ }
#endif
pNet->PortNr = 0;
@@ -831,17 +826,18 @@
#endif
#ifdef CONFIG_PROC_FS
- pProcFile = create_proc_entry(dev->name,
- S_IFREG | S_IXUSR | S_IWGRP | S_IROTH,
- pSkRootDir);
-
+ if (pSkRootDir
+ && (pProcFile = create_proc_entry(dev->name,
+ S_IFREG | S_IXUSR | S_IWGRP | S_IROTH,
+ pSkRootDir))) {
- pProcFile->read_proc = sk_proc_read;
- pProcFile->write_proc = NULL;
- pProcFile->nlink = 1;
- pProcFile->size = sizeof(dev->name + 1);
- pProcFile->data = (void *)pProcFile;
- pProcFile->owner = THIS_MODULE;
+ pProcFile->read_proc = sk_proc_read;
+ pProcFile->write_proc = NULL;
+ pProcFile->nlink = 1;
+ pProcFile->size = sizeof(dev->name + 1);
+ pProcFile->data = (void *)pProcFile;
+ pProcFile->owner = THIS_MODULE;
+ }
#endif
memcpy((caddr_t) &dev->dev_addr,
@@ -1188,7 +1184,8 @@
#ifdef CONFIG_PROC_FS
/* clear proc-dir */
- remove_proc_entry(pSkRootDir->name, proc_net);
+ if (pSkRootDir)
+ remove_proc_entry(pSkRootDir->name, proc_net);
#endif
} /* skge_cleanup_module */
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] (3/3) sk98lin -- use seq_file for /proc
2003-09-05 9:27 ` Mirko Lindner
2003-09-26 18:17 ` [PATCH] (1/3) sk98lin -- build on smp fix Stephen Hemminger
2003-09-26 18:17 ` [PATCH] (2/3) skge -- handle proc_fs errors Stephen Hemminger
@ 2003-09-26 18:17 ` Stephen Hemminger
2 siblings, 0 replies; 6+ messages in thread
From: Stephen Hemminger @ 2003-09-26 18:17 UTC (permalink / raw)
To: Mirko Lindner; +Cc: Jeff Garzik, Ralph Roesler, netdev
Replace proc_read with seq_file interface which is much cleaner.
Also, instead of searching the list of devices looking for the
name which is slow and would break if interface name changes;
store a pointer to device in the proc entry, and retrieve
it from the information saved by single_open.
Formatting and other behaviours are retained.
diff -Nru a/drivers/net/sk98lin/skge.c b/drivers/net/sk98lin/skge.c
--- a/drivers/net/sk98lin/skge.c Fri Sep 26 11:10:48 2003
+++ b/drivers/net/sk98lin/skge.c Fri Sep 26 11:10:48 2003
@@ -577,13 +577,7 @@
#ifdef CONFIG_PROC_FS
static const char SK_Root_Dir_entry[] = "sk98lin";
static struct proc_dir_entry *pSkRootDir;
-
-extern int sk_proc_read( char *buffer,
- char **buffer_location,
- off_t offset,
- int buffer_length,
- int *eof,
- void *data);
+extern struct file_operations sk_proc_fops;
#endif
extern void SkDimEnableModerationIfNeeded(SK_AC *pAC);
@@ -762,16 +756,11 @@
}
/* Create proc file */
- if (pSkRootDir &&
- (pProcFile = create_proc_entry(dev->name,
- S_IFREG | S_IXUSR | S_IWGRP | S_IROTH,
- pSkRootDir))) {
- pProcFile->read_proc = sk_proc_read;
- pProcFile->write_proc = NULL;
- pProcFile->nlink = 1;
- pProcFile->size = sizeof(dev->name + 1);
- pProcFile->data = (void *)pProcFile;
- pProcFile->owner = THIS_MODULE;
+ if (pSkRootDir
+ && (pProcFile = create_proc_entry(dev->name, S_IRUGO,
+ pSkRootDir))) {
+ pProcFile->proc_fops = &sk_proc_fops;
+ pProcFile->data = dev;
}
#endif
@@ -827,16 +816,11 @@
#ifdef CONFIG_PROC_FS
if (pSkRootDir
- && (pProcFile = create_proc_entry(dev->name,
- S_IFREG | S_IXUSR | S_IWGRP | S_IROTH,
+ && (pProcFile = create_proc_entry(dev->name,
+ S_IRUGO,
pSkRootDir))) {
-
- pProcFile->read_proc = sk_proc_read;
- pProcFile->write_proc = NULL;
- pProcFile->nlink = 1;
- pProcFile->size = sizeof(dev->name + 1);
- pProcFile->data = (void *)pProcFile;
- pProcFile->owner = THIS_MODULE;
+ pProcFile->proc_fops = &sk_proc_fops;
+ pProcFile->data = dev;
}
#endif
diff -Nru a/drivers/net/sk98lin/skproc.c b/drivers/net/sk98lin/skproc.c
--- a/drivers/net/sk98lin/skproc.c Fri Sep 26 11:10:48 2003
+++ b/drivers/net/sk98lin/skproc.c Fri Sep 26 11:10:48 2003
@@ -90,276 +90,227 @@
******************************************************************************/
#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
#include "h/skdrv1st.h"
#include "h/skdrv2nd.h"
- extern struct net_device *SkGeRootDev;
+#ifdef CONFIG_PROC_FS
+extern struct net_device *SkGeRootDev;
-int sk_proc_read(char *buffer,
- char **buffer_location,
- off_t offset,
- int buffer_length,
- int *eof,
- void *data);
-
-
-
-/*****************************************************************************
- *
- * sk_proc_read - print "summaries" entry
- *
- * Description:
- * This function fills the proc entry with statistic data about
- * the ethernet device.
- *
- *
- * Returns: buffer with statistic data
- *
- */
-int sk_proc_read(char *buffer,
-char **buffer_location,
-off_t offset,
-int buffer_length,
-int *eof,
-void *data)
+static int sk_seq_show(struct seq_file *seq, void *v)
{
- int len = 0;
- int t;
+ struct net_device *dev = seq->private;
+ DEV_NET *pNet = dev->priv;
+ SK_AC *pAC = pNet->pAC;
+ SK_PNMI_STRUCT_DATA *pPnmiStruct = &pAC->PnmiStruct;
+ SK_PNMI_STAT *pPnmiStat = &pPnmiStruct->Stat[0];
+ int unit = !(pAC->dev[0] == dev);
int i;
- DEV_NET *pNet;
- SK_AC *pAC;
- char sens_msg[50];
- unsigned long Flags;
- unsigned int Size;
- struct SK_NET_DEVICE *next;
- struct SK_NET_DEVICE *SkgeProcDev = SkGeRootDev;
-
- SK_PNMI_STRUCT_DATA *pPnmiStruct;
- SK_PNMI_STAT *pPnmiStat;
- struct proc_dir_entry *file = (struct proc_dir_entry*) data;
-
- while (SkgeProcDev) {
- pNet = (DEV_NET*) SkgeProcDev->priv;
- pAC = pNet->pAC;
- next = pAC->Next;
- pPnmiStruct = &pAC->PnmiStruct;
- /* NetIndex in GetStruct is now required, zero is only dummy */
-
- for (t=pAC->GIni.GIMacsFound; t > 0; t--) {
- if ((pAC->GIni.GIMacsFound == 2) && pAC->RlmtNets == 1)
- t--;
-
- spin_lock_irqsave(&pAC->SlowPathLock, Flags);
- Size = SK_PNMI_STRUCT_SIZE;
- SkPnmiGetStruct(pAC, pAC->IoBase,
- pPnmiStruct, &Size, t-1);
- spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
-
- if (strcmp(pAC->dev[t-1]->name, file->name) == 0) {
- pPnmiStat = &pPnmiStruct->Stat[0];
- len = sprintf(buffer,
- "\nDetailed statistic for device %s\n",
- pAC->dev[t-1]->name);
- len += sprintf(buffer + len,
- "=======================================\n");
+ char sens_msg[50];
+
+ seq_printf(seq,
+ "\nDetailed statistic for device %s\n",
+ dev->name);
+ seq_printf(seq,
+ "=======================================\n");
- /* Board statistics */
- len += sprintf(buffer + len,
- "\nBoard statistics\n\n");
- len += sprintf(buffer + len,
- "Active Port %c\n",
- 'A' + pAC->Rlmt.Net[t-1].Port[pAC->Rlmt.
- Net[t-1].PrefPort]->PortNumber);
- len += sprintf(buffer + len,
- "Preferred Port %c\n",
- 'A' + pAC->Rlmt.Net[t-1].Port[pAC->Rlmt.
- Net[t-1].PrefPort]->PortNumber);
-
- len += sprintf(buffer + len,
- "Bus speed (MHz) %d\n",
- pPnmiStruct->BusSpeed);
-
- len += sprintf(buffer + len,
- "Bus width (Bit) %d\n",
- pPnmiStruct->BusWidth);
- len += sprintf(buffer + len,
- "Hardware revision v%d.%d\n",
- (pAC->GIni.GIPciHwRev >> 4) & 0x0F,
- pAC->GIni.GIPciHwRev & 0x0F);
-
- /* Print sensor informations */
- for (i=0; i < pAC->I2c.MaxSens; i ++) {
- /* Check type */
- switch (pAC->I2c.SenTable[i].SenType) {
- case 1:
- strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
- strcat(sens_msg, " (C)");
- len += sprintf(buffer + len,
- "%-25s %d.%02d\n",
- sens_msg,
- pAC->I2c.SenTable[i].SenValue / 10,
- pAC->I2c.SenTable[i].SenValue % 10);
-
- strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
- strcat(sens_msg, " (F)");
- len += sprintf(buffer + len,
- "%-25s %d.%02d\n",
- sens_msg,
- ((((pAC->I2c.SenTable[i].SenValue)
- *10)*9)/5 + 3200)/100,
- ((((pAC->I2c.SenTable[i].SenValue)
- *10)*9)/5 + 3200) % 10);
- break;
- case 2:
- strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
- strcat(sens_msg, " (V)");
- len += sprintf(buffer + len,
- "%-25s %d.%03d\n",
- sens_msg,
- pAC->I2c.SenTable[i].SenValue / 1000,
- pAC->I2c.SenTable[i].SenValue % 1000);
- break;
- case 3:
- strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
- strcat(sens_msg, " (rpm)");
- len += sprintf(buffer + len,
- "%-25s %d\n",
- sens_msg,
- pAC->I2c.SenTable[i].SenValue);
- break;
- default:
- break;
- }
- }
+ /* Board statistics */
+ seq_printf(seq,
+ "\nBoard statistics\n\n");
+ seq_printf(seq,
+ "Active Port %c\n",
+ 'A' + pAC->Rlmt.Net[unit].Port[pAC->Rlmt.
+ Net[unit].PrefPort]->PortNumber);
+ seq_printf(seq,
+ "Preferred Port %c\n",
+ 'A' + pAC->Rlmt.Net[unit].Port[pAC->Rlmt.
+ Net[unit].PrefPort]->PortNumber);
+
+ seq_printf(seq,
+ "Bus speed (MHz) %d\n",
+ pPnmiStruct->BusSpeed);
+
+ seq_printf(seq,
+ "Bus width (Bit) %d\n",
+ pPnmiStruct->BusWidth);
+ seq_printf(seq,
+ "Hardware revision v%d.%d\n",
+ (pAC->GIni.GIPciHwRev >> 4) & 0x0F,
+ pAC->GIni.GIPciHwRev & 0x0F);
+
+ /* Print sensor informations */
+ for (i=0; i < pAC->I2c.MaxSens; i ++) {
+ /* Check type */
+ switch (pAC->I2c.SenTable[i].SenType) {
+ case 1:
+ strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
+ strcat(sens_msg, " (C)");
+ seq_printf(seq,
+ "%-25s %d.%02d\n",
+ sens_msg,
+ pAC->I2c.SenTable[i].SenValue / 10,
+ pAC->I2c.SenTable[i].SenValue % 10);
+
+ strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
+ strcat(sens_msg, " (F)");
+ seq_printf(seq,
+ "%-25s %d.%02d\n",
+ sens_msg,
+ ((((pAC->I2c.SenTable[i].SenValue)
+ *10)*9)/5 + 3200)/100,
+ ((((pAC->I2c.SenTable[i].SenValue)
+ *10)*9)/5 + 3200) % 10);
+ break;
+ case 2:
+ strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
+ strcat(sens_msg, " (V)");
+ seq_printf(seq,
+ "%-25s %d.%03d\n",
+ sens_msg,
+ pAC->I2c.SenTable[i].SenValue / 1000,
+ pAC->I2c.SenTable[i].SenValue % 1000);
+ break;
+ case 3:
+ strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
+ strcat(sens_msg, " (rpm)");
+ seq_printf(seq,
+ "%-25s %d\n",
+ sens_msg,
+ pAC->I2c.SenTable[i].SenValue);
+ break;
+ default:
+ break;
+ }
+ }
- /*Receive statistics */
- len += sprintf(buffer + len,
- "\nReceive statistics\n\n");
-
- len += sprintf(buffer + len,
- "Received bytes %Ld\n",
- (unsigned long long) pPnmiStat->StatRxOctetsOkCts);
- len += sprintf(buffer + len,
- "Received packets %Ld\n",
- (unsigned long long) pPnmiStat->StatRxOkCts);
+ /*Receive statistics */
+ seq_printf(seq,
+ "\nReceive statistics\n\n");
+
+ seq_printf(seq,
+ "Received bytes %Ld\n",
+ (unsigned long long) pPnmiStat->StatRxOctetsOkCts);
+ seq_printf(seq,
+ "Received packets %Ld\n",
+ (unsigned long long) pPnmiStat->StatRxOkCts);
#if 0
- if (pAC->GIni.GP[0].PhyType == SK_PHY_XMAC &&
- pAC->HWRevision < 12) {
- pPnmiStruct->InErrorsCts = pPnmiStruct->InErrorsCts -
- pPnmiStat->StatRxShortsCts;
- pPnmiStat->StatRxShortsCts = 0;
- }
+ if (pAC->GIni.GP[0].PhyType == SK_PHY_XMAC &&
+ pAC->HWRevision < 12) {
+ pPnmiStruct->InErrorsCts = pPnmiStruct->InErrorsCts -
+ pPnmiStat->StatRxShortsCts;
+ pPnmiStat->StatRxShortsCts = 0;
+ }
#endif
- if (pNet->Mtu > 1500)
- pPnmiStruct->InErrorsCts = pPnmiStruct->InErrorsCts -
- pPnmiStat->StatRxTooLongCts;
-
- len += sprintf(buffer + len,
- "Receive errors %Ld\n",
- (unsigned long long) pPnmiStruct->InErrorsCts);
- len += sprintf(buffer + len,
- "Receive dropped %Ld\n",
- (unsigned long long) pPnmiStruct->RxNoBufCts);
- len += sprintf(buffer + len,
- "Received multicast %Ld\n",
- (unsigned long long) pPnmiStat->StatRxMulticastOkCts);
- len += sprintf(buffer + len,
- "Receive error types\n");
- len += sprintf(buffer + len,
- " length %Ld\n",
- (unsigned long long) pPnmiStat->StatRxRuntCts);
- len += sprintf(buffer + len,
- " buffer overflow %Ld\n",
- (unsigned long long) pPnmiStat->StatRxFifoOverflowCts);
- len += sprintf(buffer + len,
- " bad crc %Ld\n",
- (unsigned long long) pPnmiStat->StatRxFcsCts);
- len += sprintf(buffer + len,
- " framing %Ld\n",
- (unsigned long long) pPnmiStat->StatRxFramingCts);
- len += sprintf(buffer + len,
- " missed frames %Ld\n",
- (unsigned long long) pPnmiStat->StatRxMissedCts);
-
- if (pNet->Mtu > 1500)
- pPnmiStat->StatRxTooLongCts = 0;
-
- len += sprintf(buffer + len,
- " too long %Ld\n",
- (unsigned long long) pPnmiStat->StatRxTooLongCts);
- len += sprintf(buffer + len,
- " carrier extension %Ld\n",
- (unsigned long long) pPnmiStat->StatRxCextCts);
- len += sprintf(buffer + len,
- " too short %Ld\n",
- (unsigned long long) pPnmiStat->StatRxShortsCts);
- len += sprintf(buffer + len,
- " symbol %Ld\n",
- (unsigned long long) pPnmiStat->StatRxSymbolCts);
- len += sprintf(buffer + len,
- " LLC MAC size %Ld\n",
- (unsigned long long) pPnmiStat->StatRxIRLengthCts);
- len += sprintf(buffer + len,
- " carrier event %Ld\n",
- (unsigned long long) pPnmiStat->StatRxCarrierCts);
- len += sprintf(buffer + len,
- " jabber %Ld\n",
- (unsigned long long) pPnmiStat->StatRxJabberCts);
-
-
- /*Transmit statistics */
- len += sprintf(buffer + len,
- "\nTransmit statistics\n\n");
+ if (pNet->Mtu > 1500)
+ pPnmiStruct->InErrorsCts = pPnmiStruct->InErrorsCts -
+ pPnmiStat->StatRxTooLongCts;
+
+ seq_printf(seq,
+ "Receive errors %Ld\n",
+ (unsigned long long) pPnmiStruct->InErrorsCts);
+ seq_printf(seq,
+ "Receive dropped %Ld\n",
+ (unsigned long long) pPnmiStruct->RxNoBufCts);
+ seq_printf(seq,
+ "Received multicast %Ld\n",
+ (unsigned long long) pPnmiStat->StatRxMulticastOkCts);
+ seq_printf(seq,
+ "Receive error types\n");
+ seq_printf(seq,
+ " length %Ld\n",
+ (unsigned long long) pPnmiStat->StatRxRuntCts);
+ seq_printf(seq,
+ " buffer overflow %Ld\n",
+ (unsigned long long) pPnmiStat->StatRxFifoOverflowCts);
+ seq_printf(seq,
+ " bad crc %Ld\n",
+ (unsigned long long) pPnmiStat->StatRxFcsCts);
+ seq_printf(seq,
+ " framing %Ld\n",
+ (unsigned long long) pPnmiStat->StatRxFramingCts);
+ seq_printf(seq,
+ " missed frames %Ld\n",
+ (unsigned long long) pPnmiStat->StatRxMissedCts);
+
+ if (pNet->Mtu > 1500)
+ pPnmiStat->StatRxTooLongCts = 0;
+
+ seq_printf(seq,
+ " too long %Ld\n",
+ (unsigned long long) pPnmiStat->StatRxTooLongCts);
+ seq_printf(seq,
+ " carrier extension %Ld\n",
+ (unsigned long long) pPnmiStat->StatRxCextCts);
+ seq_printf(seq,
+ " too short %Ld\n",
+ (unsigned long long) pPnmiStat->StatRxShortsCts);
+ seq_printf(seq,
+ " symbol %Ld\n",
+ (unsigned long long) pPnmiStat->StatRxSymbolCts);
+ seq_printf(seq,
+ " LLC MAC size %Ld\n",
+ (unsigned long long) pPnmiStat->StatRxIRLengthCts);
+ seq_printf(seq,
+ " carrier event %Ld\n",
+ (unsigned long long) pPnmiStat->StatRxCarrierCts);
+ seq_printf(seq,
+ " jabber %Ld\n",
+ (unsigned long long) pPnmiStat->StatRxJabberCts);
+
+
+ /*Transmit statistics */
+ seq_printf(seq,
+ "\nTransmit statistics\n\n");
- len += sprintf(buffer + len,
- "Transmited bytes %Ld\n",
- (unsigned long long) pPnmiStat->StatTxOctetsOkCts);
- len += sprintf(buffer + len,
- "Transmited packets %Ld\n",
- (unsigned long long) pPnmiStat->StatTxOkCts);
- len += sprintf(buffer + len,
- "Transmit errors %Ld\n",
- (unsigned long long) pPnmiStat->StatTxSingleCollisionCts);
- len += sprintf(buffer + len,
- "Transmit dropped %Ld\n",
- (unsigned long long) pPnmiStruct->TxNoBufCts);
- len += sprintf(buffer + len,
- "Transmit collisions %Ld\n",
- (unsigned long long) pPnmiStat->StatTxSingleCollisionCts);
- len += sprintf(buffer + len,
- "Transmit error types\n");
- len += sprintf(buffer + len,
- " excessive collision %ld\n",
- pAC->stats.tx_aborted_errors);
- len += sprintf(buffer + len,
- " carrier %Ld\n",
- (unsigned long long) pPnmiStat->StatTxCarrierCts);
- len += sprintf(buffer + len,
- " fifo underrun %Ld\n",
- (unsigned long long) pPnmiStat->StatTxFifoUnderrunCts);
- len += sprintf(buffer + len,
- " heartbeat %Ld\n",
- (unsigned long long) pPnmiStat->StatTxCarrierCts);
- len += sprintf(buffer + len,
- " window %ld\n",
- pAC->stats.tx_window_errors);
+ seq_printf(seq,
+ "Transmited bytes %Ld\n",
+ (unsigned long long) pPnmiStat->StatTxOctetsOkCts);
+ seq_printf(seq,
+ "Transmited packets %Ld\n",
+ (unsigned long long) pPnmiStat->StatTxOkCts);
+ seq_printf(seq,
+ "Transmit errors %Ld\n",
+ (unsigned long long) pPnmiStat->StatTxSingleCollisionCts);
+ seq_printf(seq,
+ "Transmit dropped %Ld\n",
+ (unsigned long long) pPnmiStruct->TxNoBufCts);
+ seq_printf(seq,
+ "Transmit collisions %Ld\n",
+ (unsigned long long) pPnmiStat->StatTxSingleCollisionCts);
+ seq_printf(seq,
+ "Transmit error types\n");
+ seq_printf(seq,
+ " excessive collision %ld\n",
+ pAC->stats.tx_aborted_errors);
+ seq_printf(seq,
+ " carrier %Ld\n",
+ (unsigned long long) pPnmiStat->StatTxCarrierCts);
+ seq_printf(seq,
+ " fifo underrun %Ld\n",
+ (unsigned long long) pPnmiStat->StatTxFifoUnderrunCts);
+ seq_printf(seq,
+ " heartbeat %Ld\n",
+ (unsigned long long) pPnmiStat->StatTxCarrierCts);
+ seq_printf(seq,
+ " window %ld\n",
+ pAC->stats.tx_window_errors);
- }
- }
- SkgeProcDev = next;
- }
- if (offset >= len) {
- *eof = 1;
- return 0;
- }
-
- *buffer_location = buffer + offset;
- if (buffer_length >= len - offset) {
- *eof = 1;
- }
- return (min_t(int, buffer_length, len - offset));
+ return 0;
}
+static int sk_proc_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, sk_seq_show, PDE(inode)->data);
+}
+
+struct file_operations sk_proc_fops = {
+ .owner = THIS_MODULE,
+ .open = sk_proc_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
+#endif
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] (1/3) sk98lin -- build on smp fix
2003-09-26 18:17 ` [PATCH] (1/3) sk98lin -- build on smp fix Stephen Hemminger
@ 2003-09-27 9:57 ` Jeff Garzik
0 siblings, 0 replies; 6+ messages in thread
From: Jeff Garzik @ 2003-09-27 9:57 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: Mirko Lindner, Ralph Roesler, netdev
all three patches in this series applied
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2003-09-27 9:57 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-09-04 23:06 [RFT] simplify skge /proc interface Stephen Hemminger
2003-09-05 9:27 ` Mirko Lindner
2003-09-26 18:17 ` [PATCH] (1/3) sk98lin -- build on smp fix Stephen Hemminger
2003-09-27 9:57 ` Jeff Garzik
2003-09-26 18:17 ` [PATCH] (2/3) skge -- handle proc_fs errors Stephen Hemminger
2003-09-26 18:17 ` [PATCH] (3/3) sk98lin -- use seq_file for /proc Stephen Hemminger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).