Ejemplo n.º 1
0
/*****************************************************************************
 *
 * 	SkGeGetEthStats - retrieves the card statistics
 *
 * Description:
 *	All current statistics of a selected adapter are placed 
 *	in the passed ethtool_stats structure and are returned.
 *
 * Returns:	N/A
 *
 */
void SkGeGetEthStats(struct net_device *dev,
			struct ethtool_stats *stats,
			u64 *data)
{
	DEV_NET			*pNet        = PPRIV;
	SK_AC			*pAC         = pNet->pAC;
	SK_U32			Size         = sizeof(SK_PNMI_STRUCT_DATA);
	SK_PNMI_STRUCT_DATA     *pPnmiStruct = &pAC->PnmiStruct;
	int			port         = pNet->PortNr;
	int			i;

	struct sk98lin_stats *sk98lin_etht_stats = 
		(port == 0) ? sk98lin_etht_stats_port0 : sk98lin_etht_stats_port1;

	if (netif_running(pAC->dev[port])) {
		SkPnmiGetStruct(pAC, pAC->IoBase, pPnmiStruct, &Size, port);
	}

	for(i = 0; i < SK98LIN_STATS_LEN; i++) {
		if (netif_running(pAC->dev[port])) {
			data[i] = (sk98lin_etht_stats[i].sizeof_stat ==
				sizeof(uint64_t)) ?
				*(uint64_t *)((char *)pAC +
				sk98lin_etht_stats[i].stat_offset) :
				*(uint32_t *)((char *)pAC +
				sk98lin_etht_stats[i].stat_offset);
		} else {
			data[i] = (sk98lin_etht_stats[i].sizeof_stat ==
				sizeof(uint64_t)) ? (uint64_t) 0 : (uint32_t) 0;
		}
	}
}
Ejemplo n.º 2
0
/*****************************************************************************
 *
 * 	sk_gen_browse -generic  print "summaries" entry 
 *
 * Description:
 *  This function fills the proc entry with statistic data about 
 *  the ethernet device.
 *  
 * Returns: -
 *	
 */
