Lines Matching refs:port

480 #define PORT_CTRL_ADDR(port, addr)		\
481 (addr = KS8842_PORT_1_CTRL_1 + (port) * \
686 #define HW_TO_DEV_PORT(port) (port - 1)
1048 * @state: Connection status of the port.
1057 * It is pointless to read MIB counters when the port is disconnected. The
1059 * when the port is connected. The @link_down indicates the port is just
1103 * @member: Current port membership. Used for STP.
1124 * @state: Connection status of the port.
1248 * struct ksz_port - Virtual port data structure
1260 * @first_port: Index of first port this port supports.
1262 * @port_cnt: Number of ports this port supports.
1265 * @linked: Pointer to port information linked to this port.
1382 * @port: Port information.
1395 struct ksz_port port;
1641 * @ports: The port members.
1642 * @override: The flag to override the port receive/transmit settings.
1680 * @member: Buffer to store the port membership.
1706 * @port: The port index.
1710 * This routine reads a MIB counter of the port.
1713 static void port_r_mib_cnt(struct ksz_hw *hw, int port, u16 addr, u64 *cnt)
1720 ctrl_addr = addr + PORT_COUNTER_NUM * port;
1745 * @port: The port index.
1749 * This routine reads the dropped packet counts of the port.
1752 static void port_r_mib_pkt(struct ksz_hw *hw, int port, u32 *last, u64 *cnt)
1760 index = KS_MIB_PACKET_DROPPED_RX_0 + port;
1786 } while (index >= KS_MIB_PACKET_DROPPED_TX_0 + port);
1792 * @port: The port index.
1794 * This routine is used to read the counters of the port periodically to avoid
1800 static int port_r_cnt(struct ksz_hw *hw, int port)
1802 struct ksz_port_mib *mib = &hw->port_mib[port];
1806 port_r_mib_cnt(hw, port, mib->cnt_ptr,
1811 port_r_mib_pkt(hw, port, mib->dropped,
1820 * @port: The port index.
1825 static void port_init_cnt(struct ksz_hw *hw, int port)
1827 struct ksz_port_mib *mib = &hw->port_mib[port];
1832 port_r_mib_cnt(hw, port, mib->cnt_ptr,
1837 port_r_mib_pkt(hw, port, mib->dropped,
1848 * port_cfg - set port register bits
1850 * @port: The port index.
1851 * @offset: The offset of the port register.
1855 * This routine sets or resets the specified bits of the port register.
1857 static void port_cfg(struct ksz_hw *hw, int port, int offset, u16 bits,
1863 PORT_CTRL_ADDR(port, addr);
1874 * port_r8 - read byte from port register
1876 * @port: The port index.
1877 * @offset: The offset of the port register.
1880 * This routine reads a byte from the port register.
1882 static void port_r8(struct ksz_hw *hw, int port, int offset, u8 *data)
1886 PORT_CTRL_ADDR(port, addr);
1892 * port_r16 - read word from port register.
1894 * @port: The port index.
1895 * @offset: The offset of the port register.
1898 * This routine reads a word from the port register.
1900 static void port_r16(struct ksz_hw *hw, int port, int offset, u16 *data)
1904 PORT_CTRL_ADDR(port, addr);
1910 * port_w16 - write word to port register.
1912 * @port: The port index.
1913 * @offset: The offset of the port register.
1916 * This routine writes a word to the port register.
1918 static void port_w16(struct ksz_hw *hw, int port, int offset, u16 data)
1922 PORT_CTRL_ADDR(port, addr);
2025 * @port: The port index.
2029 static void sw_dis_broad_storm(struct ksz_hw *hw, int port)
2031 port_cfg_broad_storm(hw, port, 0);
2037 * @port: The port index.
2041 static void sw_ena_broad_storm(struct ksz_hw *hw, int port)
2044 port_cfg_broad_storm(hw, port, 1);
2055 int port;
2059 for (port = 0; port < TOTAL_PORT_NUM; port++)
2060 sw_dis_broad_storm(hw, port);
2085 * @port: The port index.
2089 static void sw_dis_prio_rate(struct ksz_hw *hw, int port)
2093 PORT_CTRL_ADDR(port, addr);
2106 int port;
2110 for (port = 0; port < TOTAL_PORT_NUM; port++) {
2112 sw->port_cfg[port].rx_rate[prio] =
2113 sw->port_cfg[port].tx_rate[prio] = 0;
2115 sw_dis_prio_rate(hw, port);
2154 int port;
2156 for (port = 0; port < TOTAL_PORT_NUM; port++) {
2157 port_cfg_mirror_sniffer(hw, port, 0);
2158 port_cfg_mirror_rx(hw, port, 0);
2159 port_cfg_mirror_tx(hw, port, 0);
2193 * @port: The port index.
2197 static void sw_dis_diffserv(struct ksz_hw *hw, int port)
2199 port_cfg_diffserv(hw, port, 0);
2205 * @port: The port index.
2209 static void sw_dis_802_1p(struct ksz_hw *hw, int port)
2211 port_cfg_802_1p(hw, port, 0);
2228 * @port: The port index.
2232 * That allows 802.1p priority field to be replaced with the port's default
2234 * priority than port's default tag's priority.
2236 static void sw_cfg_replace_vid(struct ksz_hw *hw, int port, int set)
2238 port_cfg_replace_vid(hw, port, set);
2242 * sw_cfg_port_based - configure switch port based priority
2244 * @port: The port index.
2247 * This routine configures the port based priority of the switch.
2249 static void sw_cfg_port_based(struct ksz_hw *hw, int port, u8 prio)
2256 hw->ksz_switch->port_cfg[port].port_prio = prio;
2258 port_r16(hw, port, KS8842_PORT_CTRL_1_OFFSET, &data);
2261 port_w16(hw, port, KS8842_PORT_CTRL_1_OFFSET, data);
2267 * @port: The port index.
2270 * port. Only single transmit queue on the port.
2272 static void sw_dis_multi_queue(struct ksz_hw *hw, int port)
2274 port_cfg_prio(hw, port, 0);
2285 int port;
2310 for (port = 0; port < TOTAL_PORT_NUM; port++) {
2311 sw_dis_multi_queue(hw, port);
2312 sw_dis_diffserv(hw, port);
2313 sw_dis_802_1p(hw, port);
2314 sw_cfg_replace_vid(hw, port, 0);
2316 sw->port_cfg[port].port_prio = 0;
2317 sw_cfg_port_based(hw, port, sw->port_cfg[port].port_prio);
2323 * port_get_def_vid - get port default VID.
2325 * @port: The port index.
2328 * This routine retrieves the default VID of the port.
2330 static void port_get_def_vid(struct ksz_hw *hw, int port, u16 *vid)
2334 PORT_CTRL_ADDR(port, addr);
2347 int port;
2359 for (port = 0; port < TOTAL_PORT_NUM; port++) {
2360 port_get_def_vid(hw, port, &sw->port_cfg[port].vid);
2361 sw->port_cfg[port].member = PORT_MASK;
2366 * sw_cfg_port_base_vlan - configure port-based VLAN membership
2368 * @port: The port index.
2369 * @member: The port-based VLAN membership.
2371 * This routine configures the port-based VLAN membership of the port.
2373 static void sw_cfg_port_base_vlan(struct ksz_hw *hw, int port, u8 member)
2378 PORT_CTRL_ADDR(port, addr);
2386 hw->ksz_switch->port_cfg[port].member = member;
2453 * port_set_stp_state - configure port spanning tree state
2455 * @port: The port index.
2458 * This routine configures the spanning tree state of the port.
2460 static void port_set_stp_state(struct ksz_hw *hw, int port, int state)
2464 port_r16(hw, port, KS8842_PORT_CTRL_2_OFFSET, &data);
2472 * No need to turn on transmit because of port direct mode.
2501 port_w16(hw, port, KS8842_PORT_CTRL_2_OFFSET, data);
2502 hw->ksz_switch->port_cfg[port].stp_state = state;
2557 * sw_block_addr - block certain packets from the host port
2560 * This routine blocks certain packets from reaching to the host port.
2590 * @port: Port to read.
2596 static void hw_r_phy(struct ksz_hw *hw, int port, u16 reg, u16 *val)
2600 phy = KS884X_PHY_1_CTRL_OFFSET + port * PHY_CTRL_INTERVAL + reg;
2607 * @port: Port to write.
2613 static void hw_w_phy(struct ksz_hw *hw, int port, u16 reg, u16 val)
2617 phy = KS884X_PHY_1_CTRL_OFFSET + port * PHY_CTRL_INTERVAL + reg;
2819 static u16 advertised_flow_ctrl(struct ksz_port *port, u16 ctrl)
2822 switch (port->flow_ctrl) {
2858 static void determine_flow_ctrl(struct ksz_hw *hw, struct ksz_port *port,
2868 if (port->force_link)
2888 static inline void port_cfg_change(struct ksz_hw *hw, struct ksz_port *port,
2905 * @port: The port instance.
2910 static void port_get_link_speed(struct ksz_port *port)
2915 struct ksz_hw *hw = port->hw;
2925 for (i = 0, p = port->first_port; i < port->port_cnt; i++, p++) {
2946 /* Remember the first linked port. */
2963 determine_flow_ctrl(hw, port, data, status);
2968 port_cfg_change(hw, port, info, status);
2981 if (linked && media_disconnected == port->linked->state)
2982 port->linked = linked;
2990 * port_set_link_speed - set port speed
2991 * @port: The port instance.
2995 static void port_set_link_speed(struct ksz_port *port)
2997 struct ksz_hw *hw = port->hw;
3004 for (i = 0, p = port->first_port; i < port->port_cnt; i++, p++) {
3013 data = advertised_flow_ctrl(port, data);
3019 if (port->speed || port->duplex) {
3020 if (10 == port->speed)
3023 else if (100 == port->speed)
3026 if (1 == port->duplex)
3029 else if (2 == port->duplex)
3041 * port_force_link_speed - force port speed
3042 * @port: The port instance.
3046 static void port_force_link_speed(struct ksz_port *port)
3048 struct ksz_hw *hw = port->hw;
3054 for (i = 0, p = port->first_port; i < port->port_cnt; i++, p++) {
3060 if (10 == port->speed)
3062 else if (100 == port->speed)
3064 if (1 == port->duplex)
3066 else if (2 == port->duplex)
3072 static void port_set_power_saving(struct ksz_port *port, int enable)
3074 struct ksz_hw *hw = port->hw;
3078 for (i = 0, p = port->first_port; i < port->port_cnt; i++, p++)
3642 /* KSZ8842 supports port directed transmission. */
3870 int port;
3872 for (port = 0; port < SWITCH_PORT_NUM; port++) {
3874 /* Set port-base vlan membership with host port. */
3875 sw_cfg_port_base_vlan(hw, port,
3876 HOST_MASK | (1 << port));
3877 port_set_stp_state(hw, port, STP_STATE_DISABLED);
3879 sw_cfg_port_base_vlan(hw, port, PORT_MASK);
3880 port_set_stp_state(hw, port, STP_STATE_FORWARDING);
3901 int port;
3908 for (port = 0; port < SWITCH_PORT_NUM; port++)
3909 sw_ena_broad_storm(hw, port);
4238 int port;
4242 for (i = 0, port = first; i < cnt; i++, port++) {
4243 port_mib = &hw->port_mib[port];
4269 * KSZ8842 with multiple device interfaces needs to be told which port
4273 hw->dst_ports = 1 << priv->port.first_port;
4421 int port;
4425 for (port = 0; port < hw->dev_count; port++) {
4426 struct net_device *dev = hw->port_info[port].pdev;
4533 int port;
4567 for (port = 0; port < SWITCH_PORT_NUM; port++) {
4570 port_set_stp_state(hw, port,
4573 port_dev = hw->port_info[port].pdev;
4575 port_set_stp_state(hw, port,
4711 /* Get received port number. */
4756 /* Get received port number. */
4781 priv->port.counter[OID_COUNTER_RCV_ERROR]++;
4896 struct ksz_port *port = &priv->port;
4899 port_get_link_speed(port);
4944 int port;
4953 for (port = 0; port < SWITCH_PORT_NUM; port++) {
4954 if (STP_STATE_FORWARDING == sw->port_cfg[port].stp_state)
4957 member = HOST_MASK | (1 << port);
4958 if (member != sw->port_cfg[port].member)
4959 sw_cfg_port_base_vlan(hw, port, member);
4976 struct ksz_port *port = &priv->port;
4984 /* Need to shut the port manually in multiple device interfaces mode. */
4986 port_set_stp_state(hw, port->first_port, STP_STATE_DISABLED);
4990 pi = 1 << port->first_port;
4997 if (port->first_port > 0)
5000 port_set_power_saving(port, true);
5114 struct ksz_port *port = &priv->port;
5126 memset((void *) port->counter, 0,
5147 port_set_power_saving(port, false);
5149 for (i = 0, p = port->first_port; i < port->port_cnt; i++, p++) {
5158 /* Need to open the port in multiple device interfaces mode. */
5160 port_set_stp_state(hw, port->first_port, STP_STATE_SIMPLE);
5161 if (port->first_port > 0)
5165 port_get_link_speed(port);
5166 if (port->force_link)
5167 port_force_link_speed(port);
5169 port_set_link_speed(port);
5186 priv->media_state = port->linked->state;
5216 struct ksz_port *port = &priv->port;
5222 dev->stats.rx_errors = port->counter[OID_COUNTER_RCV_ERROR];
5223 dev->stats.tx_errors = port->counter[OID_COUNTER_XMIT_ERROR];
5233 for (i = 0, p = port->first_port; i < port->mib_port_cnt; i++, p++) {
5277 if (priv->port.first_port > 0)
5288 if (priv->port.first_port > 0)
5320 int port = priv->port.first_port;
5322 port_set_stp_state(hw, port, STP_STATE_DISABLED);
5323 port = 1 << port;
5324 if (sw->member & port) {
5325 sw->member &= ~port;
5450 struct ksz_port *port = &priv->port;
5468 hw_r_phy(hw, port->linked->port_id, data->reg_num,
5479 hw_w_phy(hw, port->linked->port_id, data->reg_num,
5509 struct ksz_port *port = &priv->port;
5510 struct ksz_hw *hw = port->hw;
5513 hw_r_phy(hw, port->linked->port_id, reg_num << 1, &val_out);
5529 struct ksz_port *port = &priv->port;
5530 struct ksz_hw *hw = port->hw;
5534 for (i = 0, pi = port->first_port; i < port->port_cnt; i++, pi++)
5595 struct ksz_port *port = &priv->port;
5630 port->duplex = 0;
5631 port->speed = 0;
5632 port->force_link = 0;
5634 port->duplex = cmd->base.duplex + 1;
5636 port->speed = speed;
5638 port->force_link = 0;
5640 port->force_link = 1;
5984 struct ksz_port *port = &priv->port;
5989 port->flow_ctrl = PHY_NO_FLOW_CTRL;
5991 port->flow_ctrl = PHY_FLOW_CTRL;
5993 port->force_link = 0;
6000 port_set_link_speed(port);
6139 struct ksz_port *port = &priv->port;
6148 for (i = 0, p = port->first_port; i < port->mib_port_cnt; i++, p++) {
6152 /* Remember first port that requests read. */
6162 if (1 == port->mib_port_cnt && n < SWITCH_PORT_NUM) {
6169 for (i = 0, p = n; i < port->mib_port_cnt - n; i++, p++) {
6183 get_mib_counters(hw, port->first_port, port->mib_port_cnt, counter);
6252 struct ksz_port *port)
6254 if (priv->media_state != port->linked->state) {
6255 priv->media_state = port->linked->state;
6289 /* Only read MIB counters when the port is connected. */
6338 struct ksz_port *port = &priv->port;
6341 port_get_link_speed(port);
6342 update_link(dev, priv, port);
6362 * additional eth? device for the other port.
6427 priv->mii_if.phy_id = priv->port.first_port + 1;
6468 static void get_mac_addr(struct dev_info *hw_priv, u8 *macaddr, int port)
6493 if (MAIN_PORT == port) {
6508 if (MAIN_PORT == port)
6544 struct ksz_port *port;
6694 port = &priv->port;
6695 port->port_cnt = port_count;
6696 port->mib_port_cnt = mib_port_count;
6697 port->first_port = i;
6698 port->flow_ctrl = PHY_FLOW_CTRL;
6700 port->hw = hw;
6701 port->linked = &hw->port_info[port->first_port];
6719 addr[5] += port->first_port;
6733 port_set_power_saving(port, true);