]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/net/cxgb3/cxgb3_main.c
V4L/DVB (8788): v4l: replace video_get_drvdata(video_devdata(filp)) with video_drvdat...
[linux-2.6-omap-h63xx.git] / drivers / net / cxgb3 / cxgb3_main.c
index fea2c719c8f74207a8182cb477b93ba8b53826ce..f31985df0bb9a2646adefd39746b8f05ab89072d 100644 (file)
@@ -208,6 +208,31 @@ void t3_os_link_changed(struct adapter *adapter, int port_id, int link_stat,
        }
 }
 
+/**
+ *     t3_os_phymod_changed - handle PHY module changes
+ *     @phy: the PHY reporting the module change
+ *     @mod_type: new module type
+ *
+ *     This is the OS-dependent handler for PHY module changes.  It is
+ *     invoked when a PHY module is removed or inserted for any OS-specific
+ *     processing.
+ */
+void t3_os_phymod_changed(struct adapter *adap, int port_id)
+{
+       static const char *mod_str[] = {
+               NULL, "SR", "LR", "LRM", "TWINAX", "TWINAX", "unknown"
+       };
+
+       const struct net_device *dev = adap->port[port_id];
+       const struct port_info *pi = netdev_priv(dev);
+
+       if (pi->phy.modtype == phy_modtype_none)
+               printk(KERN_INFO "%s: PHY module unplugged\n", dev->name);
+       else
+               printk(KERN_INFO "%s: %s PHY module inserted\n", dev->name,
+                      mod_str[pi->phy.modtype]);
+}
+
 static void cxgb_set_rxmode(struct net_device *dev)
 {
        struct t3_rx_mode rm;
@@ -1516,11 +1541,22 @@ static int speed_duplex_to_caps(int speed, int duplex)
 
 static int set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 {
+       int cap;
        struct port_info *p = netdev_priv(dev);
        struct link_config *lc = &p->link_config;
 
-       if (!(lc->supported & SUPPORTED_Autoneg))
-               return -EOPNOTSUPP;     /* can't change speed/duplex */
+       if (!(lc->supported & SUPPORTED_Autoneg)) {
+               /*
+                * PHY offers a single speed/duplex.  See if that's what's
+                * being requested.
+                */
+               if (cmd->autoneg == AUTONEG_DISABLE) {
+                       cap = speed_duplex_to_caps(cmd->speed, cmd->duplex);
+                       if (lc->supported & cap)
+                               return 0;
+               }
+               return -EINVAL;
+       }
 
        if (cmd->autoneg == AUTONEG_DISABLE) {
                int cap = speed_duplex_to_caps(cmd->speed, cmd->duplex);
@@ -2195,7 +2231,7 @@ static int cxgb_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
                        mmd = data->phy_id >> 8;
                        if (!mmd)
                                mmd = MDIO_DEV_PCS;
-                       else if (mmd > MDIO_DEV_XGXS)
+                       else if (mmd > MDIO_DEV_VEND2)
                                return -EINVAL;
 
                        ret =
@@ -2221,7 +2257,7 @@ static int cxgb_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
                        mmd = data->phy_id >> 8;
                        if (!mmd)
                                mmd = MDIO_DEV_PCS;
-                       else if (mmd > MDIO_DEV_XGXS)
+                       else if (mmd > MDIO_DEV_VEND2)
                                return -EINVAL;
 
                        ret =
@@ -2368,7 +2404,7 @@ static void check_link_status(struct adapter *adapter)
                struct net_device *dev = adapter->port[i];
                struct port_info *p = netdev_priv(dev);
 
-               if (!(p->port_type->caps & SUPPORTED_IRQ) && netif_running(dev))
+               if (!(p->phy.caps & SUPPORTED_IRQ) && netif_running(dev))
                        t3_link_changed(adapter, i);
        }
 }
@@ -2731,7 +2767,7 @@ static void __devinit print_port_info(struct adapter *adap,
                if (!test_bit(i, &adap->registered_device_map))
                        continue;
                printk(KERN_INFO "%s: %s %s %sNIC (rev %d) %s%s\n",
-                      dev->name, ai->desc, pi->port_type->desc,
+                      dev->name, ai->desc, pi->phy.desc,
                       is_offload(adap) ? "R" : "", adap->params.rev, buf,
                       (adap->flags & USING_MSIX) ? " MSI-X" :
                       (adap->flags & USING_MSI) ? " MSI" : "");