⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 defxx.c

📁 Linux内核源代码 为压缩文件 是<<Linux内核>>一书中的源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
			bp->link_available = PI_K_TRUE;		/* set link available flag */			}		}	return;	}/* * ================== * = dfx_int_common = * ================== *    * Overview: *   Interrupt service routine (ISR) *   * Returns: *   None *        * Arguments: *   bp - pointer to board information * * Functional Description: *   This is the ISR which processes incoming adapter interrupts. * * Return Codes: *   None * * Assumptions: *   This routine assumes PDQ interrupts have not been disabled. *   When interrupts are disabled at the PDQ, the Port Status register *   is automatically cleared.  This routine uses the Port Status *   register value to determine whether a Type 0 interrupt occurred, *   so it's important that adapter interrupts are not normally *   enabled/disabled at the PDQ. * *   It's vital that this routine is NOT reentered for the *   same board and that the OS is not in another section of *   code (eg. dfx_xmt_queue_pkt) for the same board on a *   different thread. * * Side Effects: *   Pending interrupts are serviced.  Depending on the type of *   interrupt, acknowledging and clearing the interrupt at the *   PDQ involves writing a register to clear the interrupt bit *   or updating completion indices. */static void dfx_int_common(struct net_device *dev){	DFX_board_t 	*bp = (DFX_board_t *) dev->priv;	PI_UINT32	port_status;		/* Port Status register */	/* Process xmt interrupts - frequent case, so always call this routine */	if(dfx_xmt_done(bp))				/* free consumed xmt packets */		netif_wake_queue(dev);	/* Process rcv interrupts - frequent case, so always call this routine */	dfx_rcv_queue_process(bp);		/* service received LLC frames */	/*	 * Transmit and receive producer and completion indices are updated on the	 * adapter by writing to the Type 2 Producer register.  Since the frequent	 * case is that we'll be processing either LLC transmit or receive buffers,	 * we'll optimize I/O writes by doing a single register write here.	 */	dfx_port_write_long(bp, PI_PDQ_K_REG_TYPE_2_PROD, bp->rcv_xmt_reg.lword);	/* Read PDQ Port Status register to find out which interrupts need processing */	dfx_port_read_long(bp, PI_PDQ_K_REG_PORT_STATUS, &port_status);	/* Process Type 0 interrupts (if any) - infrequent, so only call when needed */	if (port_status & PI_PSTATUS_M_TYPE_0_PENDING)		dfx_int_type_0_process(bp);	/* process Type 0 interrupts */	return;	}/* * ================= * = dfx_interrupt = * ================= *    * Overview: *   Interrupt processing routine *   * Returns: *   None *        * Arguments: *   irq	- interrupt vector *   dev_id	- pointer to device information *	 regs	- pointer to registers structure * * Functional Description: *   This routine calls the interrupt processing routine for this adapter.  It *   disables and reenables adapter interrupts, as appropriate.  We can support *   shared interrupts since the incoming dev_id pointer provides our device *   structure context. * * Return Codes: *   None * * Assumptions: *   The interrupt acknowledgement at the hardware level (eg. ACKing the PIC *   on Intel-based systems) is done by the operating system outside this *   routine. * *	 System interrupts are enabled through this call. * * Side Effects: *   Interrupts are disabled, then reenabled at the adapter. */static void dfx_interrupt(int irq, void *dev_id, struct pt_regs	*regs)	{	struct net_device	*dev = (struct net_device *) dev_id;	DFX_board_t		*bp;	/* private board structure pointer */	u8				tmp;	/* used for disabling/enabling ints */	/* Get board pointer only if device structure is valid */	bp = (DFX_board_t *) dev->priv;	spin_lock(&bp->lock);		/* See if we're already servicing an interrupt */	/* Service adapter interrupts */	if (bp->bus_type == DFX_BUS_TYPE_PCI)		{		/* Disable PDQ-PFI interrupts at PFI */		dfx_port_write_long(bp, PFI_K_REG_MODE_CTRL, PFI_MODE_M_DMA_ENB);		/* Call interrupt service routine for this adapter */		dfx_int_common(dev);		/* Clear PDQ interrupt status bit and reenable interrupts */		dfx_port_write_long(bp, PFI_K_REG_STATUS, PFI_STATUS_M_PDQ_INT);		dfx_port_write_long(bp, PFI_K_REG_MODE_CTRL,					(PFI_MODE_M_PDQ_INT_ENB + PFI_MODE_M_DMA_ENB));		}	else		{		/* Disable interrupts at the ESIC */		dfx_port_read_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, &tmp);		tmp &= ~PI_CONFIG_STAT_0_M_INT_ENB;		dfx_port_write_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, tmp);		/* Call interrupt service routine for this adapter */		dfx_int_common(dev);		/* Reenable interrupts at the ESIC */		dfx_port_read_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, &tmp);		tmp |= PI_CONFIG_STAT_0_M_INT_ENB;		dfx_port_write_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, tmp);		}	spin_unlock(&bp->lock);	return;	}/* * ===================== * = dfx_ctl_get_stats = * ===================== *    * Overview: *   Get statistics for FDDI adapter *   * Returns: *   Pointer to FDDI statistics structure *        * Arguments: *   dev - pointer to device information * * Functional Description: *   Gets current MIB objects from adapter, then *   returns FDDI statistics structure as defined *   in if_fddi.h. * *   Note: Since the FDDI statistics structure is *   still new and the device structure doesn't *   have an FDDI-specific get statistics handler, *   we'll return the FDDI statistics structure as *   a pointer to an Ethernet statistics structure. *   That way, at least the first part of the statistics *   structure can be decoded properly, and it allows *   "smart" applications to perform a second cast to *   decode the FDDI-specific statistics. * *   We'll have to pay attention to this routine as the *   device structure becomes more mature and LAN media *   independent. * * Return Codes: *   None * * Assumptions: *   None * * Side Effects: *   None */static struct net_device_stats *dfx_ctl_get_stats(struct net_device *dev)	{	DFX_board_t	*bp = (DFX_board_t *)dev->priv;	/* Fill the bp->stats structure with driver-maintained counters */	bp->stats.rx_packets			= bp->rcv_total_frames;	bp->stats.tx_packets			= bp->xmt_total_frames;	bp->stats.rx_bytes			= bp->rcv_total_bytes;	bp->stats.tx_bytes			= bp->xmt_total_bytes;	bp->stats.rx_errors				= (u32)(bp->rcv_crc_errors + bp->rcv_frame_status_errors + bp->rcv_length_errors);	bp->stats.tx_errors				= bp->xmt_length_errors;	bp->stats.rx_dropped			= bp->rcv_discards;	bp->stats.tx_dropped			= bp->xmt_discards;	bp->stats.multicast				= bp->rcv_multicast_frames;	bp->stats.transmit_collision	= 0;	/* always zero (0) for FDDI */	/* Get FDDI SMT MIB objects */	bp->cmd_req_virt->cmd_type = PI_CMD_K_SMT_MIB_GET;	if (dfx_hw_dma_cmd_req(bp) != DFX_K_SUCCESS)		return((struct net_device_stats *) &bp->stats);	/* Fill the bp->stats structure with the SMT MIB object values */	memcpy(bp->stats.smt_station_id, &bp->cmd_rsp_virt->smt_mib_get.smt_station_id, sizeof(bp->cmd_rsp_virt->smt_mib_get.smt_station_id));	bp->stats.smt_op_version_id					= bp->cmd_rsp_virt->smt_mib_get.smt_op_version_id;	bp->stats.smt_hi_version_id					= bp->cmd_rsp_virt->smt_mib_get.smt_hi_version_id;	bp->stats.smt_lo_version_id					= bp->cmd_rsp_virt->smt_mib_get.smt_lo_version_id;	memcpy(bp->stats.smt_user_data, &bp->cmd_rsp_virt->smt_mib_get.smt_user_data, sizeof(bp->cmd_rsp_virt->smt_mib_get.smt_user_data));	bp->stats.smt_mib_version_id				= bp->cmd_rsp_virt->smt_mib_get.smt_mib_version_id;	bp->stats.smt_mac_cts						= bp->cmd_rsp_virt->smt_mib_get.smt_mac_ct;	bp->stats.smt_non_master_cts				= bp->cmd_rsp_virt->smt_mib_get.smt_non_master_ct;	bp->stats.smt_master_cts					= bp->cmd_rsp_virt->smt_mib_get.smt_master_ct;	bp->stats.smt_available_paths				= bp->cmd_rsp_virt->smt_mib_get.smt_available_paths;	bp->stats.smt_config_capabilities			= bp->cmd_rsp_virt->smt_mib_get.smt_config_capabilities;	bp->stats.smt_config_policy					= bp->cmd_rsp_virt->smt_mib_get.smt_config_policy;	bp->stats.smt_connection_policy				= bp->cmd_rsp_virt->smt_mib_get.smt_connection_policy;	bp->stats.smt_t_notify						= bp->cmd_rsp_virt->smt_mib_get.smt_t_notify;	bp->stats.smt_stat_rpt_policy				= bp->cmd_rsp_virt->smt_mib_get.smt_stat_rpt_policy;	bp->stats.smt_trace_max_expiration			= bp->cmd_rsp_virt->smt_mib_get.smt_trace_max_expiration;	bp->stats.smt_bypass_present				= bp->cmd_rsp_virt->smt_mib_get.smt_bypass_present;	bp->stats.smt_ecm_state						= bp->cmd_rsp_virt->smt_mib_get.smt_ecm_state;	bp->stats.smt_cf_state						= bp->cmd_rsp_virt->smt_mib_get.smt_cf_state;	bp->stats.smt_remote_disconnect_flag		= bp->cmd_rsp_virt->smt_mib_get.smt_remote_disconnect_flag;	bp->stats.smt_station_status				= bp->cmd_rsp_virt->smt_mib_get.smt_station_status;	bp->stats.smt_peer_wrap_flag				= bp->cmd_rsp_virt->smt_mib_get.smt_peer_wrap_flag;	bp->stats.smt_time_stamp					= bp->cmd_rsp_virt->smt_mib_get.smt_msg_time_stamp.ls;	bp->stats.smt_transition_time_stamp			= bp->cmd_rsp_virt->smt_mib_get.smt_transition_time_stamp.ls;	bp->stats.mac_frame_status_functions		= bp->cmd_rsp_virt->smt_mib_get.mac_frame_status_functions;	bp->stats.mac_t_max_capability				= bp->cmd_rsp_virt->smt_mib_get.mac_t_max_capability;	bp->stats.mac_tvx_capability				= bp->cmd_rsp_virt->smt_mib_get.mac_tvx_capability;	bp->stats.mac_available_paths				= bp->cmd_rsp_virt->smt_mib_get.mac_available_paths;	bp->stats.mac_current_path					= bp->cmd_rsp_virt->smt_mib_get.mac_current_path;	memcpy(bp->stats.mac_upstream_nbr, &bp->cmd_rsp_virt->smt_mib_get.mac_upstream_nbr, FDDI_K_ALEN);	memcpy(bp->stats.mac_downstream_nbr, &bp->cmd_rsp_virt->smt_mib_get.mac_downstream_nbr, FDDI_K_ALEN);	memcpy(bp->stats.mac_old_upstream_nbr, &bp->cmd_rsp_virt->smt_mib_get.mac_old_upstream_nbr, FDDI_K_ALEN);	memcpy(bp->stats.mac_old_downstream_nbr, &bp->cmd_rsp_virt->smt_mib_get.mac_old_downstream_nbr, FDDI_K_ALEN);	bp->stats.mac_dup_address_test				= bp->cmd_rsp_virt->smt_mib_get.mac_dup_address_test;	bp->stats.mac_requested_paths				= bp->cmd_rsp_virt->smt_mib_get.mac_requested_paths;	bp->stats.mac_downstream_port_type			= bp->cmd_rsp_virt->smt_mib_get.mac_downstream_port_type;	memcpy(bp->stats.mac_smt_address, &bp->cmd_rsp_virt->smt_mib_get.mac_smt_address, FDDI_K_ALEN);	bp->stats.mac_t_req							= bp->cmd_rsp_virt->smt_mib_get.mac_t_req;	bp->stats.mac_t_neg							= bp->cmd_rsp_virt->smt_mib_get.mac_t_neg;	bp->stats.mac_t_max							= bp->cmd_rsp_virt->smt_mib_get.mac_t_max;	bp->stats.mac_tvx_value						= bp->cmd_rsp_virt->smt_mib_get.mac_tvx_value;	bp->stats.mac_frame_error_threshold			= bp->cmd_rsp_virt->smt_mib_get.mac_frame_error_threshold;	bp->stats.mac_frame_error_ratio				= bp->cmd_rsp_virt->smt_mib_get.mac_frame_error_ratio;	bp->stats.mac_rmt_state						= bp->cmd_rsp_virt->smt_mib_get.mac_rmt_state;	bp->stats.mac_da_flag						= bp->cmd_rsp_virt->smt_mib_get.mac_da_flag;	bp->stats.mac_una_da_flag					= bp->cmd_rsp_virt->smt_mib_get.mac_unda_flag;	bp->stats.mac_frame_error_flag				= bp->cmd_rsp_virt->smt_mib_get.mac_frame_error_flag;	bp->stats.mac_ma_unitdata_available			= bp->cmd_rsp_virt->smt_mib_get.mac_ma_unitdata_available;	bp->stats.mac_hardware_present				= bp->cmd_rsp_virt->smt_mib_get.mac_hardware_present;	bp->stats.mac_ma_unitdata_enable			= bp->cmd_rsp_virt->smt_mib_get.mac_ma_unitdata_enable;	bp->stats.path_tvx_lower_bound				= bp->cmd_rsp_virt->smt_mib_get.path_tvx_lower_bound;	bp->stats.path_t_max_lower_bound			= bp->cmd_rsp_virt->smt_mib_get.path_t_max_lower_bound;	bp->stats.path_max_t_req					= bp->cmd_rsp_virt->smt_mib_get.path_max_t_req;	memcpy(bp->stats.path_configuration, &bp->cmd_rsp_virt->smt_mib_get.path_configuration, sizeof(bp->cmd_rsp_virt->smt_mib_get.path_configuration));	bp->stats.port_my_type[0]					= bp->cmd_rsp_virt->smt_mib_get.port_my_type[0];	bp->stats.port_my_type[1]					= bp->cmd_rsp_virt->smt_mib_get.port_my_type[1];	bp->stats.port_neighbor_type[0]				= bp->cmd_rsp_virt->smt_mib_get.port_neighbor_type[0];	bp->stats.port_neighbor_type[1]				= bp->cmd_rsp_virt->smt_mib_get.port_neighbor_type[1];	bp->stats.port_connection_policies[0]		= bp->cmd_rsp_virt->smt_mib_get.port_connection_policies[0];	bp->stats.port_connection_policies[1]		= bp->cmd_rsp_virt->smt_mib_get.port_connection_policies[1];	bp->stats.port_mac_indicated[0]				= bp->cmd_rsp_virt->smt_mib_get.port_mac_indicated[0];	bp->stats.port_mac_indicated[1]				= bp->cmd_rsp_virt->smt_mib_get.port_mac_indicated[1];	bp->stats.port_current_path[0]				= bp->cmd_rsp_virt->smt_mib_get.port_current_path[0];	bp->stats.port_current_path[1]				= bp->cmd_rsp_virt->smt_mib_get.port_current_path[1];	memcpy(&bp->stats.port_requested_paths[0*3], &bp->cmd_rsp_virt->smt_mib_get.port_requested_paths[0], 3);	memcpy(&bp->stats.port_requested_paths[1*3], &bp->cmd_rsp_virt->smt_mib_get.port_requested_paths[1], 3);	bp->stats.port_mac_placement[0]				= bp->cmd_rsp_virt->smt_mib_get.port_mac_placement[0];	bp->stats.port_mac_placement[1]				= bp->cmd_rsp_virt->smt_mib_get.port_mac_placement[1];	bp->stats.port_available_paths[0]			= bp->cmd_rsp_virt->smt_mib_get.port_available_paths[0];	bp->stats.port_available_paths[1]			= bp->cmd_rsp_virt->smt_mib_get.port_available_paths[1];	bp->stats.port_pmd_class[0]					= bp->cmd_rsp_virt->smt_mib_get.port_pmd_class[0];	bp->stats.port_pmd_class[1]					= bp->cmd_rsp_virt->smt_mib_get.port_pmd_class[1];	bp->stats.port_connection_capabilities[0]	= bp->cmd_rsp_virt->smt_mib_get.port_connection_capabilities[0];	bp->stats.port_connection_capabilities[1]	= bp->cmd_rsp_virt->smt_mib_get.port_connection_capabilities[1];	bp->stats.port_bs_flag[0]					= bp->cmd_rsp_virt->smt_mib_get.port_bs_flag[0];	bp->stats.port_bs_flag[1]					= bp->cmd_rsp_virt->smt_mib_get.port_bs_flag[1];	bp->stats.port_ler_estimate[0]				= bp->cmd_rsp_virt->smt_mib_get.port_ler_estimate[0];	bp->stats.port_ler_estimate[1]				= bp->cmd_rsp_virt->smt_mib_get.port_ler_estimate[1];	bp->stats.port_ler_cutoff[0]				= bp->cmd_rsp_virt->smt_mib_get.port_ler_cutoff[0];	bp->stats.port_ler_cutoff[1]				= bp->cmd_rsp_virt->smt_mib_get.port_ler_cutoff[1];	bp->stats.port_ler_alarm[0]					= bp->cmd_rsp_virt->smt_mib_get.port_ler_alarm[0];	bp->stats.port_ler_alarm[1]					= bp->cmd_rsp_virt->smt_mib_get.port_ler_alarm[1];	bp->stats.port_connect_state[0]				= bp->cmd_rsp_virt->smt_mib_get.port_connect_state[0];	bp->stats.port_connect_state[1]				= bp->cmd_rsp_virt->smt_mib_get.port_connect_state[1];	bp->stats.port_pcm_state[0]					= bp->cmd_rsp_virt->smt_mib_get.port_pcm_state[0];	bp->stats.port_pcm_state[1]					= bp->cmd_rsp_virt->smt_mib_get.port_pcm_state[1];	bp->stats.port_pc_withhold[0]				= bp->cmd_rsp_virt->smt_mib_get.port_pc_withhold[0];	bp->stats.port_pc_withhold[1]				= bp->cmd_rsp_virt->smt_mib_get.port_pc_withhold[1];	bp->stats.port_ler_flag[0]					= bp->cmd_rsp_virt->smt_mib_get.port_ler_flag[0];	bp->stats.port_ler_flag[1]					= bp->cmd_rsp_virt->smt_mib_get.port_ler_flag[1];	bp->stats.port_hardware_present[0]			= bp->cmd_rsp_virt->smt_mib_get.port_hardware_present[0];	bp->stats.port_hardware_present[1]			= bp->cmd_rsp_virt->smt_mib_get.port_hardware_present[1];	/* Get FDDI counters */	bp->cmd_req_virt->cmd_type = PI_CMD_K_CNTRS_GET;	if (dfx_hw_dma_cmd_req(bp) != DFX_K_SUCCESS)		return((struct net_device_stats *) &bp->stats);	/* Fill the bp->stats structure with the FDDI counter values */	bp->stats.mac_frame_cts				= bp->cmd_rsp_virt->cntrs_get.cntrs.frame_cnt.ls;	bp->stats.mac_copied_cts			= bp->cmd_rsp_virt->cntrs_get.cntrs.copied_cnt.ls;	bp->stats.mac_transmit_cts			= bp->cmd_rsp_virt->cntrs_get.cntrs.transmit_cnt.ls;	bp->stats.mac_error_cts				= bp->cmd_rsp_virt->cntrs_get.cntrs.error_cnt.ls;	bp->stats.mac_lost_cts				= bp->cmd_rsp_virt->cntrs_get.cntrs.lost_cnt.ls;	bp->stats.port_lct_fail_cts[0]		= bp->cmd_rsp_virt->cntrs_get.cntrs.lct_rejects[0].ls;	bp->stats.port_lct_fail_cts[1]		= bp->cmd_rsp_virt->cntrs_get.cntrs.lct_rejects[1].ls;	bp->stats.port_lem_reject_cts[0]	= bp->cmd_rsp_virt->cntrs_get.cntrs.lem_rejects[0].ls;	bp->stats.port_lem_reject_cts[1]	= bp->cmd_rsp_virt->cntrs_get.cntrs.lem_rejects[1].ls;	bp->stats.port_lem_cts[0]			= bp->cmd_rsp_virt->cntrs_get.cntrs.link_errors[0].ls;	bp->stats.port_lem_cts[1]			= bp->cmd_rsp_virt->cntrs_get.cntrs.link_errors[1].ls;	return((struct net_device_stats *) &bp->stats);	}/* * ============================== * = dfx_ctl_set_multicast_list = * ============================== *    * Overview: *   Enable/Disable LLC frame promiscuous mode reception *   on the adapter and/or update multicast address table. *   * Returns: *   None *        * Arguments: *   dev - pointer to device information * * Functional Description: *   This routine follows a fairly simple algorithm for setting the *   adapter filters and CAM: * *		if IFF_PROMISC flag is set *			enable LLC individual/group promiscuous mode *		else *			disable LLC individual/group promiscuous mode *			if number of incoming multicast addresses > *					(CAM max size - number of unicast addresses in CAM) *				enable LLC group promiscuous mode *				set driver-maintained multicast address count to zero *

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -