From patchwork Wed May 29 14:00:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13678950 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-lj1-f181.google.com (mail-lj1-f181.google.com [209.85.208.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3CFFD12B95 for ; Wed, 29 May 2024 14:00:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716991206; cv=none; b=RK1mq3+J6F7AvheBmjtwYgjhOlwXlbMKvDTNHUJIyt42KVgGBbpAhtsDI6VRpQGYzKzMYg2kYbmfi8ZLqHyrPHnizEwmoCagcx5/2R8T9XfhG/bAeOREuZ3Eed2MMDizbnbmIlAp/gzlLhL4yiCp8G9SdLNMe6N1cpu9cSkRhpQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716991206; c=relaxed/simple; bh=CoBusJQazCOIEoGV+WMRvkw97W0ipsCQHXYjmrSMWjw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=uEggf/JZDN8EnBmhYXCVFTISLCulgO5WhqqHO8LL0v7qAOMBIgU2uGueC4lmIb3e2yOKdPnTPXoFOgqD9ggtVvLwOvY4Fw/Uqyfqs2RGd9m/C1Ls6SMNSmJ1itqy6LO8ixYouvzJcJAG/gHx/cZK1CQNHjAd5ndd3qNEarUby8M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=OBOCD3Q3; arc=none smtp.client-ip=209.85.208.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="OBOCD3Q3" Received: by mail-lj1-f181.google.com with SMTP id 38308e7fff4ca-2e3efa18e6aso9718621fa.0 for ; Wed, 29 May 2024 07:00:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1716991203; x=1717596003; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=uN7/h6kTo2XnMU/9NM8PFU9mkK1bfHP+69ug5lQnxeo=; b=OBOCD3Q3Ge1juDNfoSFmGK4xNdmj/+LUkYnTf57cPfFHqtSpG9YYobBhyKARDgMoER U7f1JRn3DSEpRekudcVcFfDuoDWi2hulR2zKEKHU20iqKnWK/ouamUv/a+0gXOjxB+N/ IhMJsvVgwJYauR0ul6D2MK1/GeOAGkglH4oaYNg9IdI/ehamXvZUJIzsUFAukyP95Wnm eWcj2T6R0ssXQ9M7QXlQhZyQBnFBMbMgG04/shJKlYftOfGtuxf02Z6oQlNqpVT6LczG pszt86MELsQpmN5rij/ydIrlUnZnhcOrFhB/6bEocEm5C3vxWyGGgejPcC71MfNo45sA OWsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716991203; x=1717596003; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uN7/h6kTo2XnMU/9NM8PFU9mkK1bfHP+69ug5lQnxeo=; b=i++GbHHa2Vuttaw76hqbBeqTy2WZ2q46OduMCE4pj0Nh/AZdYOTqQkuJKHhM3EMQ7s ituzGFa+106C/+9UJhffInLklFiMnm0lu6blHTAXApmlyynaP7ZMlFmw83md7MfHzCq1 eg9j1F0okCG87IWYHkGx8IueNKMz09Co1PKfoub36TKuauT/Xsfjg2euUhs1CDE5o55U HI6PbXI4hjdrHEpDJbYZAmjqu+vRVPn8T2hwLTP8n7Q0/PES2AyMqyXZ5xcRQZ1+/qT6 L79OezF+FbtD2jfgzZoourLoszUnn16iYgnl6eZySYmimceVTZeyd6cm2KqQZJF1yy0O EIPA== X-Gm-Message-State: AOJu0YybXfbSWZ7eBAEzpDzeXOArJhgM3vZJe8T+SnraAWjFZk5cFkth pxuhTk9Pha3tNwWB2q0TDHFn0ltSOPrlUFE2vGmaZcLQF36EMko2oTrshB19y5Y= X-Google-Smtp-Source: AGHT+IF5B2aYwHaoUG9A7wqPZZKFdHmfsG1ZG1/BGCj+rBRr8xBmSrqM2GBUlrQd1YIWaS9f+jQFEw== X-Received: by 2002:a05:651c:3c3:b0:2dc:f188:9945 with SMTP id 38308e7fff4ca-2ea4c8fdba5mr5386311fa.25.1716991203408; Wed, 29 May 2024 07:00:03 -0700 (PDT) Received: from [192.168.1.140] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2e95bcc47bfsm25472551fa.20.2024.05.29.07.00.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 07:00:02 -0700 (PDT) From: Linus Walleij Date: Wed, 29 May 2024 16:00:01 +0200 Subject: [PATCH net-next v4 2/3] net: ethernet: cortina: Use negotiated TX/RX pause Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240529-gemini-phylib-fixes-v4-2-16487ca4c2fe@linaro.org> References: <20240529-gemini-phylib-fixes-v4-0-16487ca4c2fe@linaro.org> In-Reply-To: <20240529-gemini-phylib-fixes-v4-0-16487ca4c2fe@linaro.org> To: Hans Ulli Kroll , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn Cc: netdev@vger.kernel.org, Linus Walleij X-Mailer: b4 0.13.0 X-Patchwork-Delegate: kuba@kernel.org Instead of directly poking into registers of the PHY, use the existing function to query phylib about this directly. Suggested-by: Andrew Lunn Reviewed-by: Andrew Lunn Signed-off-by: Linus Walleij --- drivers/net/ethernet/cortina/gemini.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c index ff3aeee15e5b..b33f9798471e 100644 --- a/drivers/net/ethernet/cortina/gemini.c +++ b/drivers/net/ethernet/cortina/gemini.c @@ -292,8 +292,8 @@ static void gmac_adjust_link(struct net_device *netdev) struct gemini_ethernet_port *port = netdev_priv(netdev); struct phy_device *phydev = netdev->phydev; union gmac_status status, old_status; - int pause_tx = 0; - int pause_rx = 0; + bool pause_tx = false; + bool pause_rx = false; status.bits32 = readl(port->gmac_base + GMAC_STATUS); old_status.bits32 = status.bits32; @@ -328,14 +328,9 @@ static void gmac_adjust_link(struct net_device *netdev) } if (phydev->duplex == DUPLEX_FULL) { - u16 lcladv = phy_read(phydev, MII_ADVERTISE); - u16 rmtadv = phy_read(phydev, MII_LPA); - u8 cap = mii_resolve_flowctrl_fdx(lcladv, rmtadv); - - if (cap & FLOW_CTRL_RX) - pause_rx = 1; - if (cap & FLOW_CTRL_TX) - pause_tx = 1; + phy_get_pause(phydev, &pause_tx, &pause_rx); + netdev_dbg(netdev, "set negotiated pause params pause TX = %s, pause RX = %s\n", + pause_tx ? "ON" : "OFF", pause_rx ? "ON" : "OFF"); } gmac_set_flow_control(netdev, pause_tx, pause_rx);