static void sk_gen_browse(void *buffer)
{
	struct SK_NET_DEVICE	*SkgeProcDev = SkGeRootDev;
	struct SK_NET_DEVICE	*next;
	SK_PNMI_STRUCT_DATA 	*pPnmiStruct;
	SK_PNMI_STAT		*pPnmiStat;
	unsigned long		Flags;	
	unsigned int		Size;
	DEV_NET			*pNet;
	SK_AC			*pAC;
	char			sens_msg[50];
	int			MaxSecurityCount = 0;
	int 			t;
	int 			i;

	while (SkgeProcDev) {
		MaxSecurityCount++;
		if (MaxSecurityCount > 100) {
			printk("Max limit for sk_proc_read security counter!\n");
			return;
		}
		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;
#ifdef SK_DIAG_SUPPORT
			if (pAC->BoardLevel == SK_INIT_DATA) {
				SK_MEMCPY(&(pAC->PnmiStruct), &(pAC->PnmiBackup), sizeof(SK_PNMI_STRUCT_DATA));
				if (pAC->DiagModeActive == DIAG_NOTACTIVE) {
					pAC->Pnmi.DiagAttached = SK_DIAG_IDLE;
				}
			} else {
				SkPnmiGetStruct(pAC, pAC->IoBase, pPnmiStruct, &Size, t-1);
			}
#else
			SkPnmiGetStruct(pAC, pAC->IoBase, 
				pPnmiStruct, &Size, t-1);
#endif
			spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
	
			if (strcmp(pAC->dev[t-1]->name, currDev->name) == 0) {
				pPnmiStat = &pPnmiStruct->Stat[0];
				len = sk_proc_print(buffer, 
					"\nDetailed statistic for device %s\n",
					pAC->dev[t-1]->name);
				len += sk_proc_print(buffer,
					"=======================================\n");
	
				/* Board statistics */
				len += sk_proc_print(buffer, 
					"\nBoard statistics\n\n");
				len += sk_proc_print(buffer,
					"Active Port                    %c\n",
					'A' + pAC->Rlmt.Net[t-1].Port[pAC->Rlmt.
					Net[t-1].PrefPort]->PortNumber);
				len += sk_proc_print(buffer,
					"Preferred Port                 %c\n",
					'A' + pAC->Rlmt.Net[t-1].Port[pAC->Rlmt.
					Net[t-1].PrefPort]->PortNumber);

				len += sk_proc_print(buffer,
					"Bus speed (MHz)                %d\n",
					pPnmiStruct->BusSpeed);

				len += sk_proc_print(buffer,
					"Bus width (Bit)                %d\n",
					pPnmiStruct->BusWidth);
				len += sk_proc_print(buffer,
					"Driver version                 %s\n",
					VER_STRING);
				len += sk_proc_print(buffer,
					"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 += sk_proc_print(buffer,
							"%-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 += sk_proc_print(buffer,
							"%-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 += sk_proc_print(buffer,
							"%-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 += sk_proc_print(buffer,
							"%-25s      %d\n",
							sens_msg,
							pAC->I2c.SenTable[i].SenValue);
						break;
					default:
						break;
					}
				}
				
				/*Receive statistics */
				len += sk_proc_print(buffer, 
				"\nReceive statistics\n\n");

				len += sk_proc_print(buffer,
					"Received bytes                 %Lu\n",
					(unsigned long long) pPnmiStat->StatRxOctetsOkCts);
				len += sk_proc_print(buffer,
					"Received packets               %Lu\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;
				}
#endif
				if (pNet->Mtu > 1500) 
					pPnmiStruct->InErrorsCts = pPnmiStruct->InErrorsCts -
						pPnmiStat->StatRxTooLongCts;

				len += sk_proc_print(buffer,
					"Receive errors                 %Lu\n",
					(unsigned long long) pPnmiStruct->InErrorsCts);
				len += sk_proc_print(buffer,
					"Receive dropped                %Lu\n",
					(unsigned long long) pPnmiStruct->RxNoBufCts);
				len += sk_proc_print(buffer,
					"Received multicast             %Lu\n",
					(unsigned long long) pPnmiStat->StatRxMulticastOkCts);
				len += sk_proc_print(buffer,
					"Receive error types\n");
				len += sk_proc_print(buffer,
					"   length                      %Lu\n",
					(unsigned long long) pPnmiStat->StatRxRuntCts);
				len += sk_proc_print(buffer,
					"   buffer overflow             %Lu\n",
					(unsigned long long) pPnmiStat->StatRxFifoOverflowCts);
				len += sk_proc_print(buffer,
					"   bad crc                     %Lu\n",
					(unsigned long long) pPnmiStat->StatRxFcsCts);
				len += sk_proc_print(buffer,
					"   framing                     %Lu\n",
					(unsigned long long) pPnmiStat->StatRxFramingCts);
				len += sk_proc_print(buffer,
					"   missed frames               %Lu\n",
					(unsigned long long) pPnmiStat->StatRxMissedCts);

				if (pNet->Mtu > 1500)
					pPnmiStat->StatRxTooLongCts = 0;

				len += sk_proc_print(buffer,
					"   too long                    %Lu\n",
					(unsigned long long) pPnmiStat->StatRxTooLongCts);					
				len += sk_proc_print(buffer,
					"   carrier extension           %Lu\n",
					(unsigned long long) pPnmiStat->StatRxCextCts);				
				len += sk_proc_print(buffer,
					"   too short                   %Lu\n",
					(unsigned long long) pPnmiStat->StatRxShortsCts);				
				len += sk_proc_print(buffer,
					"   symbol                      %Lu\n",
					(unsigned long long) pPnmiStat->StatRxSymbolCts);				
				len += sk_proc_print(buffer,
					"   LLC MAC size                %Lu\n",
					(unsigned long long) pPnmiStat->StatRxIRLengthCts);				
				len += sk_proc_print(buffer,
					"   carrier event               %Lu\n",
					(unsigned long long) pPnmiStat->StatRxCarrierCts);				
				len += sk_proc_print(buffer,
					"   jabber                      %Lu\n",
					(unsigned long long) pPnmiStat->StatRxJabberCts);				


				/*Transmit statistics */
				len += sk_proc_print(buffer, 
				"\nTransmit statistics\n\n");
				
				len += sk_proc_print(buffer,
					"Transmited bytes               %Lu\n",
					(unsigned long long) pPnmiStat->StatTxOctetsOkCts);
				len += sk_proc_print(buffer,
					"Transmited packets             %Lu\n",
					(unsigned long long) pPnmiStat->StatTxOkCts);
				len += sk_proc_print(buffer,
					"Transmit errors                %Lu\n",
					(unsigned long long) pPnmiStat->StatTxSingleCollisionCts);
				len += sk_proc_print(buffer,
					"Transmit dropped               %Lu\n",
					(unsigned long long) pPnmiStruct->TxNoBufCts);
				len += sk_proc_print(buffer,
					"Transmit collisions            %Lu\n",
					(unsigned long long) pPnmiStat->StatTxSingleCollisionCts);
				len += sk_proc_print(buffer,
					"Transmit error types\n");
				len += sk_proc_print(buffer,
					"   excessive collision         %ld\n",
					pAC->stats.tx_aborted_errors);
				len += sk_proc_print(buffer,
					"   carrier                     %Lu\n",
					(unsigned long long) pPnmiStat->StatTxCarrierCts);
				len += sk_proc_print(buffer,
					"   fifo underrun               %Lu\n",
					(unsigned long long) pPnmiStat->StatTxFifoUnderrunCts);
				len += sk_proc_print(buffer,
					"   heartbeat                   %Lu\n",
					(unsigned long long) pPnmiStat->StatTxCarrierCts);
				len += sk_proc_print(buffer,
					"   window                      %ld\n",
					pAC->stats.tx_window_errors);
				
			} /* if (strcmp(pACname, currDeviceName) == 0) */
		}
		SkgeProcDev = next;
	}
/*****************************************************************************
 *
 * 	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 proc_read(char *buffer,
char **buffer_location,
off_t offset,
int buffer_length,
int *eof,
void *data)
{
	int len = 0;
	int t;
	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");
	
				/* 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;
					}
				}
				
				/*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));
#if 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 drops                  %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 errors 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);
				
			}
		}
		SkgeProcDev = next;
	}