Hi > -----Original Message----- > From: Wu, Jingjing <jingjing...@intel.com> > Sent: Tuesday, September 8, 2020 00:16 > To: Li, Xiaoyun <xiaoyun...@intel.com> > Cc: dev@dpdk.org; Maslekar, Omkar <omkar.masle...@intel.com> > Subject: RE: [PATCH v3] raw/ntb: add Icelake support for Intel NTB > > > > > - rte_write64(limit, limit_addr); > > > > + if (is_gen3_ntb(hw)) { > > > > + /* Setup the external point so that remote can access. > > > > */ > > > > + xlat_off = XEON_EMBAR1_OFFSET + 8 * mw_idx; > > > > + xlat_addr = hw->hw_addr + xlat_off; > > > > + limit_off = XEON_EMBAR1XLMT_OFFSET + > > > > + mw_idx * XEON_BAR_INTERVAL_OFFSET; > > > > + limit_addr = hw->hw_addr + limit_off; > > > > + base = rte_read64(xlat_addr); > > > > + base &= ~0xf; > > > > + limit = base + size; > > > > + rte_write64(limit, limit_addr); > > > > + } else if (is_gen4_ntb(hw)) { > > > Can we use a variable in struct to indicate it's gen4 or gen3 after > > > init instead of check it every time? > > > > What's the difference? It comes from the value in hw->pci_dev->id.device_id. > > Checking it in this way is trying to make it easier to extend it for gen2 > > ntb in the > future. > > It's not either gen3 or gen4. > > I don't think it makes sense to have a bool value to indicate it's gen3 or > > gen4. > > Understand, as the inline function is very simple, it looks OK. > > > > > > > > > + /* Set translate base address index register */ > > > > + xlat_off = XEON_GEN4_IM1XBASEIDX_OFFSET + > > > > + mw_idx * XEON_GEN4_XBASEIDX_INTERVAL; > > > > + xlat_addr = hw->hw_addr + xlat_off; > > > > + rte_write16(rte_log2_u64(size), xlat_addr); > > > > + } else { > > > > + rte_write64(base, limit_addr); > > > > + rte_write64(0, xlat_addr); > > > > + return -ENOTSUP; > > > > + } > > > Is the else branch necessary? As if neither gen3 or gen4, the init would > > > fail. > > > Would be better to print an ERR instead of just return NO support. > > > > I don't think so. > > Yes. It will fail in init. Returning err is to stop other following > > actions like in > > intel_ntb_vector_bind() since it should be stopped. > > And I'd like to keep them in one coding style. As to the print, I > > think that can be upper layer's job to check the value and print err. > > Choosing ENOTSUP is because that in init, if it's not supported hw, it > > will return - ENOTSUP err. > > > I cannot say what you did is incorrect. But try to think it like this way: > according > current API design, ntb raw device is allocated when driver probe, if init > fails, > raw device would be free. How the ops be called?
I'll add a err print later. > > > > > > > > > return 0; > > > > } > > >