Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1532234

Re: [PATCH v3 net-next 1/2] net: ethernet: slicoss: add slicoss gigabit ethernet driver

From Markus Böhme <markus.boehme@mailbox.org>
Newsgroups linux.kernel
Subject Re: [PATCH v3 net-next 1/2] net: ethernet: slicoss: add slicoss gigabit ethernet driver
Date 2016-11-29 13:20 +0100
Message-ID <sIPy9-8o8-17@gated-at.bofh.it> (permalink)
References <sHKhc-6yp-9@gated-at.bofh.it> <sHKhc-6yp-7@gated-at.bofh.it> <sIc3L-7OS-3@gated-at.bofh.it> <sIB29-6Zn-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 11/28/2016 09:46 PM, Lino Sanfilippo wrote:
> Hi Markus,
> 
> On 27.11.2016 18:59, Markus Böhme wrote:
>> Hello Lino,
>>
>> just some things barely worth mentioning:
>>
> 
>>
>> I found a bunch of unused #defines in slic.h. I cannot judge if they are
>> worth keeping:
>>
>> 	SLIC_VRHSTATB_LONGE
>> 	SLIC_VRHSTATB_PREA
>> 	SLIC_ISR_IO
>> 	SLIC_ISR_PING_MASK
>> 	SLIC_GIG_SPEED_MASK
>> 	SLIC_GMCR_RESET
>> 	SLIC_XCR_RESET
>> 	SLIC_XCR_XMTEN
>> 	SLIC_XCR_PAUSEEN
>> 	SLIC_XCR_LOADRNG
>> 	SLIC_REG_DBAR
>> 	SLIC_REG_PING
>> 	SLIC_REG_DUMP_CMD
>> 	SLIC_REG_DUMP_DATA
>> 	SLIC_REG_WRHOSTID
>> 	SLIC_REG_LOW_POWER
>> 	SLIC_REG_RESET_IFACE
>> 	SLIC_REG_ADDR_UPPER
>> 	SLIC_REG_HBAR64
>> 	SLIC_REG_DBAR64
>> 	SLIC_REG_CBAR64
>> 	SLIC_REG_RBAR64
>> 	SLIC_REG_WRVLANID
>> 	SLIC_REG_READ_XF_INFO
>> 	SLIC_REG_WRITE_XF_INFO
>> 	SLIC_REG_TICKS_PER_SEC
>>
>> These device IDs are not used, either, but maybe it's good to keep them
>> for documentation purposes:
>>
>> 	PCI_SUBDEVICE_ID_ALACRITECH_1000X1_2
>> 	PCI_SUBDEVICE_ID_ALACRITECH_SES1001T
>> 	PCI_SUBDEVICE_ID_ALACRITECH_SEN2002XT
>> 	PCI_SUBDEVICE_ID_ALACRITECH_SEN2001XT
>> 	PCI_SUBDEVICE_ID_ALACRITECH_SEN2104ET
>> 	PCI_SUBDEVICE_ID_ALACRITECH_SEN2102ET
>>
> 
> I left these defines in for both documentation and to avoid gaps in
> register ranges. I would like to keep this as it is.

Seems reasonable.

[...]

>>> +static int slic_init_tx_queue(struct slic_device *sdev)
>>> +{
>>> +	struct slic_tx_queue *txq = &sdev->txq;
>>> +	struct slic_tx_buffer *buff;
>>> +	struct slic_tx_desc *desc;
>>> +	int err;
>>> +	int i;
>>
>> You could make i unsigned...
>>
> 
>>> +
>>> +	txq->len = SLIC_NUM_TX_DESCS;
>>> +	txq->put_idx = 0;
>>> +	txq->done_idx = 0;
>>> +
>>> +	txq->txbuffs = kcalloc(txq->len, sizeof(*buff), GFP_KERNEL);
>>> +	if (!txq->txbuffs)
>>> +		return -ENOMEM;
>>> +
>>> +	txq->dma_pool = dma_pool_create("slic_pool", &sdev->pdev->dev,
>>> +					sizeof(*desc), SLIC_TX_DESC_ALIGN,
>>> +					4096);
>>> +	if (!txq->dma_pool) {
>>> +		err = -ENOMEM;
>>> +		netdev_err(sdev->netdev, "failed to create dma pool\n");
>>> +		goto free_buffs;
>>> +	}
>>> +
>>> +	for (i = 0; i < txq->len; i++) {
>>
>> ...to fix a signed/unsigned comparison warning here, but...
>>
>>> +		buff = &txq->txbuffs[i];
>>> +		desc = dma_pool_zalloc(txq->dma_pool, GFP_KERNEL,
>>> +				       &buff->desc_paddr);
>>> +		if (!desc) {
>>> +			netdev_err(sdev->netdev,
>>> +				   "failed to alloc pool chunk (%i)\n", i);
>>> +			err = -ENOMEM;
>>> +			goto free_descs;
>>> +		}
>>> +
>>> +		desc->hnd = cpu_to_le32((u32)(i + 1));
>>> +		desc->cmd = SLIC_CMD_XMT_REQ;
>>> +		desc->flags = 0;
>>> +		desc->type = cpu_to_le32(SLIC_CMD_TYPE_DUMB);
>>> +		buff->desc = desc;
>>> +	}
>>> +
>>> +	return 0;
>>> +
>>> +free_descs:
>>> +	while (i--) {
>>
>> ...this would require reworking this logic to prevent an endless loop,
>> so probably not worth bothering, considering that txq->len is well
>> within the positive signed range.
> 
> AFAICS the logic does not have to be changed. The while loop will also work
> fine if "i" is unsigned.
> 

My bad! Of course you are right.


Regards,
Markus

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Gigabit ethernet driver for Alacritechs SLIC devices (v3) Lino Sanfilippo <LinoSanfilippo@gmx.de> - 2016-11-26 13:30 +0100
  [PATCH v3 net-next 2/2] MAINTAINERS: add entry for slicoss ethernet driver Lino Sanfilippo <LinoSanfilippo@gmx.de> - 2016-11-26 13:30 +0100
  Re: Gigabit ethernet driver for Alacritechs SLIC devices (v3) Lino Sanfilippo <LinoSanfilippo@gmx.de> - 2016-11-26 13:40 +0100
  Re: [PATCH v3 net-next 1/2] net: ethernet: slicoss: add slicoss  gigabit ethernet driver Rami Rosen <roszenrami@gmail.com> - 2016-11-26 16:50 +0100
    Re: [PATCH v3 net-next 1/2] net: ethernet: slicoss: add slicoss  gigabit ethernet driver Lino Sanfilippo <LinoSanfilippo@gmx.de> - 2016-11-27 02:10 +0100
  Re: [PATCH v3 net-next 1/2] net: ethernet: slicoss: add slicoss  gigabit ethernet driver Markus Böhme <markus.boehme@mailbox.org> - 2016-11-27 19:10 +0100
    Re: [PATCH v3 net-next 1/2] net: ethernet: slicoss: add slicoss  gigabit ethernet driver Lino Sanfilippo <LinoSanfilippo@gmx.de> - 2016-11-28 21:50 +0100
      Re: [PATCH v3 net-next 1/2] net: ethernet: slicoss: add slicoss  gigabit ethernet driver Markus Böhme <markus.boehme@mailbox.org> - 2016-11-29 13:20 +0100
  Re: [PATCH v3 net-next 1/2] net: ethernet: slicoss: add slicoss  gigabit ethernet driver Florian Fainelli <f.fainelli@gmail.com> - 2016-11-28 06:00 +0100
    Re: [PATCH v3 net-next 1/2] net: ethernet: slicoss: add slicoss  gigabit ethernet driver Lino Sanfilippo <LinoSanfilippo@gmx.de> - 2016-11-28 22:50 +0100
      Re: [PATCH v3 net-next 1/2] net: ethernet: slicoss: add slicoss  gigabit ethernet driver Florian Fainelli <f.fainelli@gmail.com> - 2016-11-29 18:20 +0100
        Re: [PATCH v3 net-next 1/2] net: ethernet: slicoss: add slicoss  gigabit ethernet driver Lino Sanfilippo <LinoSanfilippo@gmx.de> - 2016-11-30 21:00 +0100

csiph-web